]>
git.ipfire.org Git - thirdparty/iw.git/blob - util.c
5 int mac_addr_n2a(char *mac_addr
, unsigned char *arg
)
10 for (i
= 0; i
< ETH_ALEN
; i
++) {
12 sprintf(mac_addr
+l
, "%02x", arg
[i
]);
15 sprintf(mac_addr
+l
, ":%02x", arg
[i
]);
22 int mac_addr_a2n(unsigned char *mac_addr
, char *arg
)
26 for (i
= 0; i
< ETH_ALEN
; i
++) {
28 char *cp
= strchr(arg
, ':');
33 if (sscanf(arg
, "%x", &temp
) != 1)
35 if (temp
< 0 || temp
> 255)
49 static const char *ifmodes
[NL80211_IFTYPE_MAX
+ 1] = {
60 static char modebuf
[100];
62 const char *iftype_name(enum nl80211_iftype iftype
)
64 if (iftype
<= NL80211_IFTYPE_MAX
)
65 return ifmodes
[iftype
];
66 sprintf(modebuf
, "Unknown mode (%d)", iftype
);
70 int ieee80211_channel_to_frequency(int chan
)
73 return 2407 + chan
* 5;
78 /* FIXME: dot11ChannelStartingFactor (802.11-2007 17.3.8.3.2) */
79 return (chan
+ 1000) * 5;
82 int ieee80211_frequency_to_channel(int freq
)
88 return (freq
- 2407) / 5;
90 /* FIXME: dot11ChannelStartingFactor (802.11-2007 17.3.8.3.2) */
94 void print_ssid_escaped(const uint8_t len
, const uint8_t *data
)
98 for (i
= 0; i
< len
; i
++) {
100 printf("%c", data
[i
]);
102 printf("\\x%.2x", data
[i
]);