Go to the source code of this file.
Functions | |
int | selectChannelATHEROS (char *devname, int channel) |
int | shutCardATHEROS (char *devname) |
int | openCardATHEROS (char *devname) |
int | getPacketATHEROS (p80211_caphdr_t *wlan_header, UINT8 *buf, int maxlen) |
int | openPacketATHEROS (char *devname) |
void | closePacketATHEROS (void) |
int selectChannelATHEROS | ( | char * | devname, | |
int | channel | |||
) |
Definition at line 50 of file atheros.c.
References IwconfigSetChannel(), and NO_ERROR.
Referenced by selectChannel().
00051 { 00052 int result = NO_ERROR; 00053 00054 result = IwconfigSetChannel(devname, channel); 00055 return NO_ERROR; // disintegrate error ... 00056 // return result; // XXX 00057 }
int shutCardATHEROS | ( | char * | devname | ) |
Definition at line 59 of file atheros.c.
References IfconfigSetFlags(), IwconfigSetMode(), NO_ERROR, and warning_if_error().
Referenced by shutCard().
00060 { 00061 #define STR_MAX 80 00062 int result = NO_ERROR; 00063 00064 // Turn off monitor mode, and promisc mode 00065 result = IwconfigSetMode(devname, IW_MODE_INFRA); 00066 warning_if_error(result); 00067 result = IfconfigSetFlags(devname, IFF_UP); 00068 warning_if_error(result); 00069 00070 return result; 00071 }
int openCardATHEROS | ( | char * | devname | ) |
Definition at line 73 of file atheros.c.
References IfconfigSetFlags(), IwconfigSetMode(), NO_ERROR, and warning_if_error().
Referenced by openCard().
00074 { 00075 int result = NO_ERROR; 00076 00077 // Turn on monitor mode and promisc mode 00078 result = IwconfigSetMode(devname, IW_MODE_MONITOR); 00079 warning_if_error(result); 00080 result = IfconfigSetFlags(devname, IFF_UP + IFF_PROMISC); 00081 warning_if_error(result); 00082 00083 return result; 00084 }
int getPacketATHEROS | ( | p80211_caphdr_t * | wlan_header, | |
UINT8 * | buf, | |||
int | maxlen | |||
) |
Definition at line 88 of file atheros.c.
References p80211_caphdr::antenna, p80211msg_lnxind_wlansniffrm::channel, p80211_caphdr::channel, p80211item_uint32::data, p80211_caphdr::datarate, p80211_caphdr::encoding, p80211msg_lnxind_wlansniffrm::hosttime, p80211_caphdr::hosttime, p80211_caphdr::length, p80211msg_lnxind_wlansniffrm::mactime, p80211_caphdr::mactime, MAX_BUFFER_SIZE, memcpy_buff(), p80211msg_lnxind_wlansniffrm::noise, CaptureArg_t::pcap, p80211_caphdr::phytype, phytype_dsss_dot11_b, p80211_caphdr::preamble, p80211_caphdr::priority, p80211msg_lnxind_wlansniffrm::rate, p80211msg_lnxind_wlansniffrm::signal, p80211_caphdr::ssi_noise, p80211_caphdr::ssi_signal, p80211_caphdr::ssi_type, p80211_caphdr::version, and wlan_payload.
Referenced by getPacket().
00089 { 00090 struct pcap_pkthdr pktHdr; 00091 u_char *ret; 00092 fd_set rs; 00093 p80211msg_lnxind_wlansniffrm_t *Sniff_Frame; 00094 static UINT8 wlan_payload[MAX_BUFFER_SIZE]; 00095 00096 FD_ZERO(&rs); 00097 FD_SET(0, &rs); 00098 00099 ret = (u_char *) pcap_next(ca.pcap, &pktHdr); 00100 00101 // If no problem and packet is enought big (with data) 00102 if ((ret) 00103 && (pktHdr.len >= sizeof(p80211msg_lnxind_wlansniffrm_t))) { 00104 if (memcpy_buff(buf, ret, pktHdr.len) == NULL) 00105 return 0; 00106 Sniff_Frame = (p80211msg_lnxind_wlansniffrm_t *) buf; 00107 // Fill Header 00108 wlan_header->version = 0; // It's a reduced capture frame format 00109 wlan_header->length = 0; // Not used for now 00110 wlan_header->mactime = Sniff_Frame->mactime.data; 00111 wlan_header->hosttime = Sniff_Frame->hosttime.data; 00112 wlan_header->phytype = phytype_dsss_dot11_b; // Not used for now 00113 wlan_header->channel = Sniff_Frame->channel.data; 00114 wlan_header->datarate = Sniff_Frame->rate.data * 5; // datarate is in units of 100kbps. 00115 wlan_header->antenna = 0; // Not used for now 00116 wlan_header->priority = 0; // Not used for now 00117 wlan_header->ssi_type = 0; // Not used for now 00118 wlan_header->ssi_signal = Sniff_Frame->signal.data; 00119 wlan_header->ssi_noise = Sniff_Frame->noise.data; 00120 wlan_header->preamble = 0; // Not used for now 00121 wlan_header->encoding = 0; // Not used for now 00122 // Fill data frame 00123 if (memcpy_buff(wlan_payload, 00124 &buf[sizeof(p80211msg_lnxind_wlansniffrm_t)], 00125 pktHdr.len - sizeof(p80211msg_lnxind_wlansniffrm_t)) == 00126 NULL) 00127 return 0; 00128 if (memcpy_buff(buf, wlan_payload, 00129 maxlen - sizeof(p80211msg_lnxind_wlansniffrm_t)) == 00130 NULL) 00131 return 0; 00132 00133 if (pktHdr.len <= sizeof(p80211msg_lnxind_wlansniffrm_t)) 00134 // Don't return negative value 00135 return 0; 00136 else 00137 return (pktHdr.len - sizeof(p80211msg_lnxind_wlansniffrm_t)); 00138 } else { 00139 return (0); // Noting to read 00140 } 00141 }
int openPacketATHEROS | ( | char * | devname | ) |
Definition at line 143 of file atheros.c.
References CalculateOffset(), CaptureArg_t::DataLink, errbuf, ERROR_CANT_OPEN_PCAP, NO_ERROR, CaptureArg_t::offset, and CaptureArg_t::pcap.
Referenced by openPacket().
00144 { 00145 ca.pcap = pcap_open_live(devname, 3000, 1, 0, errbuf); 00146 if (ca.pcap) { 00147 pcap_setnonblock(ca.pcap, 1, errbuf); 00148 ca.DataLink = pcap_datalink(ca.pcap); 00149 ca.offset = CalculateOffset(ca.DataLink); 00150 return NO_ERROR; 00151 } 00152 return ERROR_CANT_OPEN_PCAP; 00153 }
void closePacketATHEROS | ( | void | ) |
Definition at line 155 of file atheros.c.
References CaptureArg_t::pcap.
Referenced by closePacket().