#include <include.h>
#include <src/cisco.h>
#include <src/crt_io.h>
#include <src/functions.h>
Go to the source code of this file.
Defines | |
#define | STR_MAX 80 |
Functions | |
int | selectChannelCISCO (char *devname, int channel) |
int | shutCardCISCO (char *devname) |
int | openCardCISCO (char *devname) |
int | getPacketCISCO (p80211_caphdr_t *wlan_header, UINT8 *buf, int maxlen) |
int | openPacketCISCO (char *devname) |
void | closePacketCISCO (void) |
Variables | |
static char * | ID = "$Id: cisco.c 174 2007-07-25 13:20:29Z poggij $" |
ConfigStruct | config |
static CaptureArg | ca |
static char | errbuf [PCAP_ERRBUF_SIZE] |
static char | devname1 [16] |
static char | devname2 [16] |
#define STR_MAX 80 |
int selectChannelCISCO | ( | char * | devname, | |
int | channel | |||
) |
int shutCardCISCO | ( | char * | devname | ) |
Definition at line 56 of file cisco.c.
References CISCO_CVS_CARD, CISCO_PROC_FILE_ERROR, devname1, devname2, IfconfigSetFlags(), IwconfigClearSSID(), ConfigStruct::TypeOfCard, warning(), and warning_if_error().
Referenced by shutCard().
00057 { 00058 #define STR_MAX 80 00059 int result = 0; 00060 FILE *cisco_config; 00061 char cisco_path[128]; 00062 00063 // Clear the SSID 00064 result = IwconfigClearSSID(devname); 00065 00066 // Define the /proc file path 00067 snprintf(cisco_path, 128, "/proc/driver/aironet/%s/Config", devname1); 00068 00069 if ((cisco_config = fopen(cisco_path, "w")) == NULL) { 00070 warning("Unable to open cisco control file '%s' %d:%s",cisco_path, errno, strerror(errno)); 00071 return CISCO_PROC_FILE_ERROR; 00072 } 00073 fprintf(cisco_config, "Mode: i\n"); 00074 fprintf(cisco_config, "XmitPower: 100\n"); 00075 fclose(cisco_config); 00076 00077 result = IfconfigSetFlags(devname, 0); 00078 warning_if_error(result); 00079 00080 if (config.TypeOfCard == CISCO_CVS_CARD) { 00081 result = IfconfigSetFlags(devname2, 0); 00082 warning_if_error(result); 00083 } 00084 00085 return result; 00086 }
int openCardCISCO | ( | char * | devname | ) |
Definition at line 88 of file cisco.c.
References CISCO_CVS_CARD, CISCO_PROC_FILE_ERROR, devname2, IfconfigSetFlags(), IwconfigClearSSID(), ConfigStruct::TypeOfCard, warning(), and warning_if_error().
Referenced by openCard().
00089 { 00090 int result = 0; 00091 FILE *cisco_config; 00092 char cisco_path[128]; 00093 00094 // Clear the SSID 00095 result = IwconfigClearSSID(devname); 00096 00097 // TODO try the iwpriv before write to /proc file 00098 00099 // Define the /proc file path 00100 snprintf(cisco_path, 128, "/proc/driver/aironet/%s/Config", devname); 00101 00102 if ((cisco_config = fopen(cisco_path, "w")) == NULL) { 00103 warning("Unable to open cisco control file '%s' %d:%s",cisco_path, errno, strerror(errno)); 00104 return CISCO_PROC_FILE_ERROR; 00105 } 00106 fprintf(cisco_config, "Mode: r\n"); 00107 fprintf(cisco_config, "Mode: y\n"); 00108 fprintf(cisco_config, "XmitPower: 1\n"); 00109 fclose(cisco_config); 00110 00111 // TODO : Need to put the addr to 0 00112 result = IfconfigSetFlags(devname, IFF_UP + IFF_PROMISC); 00113 warning_if_error(result); 00114 00115 if (config.TypeOfCard == CISCO_CVS_CARD) { 00116 // TODO : Need to put the addr to 0 00117 result = IfconfigSetFlags(devname2, IFF_UP + IFF_PROMISC); 00118 warning_if_error(result); 00119 } 00120 00121 return result; 00122 }
int getPacketCISCO | ( | p80211_caphdr_t * | wlan_header, | |
UINT8 * | buf, | |||
int | maxlen | |||
) |
Definition at line 126 of file cisco.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().
00127 { 00128 struct pcap_pkthdr pktHdr; 00129 u_char *ret; 00130 fd_set rs; 00131 00132 FD_ZERO(&rs); 00133 FD_SET(0, &rs); 00134 00135 ret = (u_char *) pcap_next(ca.pcap, &pktHdr); 00136 // If no problem and packet is enought big (with data) 00137 if ((ret) && (pktHdr.len >= 1)) { 00138 memcpy_buff(buf, ret, pktHdr.len); 00139 // Fill Header 00140 // TODO : find this information in any maner ?! 00141 wlan_header->version = 0; // It's a reduced capture frame format 00142 wlan_header->length = 0; // Not used for now 00143 wlan_header->mactime = 0; 00144 wlan_header->hosttime = 0; 00145 wlan_header->phytype = 0; // Not used for now 00146 wlan_header->channel = 0; 00147 wlan_header->datarate = 0; // datarate is in units of 100kbps. 00148 wlan_header->antenna = 0; // Not used for now 00149 wlan_header->priority = 0; // Not used for now 00150 wlan_header->ssi_type = 0; // Not used for now 00151 wlan_header->ssi_signal = 0; 00152 wlan_header->ssi_noise = 0; 00153 wlan_header->preamble = 0; // Not used for now 00154 wlan_header->encoding = 0; // Not used for now 00155 00156 return pktHdr.len; 00157 } else { 00158 return (0); /* Noting to read */ 00159 } 00160 }
int openPacketCISCO | ( | char * | devname | ) |
Definition at line 162 of file cisco.c.
References debug, devname2, DLT_PRISM_HEADER, errbuf, fatal(), CaptureArg_t::offset, and CaptureArg_t::pcap.
Referenced by openPacket().
00163 { 00164 int DataLink; 00165 00166 ca.pcap = pcap_open_live(devname2, 3000, 1, 0, errbuf); 00167 if (ca.pcap) { 00168 pcap_setnonblock(ca.pcap, 1, errbuf); 00169 DataLink = pcap_datalink(ca.pcap); 00170 switch (DataLink) { 00171 case DLT_PRISM_HEADER: 00172 fatal("pcap_datalink(ca.pcap) = %d = DLT_PRISM_HEADER\n", DataLink); 00173 ca.offset = 144; 00174 break; 00175 case DLT_IEEE802_11: 00176 debug(2, "pcap_datalink(ca.pcap) = %d = DLT_IEEE802_11\n", DataLink); 00177 ca.offset = 0; 00178 break; 00179 case DLT_AIRONET_HEADER: 00180 debug(2, 00181 "pcap_datalink(ca.pcap) = %d = DLT_AIRONET_HEADER:\n", 00182 DataLink); 00183 ca.offset = 0; 00184 break; 00185 default: //COOKED 00186 debug(2, "pcap_datalink(ca.pcap) = %d = COOKED:\n", DataLink); 00187 ca.offset = 160; 00188 } 00189 return 1; 00190 } 00191 return -1; 00192 }
void closePacketCISCO | ( | void | ) |
char* ID = "$Id: cisco.c 174 2007-07-25 13:20:29Z poggij $" [static] |
CaptureArg ca [static] |
char devname1[16] [static] |
char devname2[16] [static] |
Definition at line 48 of file cisco.c.
Referenced by openCardCISCO(), openCardMADWIFI_NG(), openPacketCISCO(), and shutCardCISCO().