#include <include.h>
#include <src/hermes.h>
#include <src/crt_io.h>
#include <src/functions.h>
Go to the source code of this file.
Functions | |
int | selectChannelHERMES (char *devname, int channel) |
int | shutCardHERMES (char *devname) |
int | openCardHERMES (char *devname) |
int | getPacketHERMES (p80211_caphdr_t *wlan_header, UINT8 *buf, int maxlen) |
int | openPacketHERMES (char *devname) |
void | closePacketHERMES (void) |
Variables | |
static char * | ID = "$Id: hermes.c 174 2007-07-25 13:20:29Z poggij $" |
UINT8 | SingleChannel |
UINT8 | TypeOfCard |
static CaptureArg | ca |
static char | errbuf [PCAP_ERRBUF_SIZE] |
static UINT8 | wlan_payload [4096] |
int selectChannelHERMES | ( | char * | devname, | |
int | channel | |||
) |
Definition at line 47 of file hermes.c.
References Iwconfig_Set_IntPriv(), and NO_ERROR.
Referenced by selectChannel().
00048 { 00049 char str[80]; 00050 int result = NO_ERROR; 00051 00052 #if 0 00053 sprintf(str, "iwpriv %s monitor 1 %d 2>/dev/null 1>/dev/null", devname, 00054 channel); 00055 //debug(3, str, "\n"); 00056 result += system(str); 00057 #endif 00058 Iwconfig_Set_IntPriv(devname, "monitor", 1, channel); 00059 00060 //return result; 00061 // No error return, because it's possible to change to a forbidden channel 00062 // So we don't want that the program stop because of this restriction 00063 return NO_ERROR; 00064 }
int shutCardHERMES | ( | char * | devname | ) |
Definition at line 66 of file hermes.c.
References debug, IfconfigSetFlags(), IwconfigSetMode(), NO_ERROR, and warning_if_error().
Referenced by shutCard().
00067 { 00068 char str[80]; 00069 int result = NO_ERROR; 00070 00071 // Turn off monitor mode 00072 result = IwconfigSetMode(devname, IW_MODE_INFRA); 00073 warning_if_error(result); 00074 00075 result = IfconfigSetFlags(devname, 0); 00076 warning_if_error(result); 00077 00078 sprintf(str, "iwpriv %s monitor 0 1", devname); 00079 debug(3, "%s\n", str); 00080 result += system(str); 00081 00082 return result; 00083 }
int openCardHERMES | ( | char * | devname | ) |
Definition at line 85 of file hermes.c.
References debug, IfconfigSetFlags(), IwconfigClearSSID(), NO_ERROR, and warning_if_error().
Referenced by openCard().
00086 { 00087 char str[80]; 00088 int result = NO_ERROR; 00089 00090 // Turn on monitor mode 00091 result = IfconfigSetFlags(devname, IFF_UP + IFF_PROMISC); 00092 warning_if_error(result); 00093 00094 IwconfigClearSSID(devname); 00095 00096 sprintf(str, "iwpriv %s monitor 1 1", devname); 00097 debug(3, "%s\n", str); 00098 result += system(str); 00099 00100 return result; 00101 }
int getPacketHERMES | ( | p80211_caphdr_t * | wlan_header, | |
UINT8 * | buf, | |||
int | maxlen | |||
) |
Definition at line 105 of file hermes.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, 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().
00106 { 00107 struct pcap_pkthdr pktHdr; 00108 u_char *ret; 00109 fd_set rs; 00110 p80211msg_lnxind_wlansniffrm_t *Sniff_Frame; 00111 00112 FD_ZERO(&rs); 00113 FD_SET(0, &rs); 00114 00115 ret = (u_char *) pcap_next(ca.pcap, &pktHdr); 00116 // If no problem and packet is enought big (with data) 00117 if ((ret) 00118 && (pktHdr.len >= sizeof(p80211msg_lnxind_wlansniffrm_t))) { 00119 if (memcpy_buff(buf, ret, pktHdr.len) == NULL) 00120 return 0; 00121 Sniff_Frame = (p80211msg_lnxind_wlansniffrm_t *) buf; 00122 // Fill Header 00123 wlan_header->version = 0; // It's a reduced capture frame format 00124 wlan_header->length = 0; // Not used for now 00125 wlan_header->mactime = Sniff_Frame->mactime.data; 00126 wlan_header->hosttime = Sniff_Frame->hosttime.data; 00127 wlan_header->phytype = phytype_dsss_dot11_b; // Not used for now 00128 wlan_header->channel = Sniff_Frame->channel.data; 00129 wlan_header->datarate = Sniff_Frame->rate.data * 5; // datarate is in units of 100kbps. 00130 wlan_header->antenna = 0; // Not used for now 00131 wlan_header->priority = 0; // Not used for now 00132 wlan_header->ssi_type = 0; // Not used for now 00133 wlan_header->ssi_signal = Sniff_Frame->signal.data; 00134 wlan_header->ssi_noise = Sniff_Frame->noise.data; 00135 wlan_header->preamble = 0; // Not used for now 00136 wlan_header->encoding = 0; // Not used for now 00137 // Fill data frame 00138 if (memcpy_buff(wlan_payload, 00139 &buf[sizeof(p80211msg_lnxind_wlansniffrm_t)], 00140 pktHdr.len - sizeof(p80211msg_lnxind_wlansniffrm_t)) == 00141 NULL) 00142 return 0; 00143 if (memcpy_buff(buf, wlan_payload, 00144 maxlen - sizeof(p80211msg_lnxind_wlansniffrm_t)) == 00145 NULL) 00146 return 0; 00147 00148 if (pktHdr.len <= sizeof(p80211msg_lnxind_wlansniffrm_t)) 00149 // Don't return negative value 00150 return 0; 00151 else 00152 return (pktHdr.len - sizeof(p80211msg_lnxind_wlansniffrm_t)); 00153 } else { 00154 return (0); /* Noting to read */ 00155 } 00156 }
int openPacketHERMES | ( | char * | devname | ) |
Definition at line 158 of file hermes.c.
References CalculateOffset(), CaptureArg_t::DataLink, errbuf, ERROR_CANT_OPEN_PCAP, NO_ERROR, CaptureArg_t::offset, and CaptureArg_t::pcap.
Referenced by openPacket().
00159 { 00160 ca.pcap = pcap_open_live(devname, 3000, 1, 0, errbuf); 00161 if (ca.pcap) { 00162 pcap_setnonblock(ca.pcap, 1, errbuf); 00163 ca.DataLink = pcap_datalink(ca.pcap); 00164 ca.offset = CalculateOffset(ca.DataLink); 00165 return NO_ERROR; 00166 } 00167 return ERROR_CANT_OPEN_PCAP; 00168 }
void closePacketHERMES | ( | void | ) |
Definition at line 170 of file hermes.c.
References CaptureArg_t::pcap.
Referenced by closePacket().
char* ID = "$Id: hermes.c 174 2007-07-25 13:20:29Z poggij $" [static] |
CaptureArg ca [static] |
UINT8 wlan_payload[4096] [static] |