functions.h File Reference

#include <wlan/p80211types.h>
#include <wlan/p80211msg.h>
#include <wlan/p80211meta.h>
#include <wlan/p80211metamsg.h>
#include <wlan/p80211metastruct.h>
#include <wlan/p80211mgmt.h>
#include <math.h>

Include dependency graph for functions.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define CHANNEL_MIN   1
#define CHANNEL_MAX   14
#define HOP_MIN   1
#define HOP_MAX   13
#define IFACE_WLAN_MIN   0
#define IFACE_WLAN_MAX   4

Functions

int processPacket (p80211_caphdr_t *wlan_header, UINT8 *packet, int len)
void ParseCommandLine (int argc, char **argv, ConfigStruct *config)
void ChannelToStr (char *strChannel, UINT8 Channel, UINT8 SChannel)
char * safe_strncpy (char *dst, const char *src, int size)
int safe_snprintf (char *s, int size, char *fmt,...)
void * memcpy_buff (void *dest, const void *src, size_t n)
void InitConfiguration (ConfigStruct *config)
int FillRadioData (p80211_caphdr_t *wlan_header, int DataLink, UINT8 *Packet, int len)
int CalculateOffset (int DataLink)
int InterfaceIsExistant (char *devname)
int IfconfigSetFlags (char *devname, short flags)
int IwconfigSetChannel (char *devname, int channel)
int IwconfigSetMode (char *devname, __u32 mode)
int IwconfigClearSSID (char *devname)
int Iwconfig_Set_IntPriv (const char *devname, const char *privcmd, int val1, int val2)


Define Documentation

#define CHANNEL_MIN   1

Definition at line 39 of file functions.h.

Referenced by ParseCommandLine().

#define CHANNEL_MAX   14

Definition at line 40 of file functions.h.

Referenced by parse_keystring(), and ParseCommandLine().

#define HOP_MIN   1

Definition at line 42 of file functions.h.

Referenced by parse_keystring(), and ParseCommandLine().

#define HOP_MAX   13

Definition at line 43 of file functions.h.

Referenced by parse_keystring(), and ParseCommandLine().

#define IFACE_WLAN_MIN   0

Definition at line 45 of file functions.h.

#define IFACE_WLAN_MAX   4

Definition at line 46 of file functions.h.


Function Documentation

int processPacket ( p80211_caphdr_t wlan_header,
UINT8 packet,
int  len 
)

Definition at line 498 of file functions.c.

References p80211_hdr::a3, analyseACK(), analyseBeacon(), analyseCTS(), analyseData(), analyseMGMT(), analyseProbeRep(), analyseProbeReq(), analysePSPOLL(), analyseRTS(), Statistics_t::Beacon, p80211_caphdr::datarate, debug, p80211_hdr_a3::fc, ScanResult_t::Noise, ScanResult_t::Rate, Res, safe_strncpy(), SET_TYPE_BIT_DATA, ScanResult_t::Signal, p80211_caphdr::ssi_noise, p80211_caphdr::ssi_signal, ScanResult_t::TypeOfClient, ScanResult_t::TypeOfPacket, TypeOfPacketToString(), ScanResult_t::TypeSubtype, warning(), WLAN_FSTYPE_ACK, WLAN_FSTYPE_ACTION, WLAN_FSTYPE_ASSOCREQ, WLAN_FSTYPE_ASSOCRESP, WLAN_FSTYPE_ATIM, WLAN_FSTYPE_AUTHEN, WLAN_FSTYPE_BEACON, WLAN_FSTYPE_BLOCK_ACK, WLAN_FSTYPE_BLOCK_ACK_REQ, WLAN_FSTYPE_CFACK, WLAN_FSTYPE_CFACK_CFPOLL, WLAN_FSTYPE_CFEND, WLAN_FSTYPE_CFENDCFACK, WLAN_FSTYPE_CFPOLL, WLAN_FSTYPE_CTS, WLAN_FSTYPE_DATA_CFACK, WLAN_FSTYPE_DATA_CFACK_CFPOLL, WLAN_FSTYPE_DATA_CFPOLL, WLAN_FSTYPE_DATAONLY, WLAN_FSTYPE_DEAUTHEN, WLAN_FSTYPE_DISASSOC, WLAN_FSTYPE_NULL, WLAN_FSTYPE_PROBEREQ, WLAN_FSTYPE_PROBERESP, WLAN_FSTYPE_PSPOLL, WLAN_FSTYPE_QOS_UNMASK, WLAN_FSTYPE_REASSOCREQ, WLAN_FSTYPE_REASSOCRESP, WLAN_FSTYPE_RTS, WLAN_FTYPE_CTL, WLAN_FTYPE_DATA, WLAN_FTYPE_MGMT, WLAN_GET_FC_FSTYPE, WLAN_GET_FC_FTYPE, and WLAN_SIZEOF_TYPEOFPACKET.

Referenced by main().

00499 {
00500   int ReturnCode = 0;
00501   UINT32 CRC;
00502 
00503   p80211_hdr_t *d80211b_Header;
00504 
00505   d80211b_Header = (p80211_hdr_t *) packet;
00506   Res.TypeSubtype = d80211b_Header->a3.fc;
00507 
00508   Res.Signal = wlan_header->ssi_signal;
00509   Res.Noise = wlan_header->ssi_noise;
00510   Res.Rate = wlan_header->datarate;
00511 
00512   switch (WLAN_GET_FC_FTYPE(d80211b_Header->a3.fc)) {
00513     /* Frame subtypes */
00514   case WLAN_FTYPE_MGMT:
00515     debug(1, "Process Management Frame\n");
00516     /* Management */
00517     switch (WLAN_GET_FC_FSTYPE(d80211b_Header->a3.fc)) {
00518     case WLAN_FSTYPE_ASSOCREQ: // To be analyse
00519     case WLAN_FSTYPE_ASSOCRESP:
00520     case WLAN_FSTYPE_REASSOCREQ:
00521     case WLAN_FSTYPE_REASSOCRESP:
00522       ReturnCode = analyseMGMT(packet);
00523       break;
00524     case WLAN_FSTYPE_PROBEREQ:
00525       ReturnCode = analyseProbeReq(packet, len);
00526       break;
00527     case WLAN_FSTYPE_PROBERESP:
00528       ReturnCode = analyseProbeRep(packet, len);
00529       break;
00530     case WLAN_FSTYPE_BEACON:
00531       ReturnCode = analyseBeacon(packet, len);
00532       Stats.Beacon++;
00533       break;
00534     case WLAN_FSTYPE_ATIM:
00535     case WLAN_FSTYPE_DISASSOC:
00536     case WLAN_FSTYPE_AUTHEN:
00537       ReturnCode = analyseMGMT(packet);
00538       break;
00539     case WLAN_FSTYPE_DEAUTHEN:
00540       // TODO : Clear BSSID of the Deauthenticated Client
00541       ReturnCode = analyseMGMT(packet);
00542       break;
00543     case WLAN_FSTYPE_ACTION:
00544       warning("Whaooou a packet what I search ! : MANAGEMENT/ACTION\n");
00545       break;
00546     }
00547     break;
00548   case WLAN_FTYPE_CTL:
00549     debug(1, "Process Control Frame\n");
00550     switch (WLAN_GET_FC_FSTYPE(d80211b_Header->a3.fc)) {
00551       /* Control */
00552     case WLAN_FSTYPE_BLOCK_ACK_REQ:
00553       warning
00554           ("Whaooou a packet what I search ! : CONTROL/BLOCK_ACK_REQ\n");
00555       break;
00556     case WLAN_FSTYPE_BLOCK_ACK:
00557       warning("Whaooou a packet what I search ! : CONTROL/BLOCK_ACK\n");
00558       break;
00559     case WLAN_FSTYPE_PSPOLL:
00560       ReturnCode = analysePSPOLL(packet);
00561       break;
00562     case WLAN_FSTYPE_RTS:
00563       ReturnCode = analyseRTS(packet);
00564       break;
00565     case WLAN_FSTYPE_CTS:
00566       ReturnCode = analyseCTS(packet);
00567       break;
00568     case WLAN_FSTYPE_ACK:
00569       ReturnCode = analyseACK(packet);
00570       break;
00571     case WLAN_FSTYPE_CFEND:
00572       break;
00573     case WLAN_FSTYPE_CFENDCFACK:
00574       break;
00575     }
00576     break;
00577   case WLAN_FTYPE_DATA:
00578     debug(1, "Process Data Frame\n");
00579     //CLEAR_TYPE_BIT_AP (Res.TypeOfClient);
00580     SET_TYPE_BIT_DATA(Res.TypeOfClient);
00581     switch (WLAN_GET_FC_FSTYPE(d80211b_Header->a3.fc) & (WLAN_FSTYPE_QOS_UNMASK)) {
00582       /* Data */
00583     case WLAN_FSTYPE_DATAONLY:
00584     case WLAN_FSTYPE_DATA_CFACK:
00585     case WLAN_FSTYPE_DATA_CFPOLL:
00586     case WLAN_FSTYPE_DATA_CFACK_CFPOLL:
00587     case WLAN_FSTYPE_NULL:
00588       ReturnCode = analyseData(packet, len);
00589       break;
00590     case WLAN_FSTYPE_CFACK:
00591       break;
00592     case WLAN_FSTYPE_CFPOLL:
00593       break;
00594     case WLAN_FSTYPE_CFACK_CFPOLL:
00595       break;
00596     }
00597     break;
00598   }
00599 
00600   memcpy(&CRC, packet + len - 4, 4);
00601 
00602 /*
00603 // Check if the packet is a good packet
00604 #ifndef LWNG_15
00605   if ((CRC == 0xFFFFFFFF)
00606       || ((unsigned) len < sizeof (p80211msg_lnxind_wlansniffrm_t))) {
00607 #else
00608   if ((unsigned) len < sizeof(p80211msg_lnxind_wlansniffrm_t)) {
00609 #endif
00610     if (DebugLevel >= 1) {
00611       debug(0, "INVALID PACKET : BAD CRC (%08X) or too short (%04X)\n",
00612             CRC, len);
00613       if ((unsigned) len > sizeof(p80211msg_lnxind_wlansniffrm_t)) {
00614         CRC =
00615             doFCS(&packet[sizeof(p80211msg_lnxind_wlansniffrm_t)],
00616                   (len - 4 - sizeof(p80211msg_lnxind_wlansniffrm_t)));
00617         debug(1, "Calculed CRC is : %08X\n", CRC);
00618       }
00619     }
00620     safe_strncpy(Res.TypeOfPacket, "INVLID", WLAN_SIZEOF_TYPEOFPACKET);
00621     Stats.INVLD++;
00622     ReturnCode = 0;
00623   } else {
00624 */
00625 
00626   // Copy type of packet (in text)
00627   safe_strncpy(Res.TypeOfPacket,
00628                TypeOfPacketToString(d80211b_Header->a3.fc),
00629                WLAN_SIZEOF_TYPEOFPACKET);
00630   //}
00631 
00632   debug(1, "FrameType=%04X (type:%X subtype:%X)\n",
00633         d80211b_Header->a3.fc,
00634         WLAN_GET_FC_FTYPE(d80211b_Header->a3.fc),
00635         WLAN_GET_FC_FSTYPE(d80211b_Header->a3.fc));
00636 
00637   return ReturnCode;
00638 }

void ParseCommandLine ( int  argc,
char **  argv,
ConfigStruct config 
)

Definition at line 1252 of file functions.c.

References AIRJACK_CARD, ATHEROS_CARD, Bye(), CHANNEL_MAX, CHANNEL_MIN, ConfigStruct::ChannelHop, ConfigStruct::CheckScreenSize, CISCO_CARD, CISCO_CVS_CARD, ConfigStruct::DateFormat, debug, ConfigStruct::DebugLevel, ConfigStruct::devname, ConfigStruct::devname2, DEVNAME_LEN, DISPLAY_ACK_BIT, DISPLAY_BEACON_BIT, DISPLAY_CONTROL_BIT, DISPLAY_DATA_BIT, DISPLAY_PROBE_BIT, DISPLAY_STATION_BIT, ConfigStruct::DoNotDisplay, ERROR_BAD_PARAMETER, ERROR_CHANNEL_OUT_OF_BOUND, ERROR_DONT_TRY_TO_SLEEP_ON_THE_KEYBOARD, ERROR_HOP_OUT_OF_BOUND, ERROR_MISSING_PCAP_FILE, ERROR_UNKNOWN_INTERFACE, ERROR_UNKNOWN_INTERFACE_TYPE, FALSE, HelpAndBye(), HOP_MAX, HOP_MIN, HOSTAP_CARD, ConfigStruct::IDS_is_ON, ConfigStruct::InPcapFileName, InterfaceIsExistant(), IPW_CARD, LUCENT_CARD, MADWIFI_NG_CARD, MAX_DEBUG_LEVEL, ConfigStruct::MaxPacket, NO_ERROR, ConfigStruct::OutDotFileName, ConfigStruct::OutDumpFileName, ConfigStruct::OutFileName, PCAP_VIRTUAL_CARD, PRISM54G_CARD, safe_strncpy(), ConfigStruct::SendAlert2Syslog, SET_BIT, ConfigStruct::SingleChannel, ConfigStruct::TimeToSleepBeforeChangeChannel, TRUE, ConfigStruct::TypeOfCard, and WLAN_NG_CARD.

Referenced by main().

01253 {
01254   int c, n;
01255   char *CommaPosition = NULL;
01256 
01257   int option_index = 0;
01258   static struct option long_options[] = {
01259     {"version", 0, 0, 'v'},
01260     {"help", 0, 0, 'h'},
01261     {"verbose", 1, 0, 'V'},
01262     {"output-file", 1, 0, 'F'},
01263     {"hop", 1, 0, 'H'},
01264     {"channel", 1, 0, 'S'},
01265     {"device-file", 1, 0, 'D'},
01266     {"computer-date", 0, 0, 'd'},
01267     {"iface", 1, 0, 'i'},
01268     {"pcapsrc", 1, 0, 'r'},
01269     {"ids", 0, 0, 'I'},
01270     {"max-packets", 1, 0, 'M'},
01271     {"hide-packets", 1, 0, 'N'},
01272     {"hop-delay", 1, 0, 't'},
01273     {"disable-check", 0, 0, 'c'},
01274     {"card-driver", 0, 0, 'C'},
01275 #ifdef WITH_WIRETAP
01276     {"pcap-file", 1, 0, 'W'},
01277 #endif
01278 #ifdef WITH_SYSLOG
01279     {"send-to-syslog", 0, 0, 's'},
01280 #endif
01281     {0, 0, 0, 0}
01282   };
01283 
01284 
01285   while ((c =
01286           getopt_long(argc, argv,
01287                       "vF:S:W:D:i:r:t:V:h?H:dM:N:IG:w:k:C:cs",
01288                       long_options, &option_index)) != EOF) {
01289 
01290     switch (c) {
01291       // Set channel
01292     case 'S':
01293       config->SingleChannel = atoi(optarg);
01294       if (config->SingleChannel < CHANNEL_MIN ||
01295           config->SingleChannel > CHANNEL_MAX) {
01296         fprintf(stderr,
01297                 "Error : Channel must be between %d and %d\n",
01298                 CHANNEL_MIN, CHANNEL_MAX);
01299         Bye(ERROR_CHANNEL_OUT_OF_BOUND);
01300       }
01301       break;
01302 
01303 #ifdef WITH_SYSLOG
01304       // Send Alert to Syslog
01305     case 's':
01306       config->SendAlert2Syslog = TRUE;
01307       openlog("wifiscanner", LOG_ODELAY || LOG_PID, LOG_USER);
01308       break;
01309 #endif
01310 
01311       // Output file for real time information
01312     case 'F':
01313       if (strncmp("auto", optarg, 5)) {
01314         config->OutFileName = optarg;
01315       } else {
01316 
01317       }
01318       break;
01319 
01320       // PCAP output
01321 #ifdef WITH_WIRETAP
01322     case 'W':                  // PCAP output file
01323       config->OutDumpFileName = optarg;
01324       break;
01325 #endif
01326 
01327       // .DOT output
01328     case 'D':
01329       config->OutDotFileName = optarg;
01330       break;
01331 
01332     case 'r':
01333       config->InPcapFileName = optarg;
01334       break;
01335 
01336       // Version
01337     case 'v':
01338       Bye(NO_ERROR);
01339       break;
01340 
01341       // Number of Hop for channel rotation
01342     case 'H':
01343       config->ChannelHop = atoi(optarg);
01344       if (config->ChannelHop < HOP_MIN || config->ChannelHop > HOP_MAX) {
01345         fprintf(stderr,
01346                 "Error : Hop must be between %d and %d\n",
01347                 HOP_MIN, HOP_MAX);
01348         Bye(ERROR_HOP_OUT_OF_BOUND);
01349       }
01350       break;
01351 
01352       // Verbosity level
01353     case 'V':
01354       config->DebugLevel = atoi(optarg);
01355       if (config->DebugLevel < 1 || config->DebugLevel > MAX_DEBUG_LEVEL)
01356         config->DebugLevel = MAX_DEBUG_LEVEL;
01357       n = 0;                    // Display all packets
01358       break;
01359 
01360       // Time to sleep before change channel
01361     case 't':
01362       config->TimeToSleepBeforeChangeChannel = atoi(optarg);
01363       if (config->TimeToSleepBeforeChangeChannel < 1
01364           || config->TimeToSleepBeforeChangeChannel > 10000)
01365         config->TimeToSleepBeforeChangeChannel = 10000; /* Ten seconds is enougth */
01366       break;
01367 
01368       // Choice of interface
01369     case 'i':
01370       // The interface can be "eth0" or "eth1,wifi0"
01371       // So we search the comma
01372       if (strlen(optarg) > (DEVNAME_LEN * 2 + 1)) {
01373         // Hmmm What did the user want ...
01374         fprintf(stderr,
01375                 "I think that the length of the interface is a little bit too long\n"
01376                 " Wake up ! And don't sleep on your keyboard !   :)\n");
01377         Bye(ERROR_DONT_TRY_TO_SLEEP_ON_THE_KEYBOARD);
01378       }
01379       memset(config->devname, 0, DEVNAME_LEN);
01380       memset(config->devname2, 0, DEVNAME_LEN);
01381       CommaPosition = strchr(optarg, ',');
01382       if (CommaPosition == NULL) {
01383         // Only one interface
01384         safe_strncpy(config->devname, optarg, DEVNAME_LEN);
01385         config->devname[DEVNAME_LEN - 1] = '\0';
01386         debug(3, "Only one interface is given : %s\n", config->devname);
01387       } else {
01388         UINT16 SizeOne, SizeTwo;
01389         SizeOne = CommaPosition - optarg;
01390         SizeTwo = strlen(optarg) - SizeOne;
01391         safe_strncpy(config->devname, optarg, SizeOne + 1);
01392         safe_strncpy(config->devname2, (CommaPosition + 1), SizeTwo);
01393         debug(3, "Two interface is given : (%s)[%d]-(%s)[%d]\n",
01394               config->devname, SizeOne, config->devname2, SizeTwo);
01395       }
01396       if (InterfaceIsExistant(config->devname) == FALSE) {
01397         fprintf(stderr, "Arg, the interface %s is not existant\n",
01398                 config->devname);
01399         Bye(ERROR_UNKNOWN_INTERFACE);
01400       }
01401       break;
01402 
01403       // Human readable date
01404     case 'd':
01405       config->DateFormat = 0;
01406       break;
01407 
01408       // Max packets to capture before leave
01409     case 'M':
01410       // Check if outbound
01411       if (atol(optarg) < 0)
01412         config->MaxPacket = atol(optarg);
01413       break;
01414 
01415       // IDS 
01416     case 'I':
01417       config->IDS_is_ON = TRUE;
01418       //*OutIDSFileName = optarg;
01419       break;
01420 
01421       // Hide some packets (only on display)
01422     case 'N':
01423       n = 0;
01424       fprintf(stdout, "Do not display: ");
01425       // do while until end of option or 16 sub-option ...
01426       while ((optarg[n] != 0) && (n < 16)) {
01427         switch (optarg[n]) {
01428         case 'A':
01429         case 'a':
01430           SET_BIT(config->DoNotDisplay, DISPLAY_ACK_BIT);
01431           fprintf(stdout, "ACK ");
01432           break;
01433         case 'B':
01434         case 'b':
01435           SET_BIT(config->DoNotDisplay, DISPLAY_BEACON_BIT);
01436           fprintf(stdout, "BEACON ");
01437           break;
01438         case 'C':
01439         case 'c':
01440           SET_BIT(config->DoNotDisplay, DISPLAY_CONTROL_BIT);
01441           fprintf(stdout, "CONTROL ");
01442           break;
01443         case 'D':
01444         case 'd':
01445           SET_BIT(config->DoNotDisplay, DISPLAY_DATA_BIT);
01446           fprintf(stdout, "DATA ");
01447           break;
01448         case 'P':
01449         case 'p':
01450           SET_BIT(config->DoNotDisplay, DISPLAY_PROBE_BIT);
01451           fprintf(stdout, "PROBE ");
01452           break;
01453         case 'S':
01454         case 's':
01455           SET_BIT(config->DoNotDisplay, DISPLAY_STATION_BIT);
01456           fprintf(stdout, "STATION ");
01457           break;
01458         default:
01459           break;
01460         }
01461         n++;
01462       }
01463       fprintf(stdout, "\n");
01464       if (config->DebugLevel > 1) {
01465         fprintf(stdout,
01466                 "Verbose level is more than 1 so all packets are display\n");
01467       }
01468       break;
01469 
01470       // G option
01471     case 'G':                  // ???
01472       break;
01473 
01474       // Save weak packets
01475     case 'w':
01476       break;
01477 
01478       // Save KeyStream of Authen with IV
01479     case 'k':
01480       break;
01481 
01482       // Card driver
01483     case 'C':                  // Choice of CARD
01484       if ((!strcmp(optarg, "prism"))
01485           || (!strcmp(optarg, "hostap"))
01486           || (!strcmp(optarg, "cisco"))
01487           || (!strcmp(optarg, "cisco_wifi"))
01488           || (!strcmp(optarg, "orinoco"))
01489           || (!strcmp(optarg, "prism54g"))
01490           || (!strcmp(optarg, "airjack"))
01491           || (!strcmp(optarg, "ipw2100"))
01492           || (!strcmp(optarg, "ipw2200"))
01493           || (!strcmp(optarg, "madwifi-ng"))
01494 /*          || (!strcmp(optarg, "pcap")) */
01495           || (!strcmp(optarg, "atheros"))) {
01496         if (!strcmp(optarg, "cisco_wifi")) {
01497           config->TypeOfCard = CISCO_CVS_CARD;
01498           fprintf(stderr,
01499                   "\n##############\n"
01500                   " WARNING - I'm absolutly not sure that this driver work correctly (ALPHA VERSION)\n"
01501                   "##############\n\n");
01502           sleep(5);
01503         }
01504         if (!strcmp(optarg, "cisco")) {
01505           config->TypeOfCard = CISCO_CARD;
01506         }
01507         if (!strcmp(optarg, "prism")) {
01508           config->TypeOfCard = WLAN_NG_CARD;
01509         }
01510         if (!strcmp(optarg, "prism54g")) {
01511           config->TypeOfCard = PRISM54G_CARD;
01512         }
01513         if (!strcmp(optarg, "hostap")) {
01514           config->TypeOfCard = HOSTAP_CARD;
01515         }
01516         if (!strcmp(optarg, "atheros")) {
01517           config->TypeOfCard = ATHEROS_CARD;
01518         }
01519         if (!strcmp(optarg, "madwifi-ng")) {
01520           config->TypeOfCard = MADWIFI_NG_CARD;
01521         }
01522         if (!strcmp(optarg, "orinoco")) {
01523           config->TypeOfCard = LUCENT_CARD;
01524         }
01525         if (!strcmp(optarg, "ipw2100")) {
01526           config->TypeOfCard = IPW_CARD;
01527         }
01528         if (!strcmp(optarg, "ipw2200")) {
01529           config->TypeOfCard = IPW_CARD;
01530         }
01531         if (!strcmp(optarg, "pcap")) {
01532           // XXX : NOT NOW SUPPORTED 
01533           config->TypeOfCard = PCAP_VIRTUAL_CARD;
01534         }
01535         if (!strcmp(optarg, "airjack")) {
01536           config->TypeOfCard = AIRJACK_CARD;
01537         }
01538       } else {
01539         fprintf(stderr,
01540                 "Only 'prism', 'cisco' 'cisco_wifi (eth+wifi)' 'orinoco' 'atheros', 'prism54g',\n"
01541                 " 'airjack', 'ipw2200', 'ipw2100', 'hostap', 'madwifi-ng' or 'pcap' card is allowed.\n");
01542         Bye(ERROR_UNKNOWN_INTERFACE_TYPE);
01543       }
01544       debug(2, "Driver used is : %s\n", optarg);
01545       break;
01546       // Disable curses checks
01547     case 'c':
01548       config->CheckScreenSize = FALSE;
01549       break;
01550 
01551       // Help 
01552     case '?':                  // Help
01553     case 'h':                  // Help too
01554       HelpAndBye();
01555       break;
01556 
01557       // Default
01558     default:
01559       HelpAndBye();
01560       break;
01561     }
01562   }
01563 
01564   // Post analyse of parameters
01565   if ((config->TypeOfCard == CISCO_CVS_CARD)
01566       && (!strcmp(config->devname2, ""))) {
01567     fprintf(stderr,
01568             "You must give me two interface, when card driver is cisco_wifi"
01569             "like -i eth1,wifi0\n");
01570     Bye(ERROR_BAD_PARAMETER);
01571   }
01572   if ((config->TypeOfCard == PCAP_VIRTUAL_CARD)
01573       && (!strcmp(config->InPcapFileName, ""))) {
01574     fprintf(stderr,
01575             "You must give me a PCAP source file, when card driver is PCAP\n");
01576     Bye(ERROR_MISSING_PCAP_FILE);
01577   }
01578 
01579 }

void ChannelToStr ( char *  strChannel,
UINT8  Channel,
UINT8  SChannel 
)

Channel to string

Definition at line 1647 of file functions.c.

References debug.

Referenced by main().

01648 {
01649   if (Channel == 0) {
01650     sprintf(strChannel, "%02d(%02d)", Channel, SChannel);
01651   } else {
01652     sprintf(strChannel, "%02d(%+02d)", Channel, Channel - SChannel);
01653   }
01654   debug(1, "S-C=%02d-%02d\n", Channel, SChannel);
01655 }

char* safe_strncpy ( char *  dst,
const char *  src,
int  size 
)

Definition at line 89 of file functions.c.

Referenced by analyseACK(), analyseCTS(), analyseData(), analysePSPOLL(), analyseRTS(), LogPutOtherInformation(), LogPutSSID_byAddMac(), LogPutSSID_byBSSID(), ParseCommandLine(), processPacket(), ProcessTagBits(), UpdateOtherInformation(), and WritePanel().

00090 {
00091   dst[size - 1] = '\0';
00092   return strncpy(dst, src, size - 1);
00093 }

int safe_snprintf ( char *  s,
int  size,
char *  fmt,
  ... 
)

Definition at line 95 of file functions.c.

00096 {
00097   va_list ap;
00098   int ret;
00099 
00100   va_start(ap, fmt);
00101   ret = vsnprintf(s, size, fmt, ap);
00102   s[size - 1] = '\0';
00103   va_end(ap);
00104 
00105   return ret;
00106 }

void* memcpy_buff ( void *  dest,
const void *  src,
size_t  n 
)

Definition at line 111 of file functions.c.

References debug, and MAX_BUFFER_SIZE.

Referenced by getPacketAIRJACK(), getPacketATHEROS(), getPacketCISCO(), getPacketHERMES(), getPacketHOSTAP(), getPacketIPW(), getPacketMADWIFI_NG(), getPacketPCAP(), getPacketPRISM54g(), and getPacketWLAN().

00112 {
00113   if (n > MAX_BUFFER_SIZE) {
00114     debug(1, "ERROR : Packet is TOOO BIG size=%d\n", n);
00115     //DumpHexPaquets(RealTime_WND, dest, (MAX_BUFFER_SIZE + 0x10));
00116     return NULL;
00117   } else {
00118     return memcpy(dest, src, n);
00119   }
00120 
00121 }

void InitConfiguration ( ConfigStruct config  ) 

Definition at line 1660 of file functions.c.

References ConfigStruct::ChannelHop, ConfigStruct::CheckScreenSize, ConfigStruct::DateFormat, ConfigStruct::DebugLevel, ConfigStruct::devname, ConfigStruct::DoNotDisplay, FALSE, ConfigStruct::JammingNow, ConfigStruct::SendAlert2Syslog, ConfigStruct::SingleChannel, ConfigStruct::TimeToSleepBeforeChangeChannel, TRUE, ConfigStruct::TypeOfCard, and WLAN_NG_CARD.

Referenced by main().

01661 {
01662   // Configuration declaration
01663   config->SingleChannel = (UINT8) 0;
01664   //config->TimeToSleepBeforeChangeChannel = TIME_TO_SLEEP_BEFORE_CHANGE_CHANNEL;
01665   config->TimeToSleepBeforeChangeChannel = 200; // in ms
01666   config->DebugLevel = (UINT8) 0;
01667   config->ChannelHop = (UINT8) 5;
01668   config->DateFormat = (UINT8) 1;       // 1 is human readable
01669   strcpy(config->devname, "wlan0");
01670   config->TypeOfCard = WLAN_NG_CARD;
01671   config->CheckScreenSize = TRUE;
01672   config->SendAlert2Syslog = FALSE;
01673   config->JammingNow = FALSE;
01674   config->DoNotDisplay = (UINT8) 0;     // 0000 0000
01675   //                                         || |||\_Ack
01676   //                                         || ||\__Beacon
01677   //                                         || |\___Control
01678   //                                         || \____Data
01679   //                                         |\______Probe
01680   //                                         \_______Station
01681 }

int FillRadioData ( p80211_caphdr_t wlan_header,
int  DataLink,
UINT8 Packet,
int  len 
)

Definition at line 1886 of file functions.c.

References p80211_caphdr::antenna, BITNO_32, p80211msg_lnxind_wlansniffrm::channel, p80211_caphdr::channel, cpack_init(), p80211item_uint32::data, p80211_caphdr::datarate, debug, DLT_PRISM_HEADER, DumpHexPaquets(), p80211_caphdr::encoding, EXTRACT_LE_32BITS, extract_radiotap_field(), FALSE, p80211msg_lnxind_wlansniffrm::hosttime, p80211_caphdr::hosttime, IEEE80211_RADIOTAP_EXT, IS_BIT_SET, IS_EXTENDED, ieee80211_radiotap_header::it_len, ieee80211_radiotap_header::it_present, p80211_caphdr::length, p80211msg_lnxind_wlansniffrm::mactime, p80211_caphdr::mactime, NO_ERROR, p80211msg_lnxind_wlansniffrm::noise, p80211_caphdr::phytype, phytype_dsss_dot11_b, p80211_caphdr::preamble, p80211_caphdr::priority, p80211msg_lnxind_wlansniffrm::rate, RealTime_WND, p80211msg_lnxind_wlansniffrm::signal, p80211_caphdr::ssi_noise, p80211_caphdr::ssi_signal, p80211_caphdr::ssi_type, TRUE, p80211_caphdr::version, and warning().

Referenced by getPacketHOSTAP(), getPacketIPW(), getPacketMADWIFI_NG(), and getPacketWLAN().

01902                     {
01903   case DLT_PRISM_HEADER:
01904     Sniff_Frame = (p80211msg_lnxind_wlansniffrm_t *) Packet;
01905     wlan_header->mactime = Sniff_Frame->mactime.data;
01906     wlan_header->hosttime = Sniff_Frame->hosttime.data;
01907     wlan_header->phytype = phytype_dsss_dot11_b;        // Not used for now
01908     wlan_header->channel = Sniff_Frame->channel.data;
01909     wlan_header->datarate = Sniff_Frame->rate.data * 5; // datarate is in units of 100kbps.
01910     wlan_header->ssi_signal = Sniff_Frame->signal.data;
01911     wlan_header->ssi_noise = Sniff_Frame->noise.data;
01912     real_size_of_headers = sizeof(p80211msg_lnxind_wlansniffrm_t);
01913     break;
01914   case DLT_IEEE802_11_RADIO_AVS:
01915     AVS_data = (p80211_caphdr_t *) Packet;
01916     wlan_header->version = AVS_data->version;
01917     wlan_header->length = AVS_data->length;
01918     wlan_header->mactime = AVS_data->mactime;
01919     wlan_header->hosttime = AVS_data->hosttime;
01920     wlan_header->phytype = AVS_data->phytype;
01921     wlan_header->channel = AVS_data->channel;
01922     wlan_header->datarate = AVS_data->datarate;
01923     wlan_header->antenna = AVS_data->antenna;
01924     wlan_header->priority = AVS_data->priority;
01925     wlan_header->ssi_type = AVS_data->ssi_type;
01926     wlan_header->ssi_signal = AVS_data->ssi_signal;
01927     wlan_header->ssi_noise = AVS_data->ssi_noise;
01928     wlan_header->preamble = AVS_data->preamble;
01929     wlan_header->encoding = AVS_data->encoding;
01930     real_size_of_headers = sizeof(p80211_caphdr_t);
01931     break;
01932   case DLT_IEEE802_11_RADIO:
01933     {
01934 #define BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x)))
01935 #define BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x)))
01936 #define BITNO_8(x) (((x) >> 4) ? 4 + BITNO_4((x) >> 4) : BITNO_4((x)))
01937 #define BITNO_4(x) (((x) >> 2) ? 2 + BITNO_2((x) >> 2) : BITNO_2((x)))
01938 #define BITNO_2(x) (((x) & 2) ? 1 : 0)
01939 #define BIT(n)  (1 << n)
01940 #define IS_EXTENDED(__p)        \
01941                   (EXTRACT_LE_32BITS(__p) & BIT(IEEE80211_RADIOTAP_EXT)) != 0
01942       int bit0;
01943       enum ieee80211_radiotap_type bit;
01944       struct cpack_state cpacker;
01945       u_int32_t present, next_present;
01946       u_int32_t *presentp, *last_presentp;
01947       UINT8 exit_loop = FALSE;
01948       const u_char *iter;
01949 
01950       // Exemple : 0000 1000 2E08 0000 0002 9409 A000 C802
01951       radiotap_hdr = (struct ieee80211_radiotap_header *) Packet;
01952       //data_pt = Packet + sizeof(struct ieee80211_radiotap_header);
01953 
01954       real_size_of_headers = radiotap_hdr->it_len;
01955 
01956       debug(3, "radiotap_hdr->it_len = %02X\n", radiotap_hdr->it_len);
01957 
01958 #if 0
01959       DumpHexPaquets(RealTime_WND, Packet, radiotap_hdr->it_len);
01960       DumpHexPaquets(RealTime_WND, Packet + radiotap_hdr->it_len, len);
01961 #endif
01962 
01963       for (last_presentp = &radiotap_hdr->it_present;
01964            IS_EXTENDED(last_presentp)
01965            && (u_char *) (last_presentp + 1) <= Packet + len; last_presentp++);
01966       {
01967       }
01968 
01969       iter = (u_char *) (last_presentp + 1);
01970 
01971       if (cpack_init(&cpacker, (u_int8_t *) iter, len - (iter - Packet)) == 0) {
01972 
01973         if (IS_BIT_SET(radiotap_hdr->it_present, IEEE80211_RADIOTAP_EXT)) {
01974           warning
01975               ("Radiotap use an extended data, please send mail to the developper to notify this problem\n");
01976         } else {
01977           for (bit0 = 0, presentp = &radiotap_hdr->it_present;
01978                presentp <= last_presentp; presentp++, bit0 += 32) {
01979             for (present = EXTRACT_LE_32BITS(presentp); present;
01980                  present = next_present) {
01981               /* clear the least significant bit that is set */
01982               next_present = present & (present - 1);
01983               /* extract the least significant bit that is set */
01984               bit = (enum ieee80211_radiotap_type) (bit0 + BITNO_32(present ^ next_present)); 
01985 
01986               if (extract_radiotap_field(&cpacker, bit, wlan_header) != NO_ERROR) {
01987                 exit_loop = TRUE;
01988                 break;
01989               }
01990             }
01991             if (exit_loop == TRUE)
01992               break;
01993           }
01994         }
01995       }
01996 #undef BITNO_32
01997 #undef BITNO_16
01998 #undef BITNO_8
01999 #undef BITNO_4
02000 #undef BITNO_2
02001 #undef BIT
02002 #undef IS_EXTENDED
02003     }
02004     break;
02005   default:
02006     break;
02007   }
02008   return real_size_of_headers;
02009 }
02010 
02011 int CalculateOffset(int DataLink)
02012 {
02013   int offset = 0;
02014 
02015   switch (DataLink) {
02016   case DLT_PRISM_HEADER:
02017     debug(2, "pcap_datalink(ca.pcap) = %d = DLT_PRISM_HEADER\n", DataLink);
02018     offset = 0x90;

int CalculateOffset ( int  DataLink  ) 

Definition at line 2020 of file functions.c.

Referenced by openPacketATHEROS(), openPacketHERMES(), openPacketHOSTAP(), openPacketIPW(), openPacketMADWIFI_NG(), openPacketPCAP(), openPacketPRISM54g(), and openPacketWLAN().

02020                      :
02021     debug(2, "pcap_datalink(ca.pcap) = %d = DLT_IEEE802_11\n", DataLink);
02022     offset = 0x00;
02023     break;
02024   case DLT_AIRONET_HEADER:
02025     debug(2, "pcap_datalink(ca.pcap) = %d = DLT_AIRONET_HEADER:\n",
02026           DataLink);
02027     offset = 0x00;
02028     break;
02029   case DLT_LINUX_SLL:          //113
02030     debug(2, "pcap_datalink(ca.pcap) = %d = DLT_LINUX_SLL\n", DataLink);
02031     offset = 0x10;
02032     break;
02033   case DLT_IEEE802_11_RADIO:   //127
02034     debug(2, "pcap_datalink(ca.pcap) = %d = DLT_IEEE802_11_RADIO\n",
02035           DataLink);
02036     offset = 0x10;
02037     // ofset is calculate directly by the extract function
02038     break;
02039   case DLT_IEEE802_11_RADIO_AVS:       //163
02040     debug(2, "pcap_datalink(ca.pcap) = %d = DLT_IEEE802_11_RADIO_AVS\n",
02041           DataLink);
02042     offset = 0x40;
02043     break;
02044   default:                     //COOKED
02045     debug(2, "pcap_datalink(ca.pcap) = %d = Default to COOKED\n",
02046           DataLink);
02047     offset = 0x10;
02048   }
02049   return offset;
02050 }
}

int InterfaceIsExistant ( char *  devname  ) 

Definition at line 133 of file functions.c.

References FALSE, IfconfigSetFlags(), NO_ERROR, and TRUE.

Referenced by DispConf(), and ParseCommandLine().

00134 {
00135   if (IfconfigSetFlags(devname, 0) == NO_ERROR)
00136     return TRUE;                // Existant
00137   else
00138     return FALSE;               // Not Existant
00139 }

int IfconfigSetFlags ( char *  devname,
short  flags 
)

Definition at line 145 of file functions.c.

References debug, ERROR_CANT_CREATE_SOCKET, ERROR_UNKNOWN_INTERFACE, and NO_ERROR.

Referenced by InterfaceIsExistant(), openCardAIRJACK(), openCardATHEROS(), openCardCISCO(), openCardHERMES(), openCardHOSTAP(), openCardIPW(), openCardMADWIFI_NG(), openCardPRISM54g(), openCardWLAN(), shutCardAIRJACK(), shutCardATHEROS(), shutCardCISCO(), shutCardHERMES(), shutCardHOSTAP(), shutCardIPW(), shutCardPRISM54g(), and shutCardWLAN().

00146 {
00147   struct ifreq ifr;
00148   int skfd;
00149 
00150   if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
00151     debug(3, "SetIFFlags: Failed to create AF_INET "
00152           "DGRAM socket. %d:%s", errno, strerror(errno));
00153     return ERROR_CANT_CREATE_SOCKET;
00154   }
00155   // Fetch interface flags
00156   memset(&ifr, 0, sizeof ifr);
00157   strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name) - 1);
00158   ifr.ifr_flags = flags;
00159 
00160   // do the IOCTL call
00161   if (ioctl(skfd, SIOCSIFFLAGS, &ifr) < 0) {
00162     debug(3, "SetIFFlags: Unknown interface %s: %s", devname,
00163           strerror(errno));
00164     close(skfd);
00165     return ERROR_UNKNOWN_INTERFACE;
00166   }
00167   close(skfd);
00168   return NO_ERROR;
00169 }

int IwconfigSetChannel ( char *  devname,
int  channel 
)

Definition at line 196 of file functions.c.

References debug, ERROR_CANT_CREATE_SOCKET, ERROR_CANT_SET_CHANNEL, IwFloat2Freq(), NO_ERROR, and warning().

Referenced by openCardHOSTAP(), selectChannelATHEROS(), selectChannelHOSTAP(), selectChannelMADWIFI_NG(), selectChannelPRISM54g(), and shutCardHOSTAP().

00197 {
00198   struct iwreq wrq;
00199   int skfd;
00200 
00201   if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
00202     warning("Failed to create AF_INET DGRAM socket %d:%s", errno,
00203             strerror(errno));
00204     return ERROR_CANT_CREATE_SOCKET;
00205   }
00206   // Set a channel
00207   memset(&wrq, 0, sizeof(struct iwreq));
00208 
00209   strncpy(wrq.ifr_name, devname, IFNAMSIZ);
00210   wrq.u.freq.flags = IW_FREQ_FIXED;
00211   IwFloat2Freq(channel, &wrq.u.freq);
00212 
00213   // Try twice with a tiny delay, some cards (madwifi) need a second chance...
00214   if (ioctl(skfd, SIOCSIWFREQ, &wrq) < 0) {
00215     usleep(5000);
00216     if (ioctl(skfd, SIOCSIWFREQ, &wrq) < 0) {
00217       debug(3, "Failed to set channel %d %d:%s\n", channel,
00218             errno, strerror(errno));
00219       close(skfd);
00220       return ERROR_CANT_SET_CHANNEL;
00221     }
00222   }
00223 
00224   close(skfd);
00225   return NO_ERROR;
00226 }

int IwconfigSetMode ( char *  devname,
__u32  mode 
)

Definition at line 231 of file functions.c.

References ERROR_CANT_CREATE_SOCKET, ERROR_CANT_SET_MODE, NO_ERROR, and warning().

Referenced by openCardATHEROS(), openCardHOSTAP(), openCardIPW(), openCardPRISM54g(), shutCardATHEROS(), shutCardHERMES(), shutCardHOSTAP(), shutCardIPW(), and shutCardPRISM54g().

00232 {
00233   // cf wireless.h
00234   struct iwreq wrq;
00235   int skfd;
00236 
00237   if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
00238     warning("Failed to create AF_INET DGRAM socket %d:%s\n", errno,
00239             strerror(errno));
00240     return ERROR_CANT_CREATE_SOCKET;
00241   }
00242 
00243   memset(&wrq, 0, sizeof(struct iwreq));
00244   strncpy(wrq.ifr_name, devname, IFNAMSIZ);
00245   wrq.u.mode = mode;
00246 
00247   if (ioctl(skfd, SIOCSIWMODE, &wrq) < 0) {
00248     warning("mode set ioctl failed %d:%s\n", errno, strerror(errno));
00249     close(skfd);
00250     return ERROR_CANT_SET_MODE;
00251   }
00252 
00253   close(skfd);
00254   return NO_ERROR;
00255 }

int IwconfigClearSSID ( char *  devname  ) 

Definition at line 260 of file functions.c.

References ERROR_CANT_CREATE_SOCKET, ERROR_CANT_SET_SSID, and warning().

Referenced by openCardCISCO(), openCardHERMES(), and shutCardCISCO().

00261 {
00262   struct iwreq wrq;
00263   int skfd;
00264   char essid[1];
00265 
00266   essid[0] = '\0';
00267 
00268   if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
00269     warning("Failed to create AF_INET DGRAM socket %d:%s", errno,
00270             strerror(errno));
00271     return ERROR_CANT_CREATE_SOCKET;
00272   }
00273   // Zero the ssid
00274   strncpy(wrq.ifr_name, devname, IFNAMSIZ);
00275   wrq.u.essid.pointer = (caddr_t) essid;
00276   wrq.u.essid.length = 1;
00277   wrq.u.essid.flags = 1;
00278 
00279   if (ioctl(skfd, SIOCSIWESSID, &wrq) < 0) {
00280     warning("Failed to set SSID %d:%s", errno, strerror(errno));
00281     close(skfd);
00282     return ERROR_CANT_SET_SSID;
00283   }
00284 
00285   close(skfd);
00286   return 0;
00287 
00288 }

int Iwconfig_Set_IntPriv ( const char *  devname,
const char *  privcmd,
int  val1,
int  val2 
)

Definition at line 294 of file functions.c.

References ERROR_CANT_CREATE_SOCKET, IWPRIV_DOES_NOT_ACCEPT_INTEGER, IWPRIV_FAILED_TO_FIND_IOCTL, IWPRIV_FAILED_TO_FIND_SUBIOCTL, IWPRIV_FAILED_TO_RETREIVE_IOCTL_LIST, IWPRIV_FAILED_TO_SET_IOCTL, IWPRIV_FAILED_TO_SET_VALUE, IWPRIV_NEED_MORE_THAN_2_ARG, and NO_ERROR.

Referenced by selectChannelHERMES().

00296 {
00297   struct iwreq wrq;
00298   int skfd;
00299   struct iw_priv_args priv[IW_MAX_PRIV_DEF];
00300   u_char buffer[4096];
00301   int subcmd = 0;
00302   int offset = 0;
00303 
00304   memset(priv, 0, sizeof(priv));
00305 
00306   if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
00307     return ERROR_CANT_CREATE_SOCKET;
00308   }
00309 
00310   memset(&wrq, 0, sizeof(struct iwreq));
00311   strncpy(wrq.ifr_name, devname, IFNAMSIZ);
00312 
00313   wrq.u.data.pointer = (caddr_t) priv;
00314   wrq.u.data.length = IW_MAX_PRIV_DEF;
00315   wrq.u.data.flags = 0;
00316 
00317   if (ioctl(skfd, SIOCGIWPRIV, &wrq) < 0) {
00318     close(skfd);
00319     return IWPRIV_FAILED_TO_RETREIVE_IOCTL_LIST;
00320   }
00321 
00322   int pn = -1;
00323   while ((++pn < wrq.u.data.length) && strcmp(priv[pn].name, privcmd));
00324 
00325   if (pn == wrq.u.data.length) {
00326     close(skfd);
00327     return IWPRIV_FAILED_TO_FIND_IOCTL;
00328   }
00329   // Find subcmds, as if this isn't ugly enough already
00330   if (priv[pn].cmd < SIOCDEVPRIVATE) {
00331     int j = -1;
00332 
00333     while ((++j < wrq.u.data.length) &&
00334            ((priv[j].name[0] != '\0') ||
00335             (priv[j].set_args != priv[pn].set_args) ||
00336             (priv[j].get_args != priv[pn].get_args)
00337            ));
00338 
00339     if (j == wrq.u.data.length) {
00340       close(skfd);
00341       return IWPRIV_FAILED_TO_FIND_SUBIOCTL;
00342     }
00343 
00344     subcmd = priv[pn].cmd;
00345     offset = sizeof(__u32);
00346     pn = j;
00347   }
00348   // Make sure its an iwpriv we can set
00349   if ((priv[pn].set_args & IW_PRIV_TYPE_MASK) == 0 ||
00350       (priv[pn].set_args & IW_PRIV_SIZE_MASK) == 0) {
00351     close(skfd);
00352     return IWPRIV_FAILED_TO_SET_VALUE;
00353   }
00354 
00355   if ((priv[pn].set_args & IW_PRIV_TYPE_MASK) != IW_PRIV_TYPE_INT) {
00356     close(skfd);
00357     return IWPRIV_DOES_NOT_ACCEPT_INTEGER;
00358   }
00359   // Find out how many arguments it takes and die if we can't handle it
00360   int nargs = (priv[pn].set_args & IW_PRIV_SIZE_MASK);
00361   if (nargs > 2) {
00362     close(skfd);
00363     return IWPRIV_NEED_MORE_THAN_2_ARG;
00364   }
00365   // Build the set request
00366   memset(&wrq, 0, sizeof(struct iwreq));
00367   strncpy(wrq.ifr_name, devname, IFNAMSIZ);
00368 
00369   // Assign the arguments
00370   wrq.u.data.length = nargs;
00371   ((__s32 *) buffer)[0] = (__s32) val1;
00372   if (nargs > 1) {
00373     ((__s32 *) buffer)[1] = (__s32) val2;
00374   }
00375   // This is terrible!
00376   // This is also simplified from what iwpriv.c does, because we don't
00377   // need to worry about get-no-set ioctls
00378   if ((priv[pn].set_args & IW_PRIV_SIZE_FIXED) &&
00379       ((sizeof(__u32) * nargs) + offset <= IFNAMSIZ)) {
00380     if (offset)
00381       wrq.u.mode = subcmd;
00382     memcpy(wrq.u.name + offset, buffer, IFNAMSIZ - offset);
00383   } else {
00384     wrq.u.data.pointer = (caddr_t) buffer;
00385     wrq.u.data.flags = 0;
00386   }
00387 
00388   // Actually do it.
00389   if (ioctl(skfd, priv[pn].cmd, &wrq) < 0) {
00390     close(skfd);
00391     return IWPRIV_FAILED_TO_SET_IOCTL;
00392   }
00393 
00394   close(skfd);
00395   return NO_ERROR;
00396 }


Generated on Fri Jul 25 17:10:58 2008 for WifiScanner by  doxygen 1.5.5