#include <include.h>
#include <src/prism54g.h>
#include <src/wlan-ng.h>
#include <src/functions.h>
#include <src/crt_io.h>
Go to the source code of this file.
Functions | |
int | selectChannelPRISM54g (char *devname, int channel) |
int | shutCardPRISM54g (char *devname) |
int | openCardPRISM54g (char *devname) |
int | getPacketPRISM54g (p80211_caphdr_t *wlan_header, UINT8 *buf, int maxlen) |
int | openPacketPRISM54g (char *devname) |
void | closePacketPRISM54g (void) |
Variables | |
static char * | ID = "$Id: prism54g.c 174 2007-07-25 13:20:29Z poggij $" |
ConfigStruct | config |
static CaptureArg | ca |
static char | errbuf [PCAP_ERRBUF_SIZE] |
int selectChannelPRISM54g | ( | char * | devname, | |
int | channel | |||
) |
Definition at line 50 of file prism54g.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; 00056 //return result; 00057 }
int shutCardPRISM54g | ( | char * | devname | ) |
Definition at line 59 of file prism54g.c.
References IfconfigSetFlags(), IwconfigSetMode(), NO_ERROR, and warning_if_error().
Referenced by shutCard().
00060 { 00061 int result = NO_ERROR; 00062 00063 // Turn off monitor mode 00064 result = IwconfigSetMode(devname, IW_MODE_INFRA); 00065 warning_if_error(result); 00066 result = IfconfigSetFlags(devname, 0); 00067 warning_if_error(result); 00068 return result; 00069 }
int openCardPRISM54g | ( | char * | devname | ) |
Definition at line 71 of file prism54g.c.
References IfconfigSetFlags(), IwconfigSetMode(), NO_ERROR, and warning_if_error().
Referenced by openCard().
00072 { 00073 int result = NO_ERROR; 00074 00075 // Turn on monitor mode 00076 result = IwconfigSetMode(devname, IW_MODE_MONITOR); 00077 warning_if_error(result); 00078 result = IfconfigSetFlags(devname, IFF_UP + IFF_PROMISC); 00079 warning_if_error(result); 00080 return result; 00081 }
int getPacketPRISM54g | ( | p80211_caphdr_t * | wlan_header, | |
UINT8 * | buf, | |||
int | maxlen | |||
) |
Definition at line 85 of file prism54g.c.
References p80211_caphdr::antenna, p80211_caphdr::channel, p80211_caphdr::datarate, p80211_caphdr::encoding, p80211_caphdr::hosttime, p80211_caphdr::length, p80211_caphdr::mactime, memcpy_buff(), CaptureArg_t::pcap, p80211_caphdr::phytype, p80211_caphdr::preamble, p80211_caphdr::priority, p80211_caphdr::ssi_noise, p80211_caphdr::ssi_signal, p80211_caphdr::ssi_type, and p80211_caphdr::version.
Referenced by getPacket().
00086 { 00087 struct pcap_pkthdr pktHdr; 00088 u_char *ret; 00089 fd_set rs; 00090 00091 FD_ZERO(&rs); 00092 FD_SET(0, &rs); 00093 00094 ret = (u_char *) pcap_next(ca.pcap, &pktHdr); 00095 // If no problem and packet is enought big (with data) 00096 if ((ret) && (pktHdr.len >= 1)) { 00097 if (memcpy_buff(buf, ret, pktHdr.len) == NULL) 00098 return 0; 00099 // Fill Header 00100 // TODO : find this information in any maner ?! 00101 wlan_header->version = 0; // It's a reduced capture frame format 00102 wlan_header->length = 0; // Not used for now 00103 wlan_header->mactime = 0; 00104 wlan_header->hosttime = 0; 00105 wlan_header->phytype = 0; // Not used for now 00106 wlan_header->channel = 0; 00107 wlan_header->datarate = 0; // datarate is in units of 100kbps. 00108 wlan_header->antenna = 0; // Not used for now 00109 wlan_header->priority = 0; // Not used for now 00110 wlan_header->ssi_type = 0; // Not used for now 00111 wlan_header->ssi_signal = 0; 00112 wlan_header->ssi_noise = 0; 00113 wlan_header->preamble = 0; // Not used for now 00114 wlan_header->encoding = 0; // Not used for now 00115 00116 return pktHdr.len; 00117 } else { 00118 return (0); // Noting to read 00119 } 00120 }
int openPacketPRISM54g | ( | char * | devname | ) |
Definition at line 122 of file prism54g.c.
References CalculateOffset(), CaptureArg_t::DataLink, errbuf, ERROR_CANT_OPEN_PCAP, NO_ERROR, CaptureArg_t::offset, and CaptureArg_t::pcap.
Referenced by openPacket().
00123 { 00124 ca.pcap = pcap_open_live(devname, 3000, 1, 0, errbuf); 00125 if (ca.pcap) { 00126 pcap_setnonblock(ca.pcap, 1, errbuf); 00127 ca.DataLink = pcap_datalink(ca.pcap); 00128 ca.offset = CalculateOffset(ca.DataLink); 00129 return NO_ERROR; 00130 } 00131 return ERROR_CANT_OPEN_PCAP; 00132 }
void closePacketPRISM54g | ( | void | ) |
Definition at line 134 of file prism54g.c.
References CaptureArg_t::pcap.
Referenced by closePacket().
char* ID = "$Id: prism54g.c 174 2007-07-25 13:20:29Z poggij $" [static] |
Definition at line 38 of file prism54g.c.
CaptureArg ca [static] |
Definition at line 46 of file prism54g.c.
char errbuf[PCAP_ERRBUF_SIZE] [static] |
Definition at line 47 of file prism54g.c.