コード例 #1
0
int main(void)
{
    const unsigned int FrameLen = 36;
    unsigned char *macframe = malloc(FrameLen);  // alloc MAC header until frame body
    
    // fill header with junk, to make this more interesting
    for (unsigned int i = 0; i < FrameLen; i++) {
        macframe[i] = 0xde;
    }
    
    set_proto_version(macframe, 0);
    set_type(macframe, 1);
    set_subtype(macframe, 1);
    set_to_ds(macframe, 1);
    set_from_ds(macframe, 0);
    set_retry(macframe, 0);
    set_more_data(macframe, 0);
    
    print_header(macframe);
    
    printf("Protocol version: %d\n", get_proto_version(macframe));
    printf("Type: %d\n", get_type(macframe));
    printf("Subtype: %d\n", get_subtype(macframe));
    printf("Flags: To DS: %d  From DS: %d  Retry: %d  More Data: %d\n",
            get_to_ds(macframe) != 0, get_from_ds(macframe) != 0,
            get_retry(macframe) != 0, get_more_data(macframe) != 0);
    
    free(macframe);
}
コード例 #2
0
ファイル: iw.c プロジェクト: mixalturek/xsysguard
static const char *
help_iw(void)
{
	static xsg_string_t *string = NULL;
	xsg_list_t *l;
	int i = 0;

	init_iw();

	if (skfd < 0) {
		return NULL;
	}

	if (string == NULL) {
		string = xsg_string_new(NULL);
	} else {
		xsg_string_truncate(string, 0);
	}

	get_iw_device_list();

	for (l = device_list; l; l = l->next) {
		char name[128];

		snprintf(name, sizeof(name), "IW_INTERFACE%d", i++);
		xsg_setenv(name, (char *) device_list->data, TRUE);

		xsg_string_append_printf(string, "%s:   %s\n", name,
				(char *) device_list->data);
	}

	xsg_string_append(string, "\n");

	for (l = device_list; l; l = l->next) {
		char *ifname = (char *) l->data;

		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "config:name",
				get_name(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "config:nwid",
				get_nwid(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "config:freq",
				get_freq_number(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "config:freq",
				get_freq_string(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "config:channel",
				get_channel(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "config:key",
				get_key(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "config:keyid",
				get_keyid(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "config:essid",
				get_essid(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "config:mode",
				get_mode_number(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "config:mode",
				get_mode_string(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "info:sensitivity",
				get_sens(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "info:nickname",
				get_nickname(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "info:access_point",
				get_ap(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "info:bitrate",
				get_bitrate_number(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "info:bitrate",
				get_bitrate_string(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "info:rts",
				get_rts_number(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "info:rts",
				get_rts_string(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "info:fragment",
				get_frag_number(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "info:fragment",
				get_frag_string(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "info:power_management",
				get_power_management(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "info:txpower:dbm",
				get_txpower_dbm(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.2f\n",
				XSG_MODULE_NAME, ifname, "info:txpower:mw",
				get_txpower_mw(ifname));
		xsg_string_append_printf(string, "S %s:%s:%-36s%s\n",
				XSG_MODULE_NAME, ifname, "info:retry",
				get_retry(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "stats:quality:quality",
				get_stats_quality_quality(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "stats:quality:signal",
				get_stats_quality_signal(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "stats:quality:noise",
				get_stats_quality_noise(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "stats:discarded:nwid",
				get_stats_discarded_nwid(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "stats:discarded:code",
				get_stats_discarded_code(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "stats:discarded:fragment",
				get_stats_discarded_fragment(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "stats:discarded:retries",
				get_stats_discarded_retries(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "stats:discarded:misc",
				get_stats_discarded_misc(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "stats:missed:beacon",
				get_stats_missed_beacon(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "range:sensitivity",
				get_range_sensitivity(ifname));
		xsg_string_append_printf(string, "N %s:%s:%-36s%.0f\n",
				XSG_MODULE_NAME, ifname, "range:max_quality:quality",
				get_range_max_quality_quality(ifname));
	}

	return string->str;
}