00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00021 #include <net/ethernet.h>
00022 #include <math.h>
00023 #include <stdio.h>
00024 #include "iw_compat.h"
00025
00026
00030 void
00031 iw_ether_ntop(const struct ether_addr *eth, char *buf)
00032 {
00033 sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
00034 eth->ether_addr_octet[0], eth->ether_addr_octet[1],
00035 eth->ether_addr_octet[2], eth->ether_addr_octet[3],
00036 eth->ether_addr_octet[4], eth->ether_addr_octet[5]);
00037 }
00038
00044 char *
00045 iw_sawap_ntop(const struct sockaddr *sap, char *buf)
00046 {
00047 const struct ether_addr ether_zero = {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }};
00048 const struct ether_addr ether_bcast = {{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }};
00049 const struct ether_addr ether_hack = {{ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }};
00050 const struct ether_addr *ether_wap = (const struct ether_addr *) sap->sa_data;
00051
00052 if (!iw_ether_cmp(ether_wap, ðer_zero))
00053 sprintf(buf, "Not-Associated");
00054 else
00055 if (!iw_ether_cmp(ether_wap, ðer_bcast))
00056 sprintf(buf, "Invalid");
00057 else
00058 if(!iw_ether_cmp(ether_wap, ðer_hack))
00059 sprintf(buf, "None");
00060 else
00061 iw_ether_ntop(ether_wap, buf);
00062
00063 return(buf);
00064 }
00065
00066
00073 void
00074 iw_float2freq(double in, iwfreq *out)
00075 {
00076 out->e = (short) (floor(log10(in)));
00077 if(out->e > 8)
00078 {
00079 out->m = ((long) (floor(in / pow(10,out->e - 6)))) * 100;
00080 out->e -= 8;
00081 } else {
00082 out->m = (long) in;
00083 out->e = 0;
00084 }
00085 }
00086
00090 double
00091 iw_freq2float(const iwfreq *in)
00092 {
00093 return ((double) in->m) * pow(10,in->e);
00094 }
00095
00097 int16_t
00098 dbm2mw(int16_t in)
00099 {
00100 return((int16_t) (floor(pow(10.0, (((double) in) / 10.0)))));
00101 }
00102
00110 int
00111 iw_get_param_state(struct iw_param * par)
00112 {
00113 return !(par->disabled == 1);
00114 }