From d11a0154e2d9732854c9a3d598857bc20f359849 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sun, 30 Mar 2003 01:51:14 +0000 Subject: - the network work for libopie2 pays off... - good bye to wellenreiterd, t'was fun but always too unstable and too hard to maintain - good bye to libwellenreiter --- (limited to 'noncore/net/wellenreiter/libwellenreiter') diff --git a/noncore/net/wellenreiter/libwellenreiter/.cvsignore b/noncore/net/wellenreiter/libwellenreiter/.cvsignore deleted file mode 100644 index 4299fd9..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/.cvsignore +++ b/dev/null @@ -1,4 +0,0 @@ -*.o -*~ -moc_* -Makefile* diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/quickintro b/noncore/net/wellenreiter/libwellenreiter/docs/quickintro deleted file mode 100644 index 97458b7..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/quickintro +++ b/dev/null @@ -1,88 +0,0 @@ - -Name: libwellenreiter -Author: Martin J. Muench - -NOTE: This is just a very short summary of the functions included -in libwellenreiter, written because a lack of time. The whole -library will be rewritten with extended documentation and -test programs. - --- -Wellenreiter types: -In proto.hh the following type (wl_network_t) is declared: - -typedef struct { - int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ - int ssid_len; /* Length of SSID */ - int channel; /* Channel */ - int wep; /* 1 = WEP enabled ; 0 = disabled */ - char mac[64]; /* MAC address of Accesspoint */ - char bssid[128]; /* BSSID of Accesspoint */ -} wl_network_t; - -When a network is found, the structure has to be set and -sent to the send_network_found() function. - -When the GUI receives a found network string it calls the -get_network_found() function to get its own structure set. - --- -Included functions: - --- -Protocol: - -Send a found network to GUI: -int send_network_found (const char *, int, void *); - -The first two arguments are the guihost and the guiport. -The third is the filled structure (wl_network_t), that will -be send to the GUI. - -Setup structure for found network: -int get_network_found (void *, const char *); - -When the GUI receives a new network found packet it calls -this function and passes a wl_network_t structure and the -received buffer. The function will strip the data from -the buffer and set it to the structure. - --- -Log to syslog/info: -void wl_loginfo(const char *, ...); - -Log to syslog/err: -void wl_logerr(const char *, ...); - -Use like printf() function with format strings and so on. - --- -Setup udp socket for incoming commands: -int commsock(const char *, int); - -Fist argument is the host where it should listen and second -is the port. Socket is returned, on failure -1 is returned. - - -Recvfrom socket: -int recv_commsock(int *, char *, int); - -First argument is the address of the socket, second is a buffer -that should be filled in and the third is the maxlength of the -buffer. On error, -1 is returned, on success the number of -packet type is returned. (return value should be used with switch -command, for types see proto.hh) - -Send command to udp socket: -int sendcomm(const char *, int, const char *, ...); - -First two arguments are the host and port where the command should -be send to, followed by buffer that should be send. On error, -1 -is returned. - - ---- - -Thats it for the moment. - -mjm. diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_conf.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_conf.8 deleted file mode 100644 index 8d2fe27..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_conf.8 +++ b/dev/null @@ -1,17 +0,0 @@ -wl_conf - -#include - -int wl_checkcfg(void); -int wl_cfgvalue(const char *token, char *out, int maxlen); - -wl_checkcfg checks whether the wellenreiter configfile exists. -wl_cfgvalue searches for the given token and copies maxlen -characters of its value to out. - -wl_ckeckcfg returns 1 if the file exists and is readable and -0 on error. - -wl_cfgvalue returns -1 on error, 0 if nothing was found and -1 on success. - diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_log.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_log.8 deleted file mode 100644 index 00262bd..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_log.8 +++ b/dev/null @@ -1,12 +0,0 @@ -wl_log - -#include - -void wl_loginfo(const char *string, ...) -void wl_logerr(const char *string, ...) - -wl_loginfo() and wl_err() write string to syslog(), -either to INFO or to ERR. - -no return values - diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sniff.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_sniff.8 deleted file mode 100644 index 9a65223..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sniff.8 +++ b/dev/null @@ -1,21 +0,0 @@ -sniff.cc - -#include - -void process_packets(const struct pcap_pkthdr *pkthdr, - const unsigned char *packet, - char *guihost, - int guiport) - -The function process_packets() will use libpcap to get the -informations for a 802.11b packet. When it finds a valid -network it calls the wl_send function and sends a found -network packet to the guiport on the guihost. - - -Return value - -none - -NOTE: process_packets() is void at the moment because there -will be alot of non-critical and annoying errors. diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sock.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_sock.8 deleted file mode 100644 index 62e935b..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sock.8 +++ b/dev/null @@ -1,26 +0,0 @@ -wl_sock - -#include - -int wl_setupsock(const char *host, int port, struct sockaddr_in *) -int wl_send(const char *host, int port, const char *string, ...) -int wl_recv(int *socket, struct sockaddr_in *, char *out, int len) - - -wl_setupsock() returns the number of the activated udp socket. - -wl_send() sends string to the given host. - -wl_recv() checks for incoming data on a socket (created using -wl_setupsock()). It writes the incoming data to out with a -maxlen of len. - - -wl_setupsock() returns -1 on error and the number of socket on -success. -wl_send() returns 0 on error and 1 on success. -wl_recv() returns -1 on error and the type of the received packet -on success. - -Note: To use this function you have to set a sockaddr_in structure -and pass it to wl_setupsock and wl_receive. diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_types.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_types.8 deleted file mode 100644 index d12f564..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_types.8 +++ b/dev/null @@ -1,25 +0,0 @@ -wl_types.hh - -wl_types.hh contains the global buffers and type definitions. - -At the moment these are: - -/* Type definitions, to be continued */ -#define WL_NETFOUND 01 -#define WL_NETLOST 02 -#define WL_STARTSNIFF 98 -#define WL_STOPSNIFF 99 - -#define WL_SOCKBUF 512 /* Buffer for wl_send and wl_recv calls */ - -/* WL network structure */ -typedef struct { - int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ - int ssid_len; /* Length of SSID */ - int channel; /* Channel */ - int wep; /* 1 = WEP enabled ; 0 = disabled */ - char mac[64]; /* MAC address of Accesspoint */ - char bssid[128]; /* BSSID of Net */ -} wl_network_t; - -Will be filled up with other structs and size definitions asap. diff --git a/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro b/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro deleted file mode 100644 index 5930c60..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro +++ b/dev/null @@ -1,16 +0,0 @@ -DESTDIR = $(OPIEDIR)/lib -TEMPLATE = lib -CONFIG = warn_on debug -VERSION = 0.2 -HEADERS = source/cardmode.hh source/wl_log.hh source/wl_proto.hh source/sniff.hh source/wl_sock.hh source/wl_types.hh -SOURCES = source/cardmode.cc source/wl_log.cc source/wl_proto.cc source/sniff.cc source/wl_sock.cc - -LIBS = -lpcap -TMAKE_CFLAGS += -D__UNIX__ -DEFINES += DEBUG -TARGET = wellenreiter - -!contains( platform, x11 ) { - include ( $(OPIEDIR)/include.pro ) -} - diff --git a/noncore/net/wellenreiter/libwellenreiter/source/.cvsignore b/noncore/net/wellenreiter/libwellenreiter/source/.cvsignore deleted file mode 100644 index ed65c71..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/.cvsignore +++ b/dev/null @@ -1,3 +0,0 @@ -*.o -*~ -moc_* diff --git a/noncore/net/wellenreiter/libwellenreiter/source/Makefile b/noncore/net/wellenreiter/libwellenreiter/source/Makefile deleted file mode 100644 index 0017f05..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/Makefile +++ b/dev/null @@ -1,20 +0,0 @@ -# $Id$ - -OBJ = wl_proto.o wl_sock.o wl_log.o wl_conf.o cardmode.o sniff.o -CPP = g++ -CPPFLAGS = -Wall -pedantic -g -DDEBUG - -%.o : %.cc - $(CPP) $(CPPFLAGS) -c $< -o $@ - -static: libwellenreiter.a -libwellenreiter.a: $(OBJ) - ar -cr libwellenreiter.a $(OBJ) - -shared: libwellenreiter.so -libwellenreiter.so: $(OBJ) - $(CPP) $(CPPFLAGS) -shared -o libwellenreiter.so $(OBJ) - -clean: - rm -f *.o *.a *.so *~ - diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc deleted file mode 100644 index 4f187c0..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc +++ b/dev/null @@ -1,451 +0,0 @@ -/* - * Set card modes for sniffing - * - * $Id$ - */ - -#include "cardmode.hh" -#include "wl_log.hh" -pcap_t *handletopcap; -/* main card into monitor function */ -int card_into_monitormode (const char *device, int cardtype) -{ - char CiscoRFMON[35] = "/proc/driver/aironet/"; - FILE *CISCO_CONFIG_FILE; - - /* Checks if we have a device to sniff on */ - if(device == NULL) - { - wl_logerr("No device given"); - return 0; - } - - /* Setting the promiscous and up flag to the interface */ - if (!card_set_promisc_up(device)) - { - wl_logerr("Cannot set interface to promisc mode"); - return 0; - } - wl_loginfo("Interface set to promisc mode"); - - /* Check the cardtype and executes the commands to go into monitor mode */ - if (cardtype == CARD_TYPE_CISCO) - { - /* bring the sniffer into rfmon mode */ - snprintf(CiscoRFMON, sizeof(CiscoRFMON) - 1, DEFAULT_PATH, device); - if((CISCO_CONFIG_FILE = fopen(CiscoRFMON,"w")) == NULL) - { - wl_logerr("Cannot open config file: %s", strerror(errno)); - return 0; - } - fputs ("Mode: r",CISCO_CONFIG_FILE); - fputs ("Mode: y",CISCO_CONFIG_FILE); - fputs ("XmitPower: 1",CISCO_CONFIG_FILE); - fclose(CISCO_CONFIG_FILE); - } - else if (cardtype == CARD_TYPE_NG) - { - char wlanngcmd[80]; - snprintf(wlanngcmd, sizeof(wlanngcmd) - 1, "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=true", device, 1); - if (system(wlanngcmd) != 0) - { - wl_logerr("Could not set %s in raw mode, check cardtype", device); - return 0; - } - } - else if (cardtype == CARD_TYPE_HOSTAP) - { -#if WIRELESS_EXT > 14 - // IW_MODE_MONITOR was implemented in Wireless Extensions Version 15 - int skfd; - skfd = socket(AF_INET, SOCK_STREAM, 0); - struct iwreq wrq; - wrq.u.mode = IW_MODE_MONITOR; - - if(iw_set_ext(skfd,(char *) device,SIOCSIWMODE,&wrq)<0) - { - wl_logerr("Could not set hostap card %s to raw mode, check cardtype", device); - return 0; - } - else - { - wl_loginfo("Successfully set hostap card %s into raw mode",device); - return 1; - } - return 1; -#else - // Wireless Extensions < Version 15 need iwpriv commandos for monitoring - int fd; - //Wireless tools structure for the iocalls - struct iwreq ireq; - int *ptr; - /* Socket needed to use the iocall to */ - fd = socket(AF_INET, SOCK_STREAM, 0); - - if ( fd == -1 ) { - return -1; - } - - ptr = (int *) ireq.u.name; - // This is the monitor mode for 802.11 non-prism header - ptr[0] = 2; - strcpy(ireq.ifr_ifrn.ifrn_name, device); - if (ioctl( fd, SIOCDEVPRIVATE, &ireq)==0) - { - /* All was fine... */ - close(fd); - wl_loginfo("Set hostap card %s into monitormode",device); - return 1; - } - else - { - /* iocall does not work */ - close(fd); - wl_logerr("Could not set hostap card %s into monitormode, check cardtype",device); - return 0; - } -#endif - } - else if (cardtype == CARD_TYPE_ORINOCCO ) - { - if (!card_set_channel (device, 1, CARD_TYPE_ORINOCCO)) - { - wl_logerr("Could not set %s in raw mode, check cardtype", device); - return 0; - } - else - { - wl_loginfo("Successfully set %s into raw mode",device); - } - } - - /* Setting the promiscous and up flag to the interface */ - if (!card_check_rfmon_datalink(device)) - { - wl_logerr("Cannot set interface to rfmon mode"); - return 0; - } - else - { - wl_loginfo("Interface set to rfmon mode"); - } - return 1; -} - -/* Check card is in the rfmon mode */ -int card_check_rfmon_datalink (const char *device) -{ - int datalinktype=0; - pcap_t *phandle; - phandle = pcap_open_live((char *)device, 65,0,0,NULL); - datalinktype = pcap_datalink (phandle); - pcap_close(phandle); - - if (datalinktype != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */ - { - return 0; - } - else - { - wl_loginfo("Your successfully listen on %s in 802.11 raw mode", device); - return 1; - } -} - -/* Ipaq running familiar does not have a loopback device, we need one */ -int check_loopback() -{ - /* Checking for a loopback interface with 127.0.0.1, otherwise the other stuff seems to fail on - familiar linux on ipaq's */ - int err; - /* First generate a socket to use with iocalls */ - int fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) - { - /* In case of an error */ - wl_logerr("check_loopback, generation of a socket failed, cannot continue"); - return 0; - } - /* Fill an empty an interface structure with the right flags (UP and Promsic) */ - struct ifreq ifr; - strncpy(ifr.ifr_name, "lo",3); - - /* Get the interface flags, loopback interfaces can be detected that way */ - err = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (err < 0) - { - wl_logerr("check_loopback, could not get the flags of lo, check if you got a lo loopback interface, cannot continue"); - close(fd); - return 0; - } - /* Checking the flags for IFF_LOOPBACK flags */ - if(ifr.ifr_flags && IFF_LOOPBACK) - { - /* Yes, we do have a loopback interface....sup! */ - close(fd); - wl_loginfo ("check_loopback, check for loopback interface lo successful"); - return 1; - } - else - { - wl_logerr("check_loopback, did not found an interface lo with the IFF_LOOPBACK flag set, cannot continue"); - close(fd); - return 0; - } - /* Should never be reached */ - return 0; -} /*check_loopback */ - - -/* Set card into promisc mode */ -int card_set_promisc_up (const char *device) -{ - int err; - /* First generate a socket to use with iocalls */ - int fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) - { - /* In case of an error */ - perror("socket"); - return 0; - } - - /* Fill an empty an interface structure with the right flags (UP and Promsic) */ - struct ifreq ifr; - strncpy(ifr.ifr_name, device,10); - ifr.ifr_flags = IFF_UP + IFF_PROMISC; - err = ioctl(fd, SIOCSIFFLAGS, &ifr); - if (err < 0) - { - perror("Could not access the interface, "); - close(fd); - return 0; - } - - /* Get the informations back from the interface to check if the flags are correct */ - strncpy(ifr.ifr_name, device,10); - err = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (err < 0) - { - perror("Could not access the interface, "); - close(fd); - return 0; - } - - if(ifr.ifr_flags && IFF_UP) - { - close(fd); - return 1; - } - else - { - wl_logerr("Could not set promisc flag on %d", device); - close(fd); - return 0; - } -} - -/* Remove card from promisc mode */ -int card_remove_promisc (const char *device) -{ - int err; - /* First generate a socket to use with iocalls */ - int fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) - { - /* In case of an error */ - perror("socket"); - return 0; - } - - /* Fill an empty an interface structure with the right flags (UP and Promsic) */ - struct ifreq ifr; - /* Get the flags from the interface*/ - strncpy(ifr.ifr_name, device,10); - err = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (err < 0) - { - perror("Could not access the interface, "); - close(fd); - return 0; - } - /* Remove the IFF_PROMISC flag */ - ifr.ifr_flags = ifr.ifr_flags - IFF_PROMISC; - /*Set the new flags to the interface*/ - err = ioctl(fd, SIOCSIFFLAGS, &ifr); - if (err < 0) - { - perror("Could not access the interface, "); - close(fd); - return 0; - } - - /* Get the flags again to check if IFF_PROMISC is removed */ - err = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (err < 0) - { - perror("Could not access the interface, "); - close(fd); - return 0; - } - if(ifr.ifr_flags && IFF_PROMISC) - { - wl_logerr("Could not remove the promisc flag on %d", device); - close(fd); - return 0; - } - else - { - /* Successfully removed the promisc flags */ - close(fd); - return 1; - } -} - - - - -/* Set channel (Wireless frequency) of the device */ -int card_set_channel (const char *device, int channel, int cardtype) -{ - if (cardtype == CARD_TYPE_CISCO || cardtype == CARD_TYPE_NG) - { - /* Cisco and wlan-ng drivers don't need channelswitching */ - return 1; - } - /* If it is a lucent orinocco card */ - else if (cardtype == CARD_TYPE_ORINOCCO) - { - int fd; - //Wireless tools structure for the iocalls - struct iwreq ireq; - int *ptr; - /* Socket needed to use the iocall to */ - fd = socket(AF_INET, SOCK_STREAM, 0); - - if ( fd == -1 ) { - return -1; - } - - ptr = (int *) ireq.u.name; - // This is the monitor mode for 802.11 non-prism header - ptr[0] = 2; - ptr[1] = channel; - strcpy(ireq.ifr_ifrn.ifrn_name, device); - if (ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq)==0) - { - /* All was fine... */ - close(fd); - wl_loginfo("Set channel %d on interface %s",channel, device); - return 1; - } - else - { - /* iocall does not work */ - close(fd); - wl_logerr("Could not set channel %d on %s, check cardtype",channel, device); - return 0; - } - } - /* when it is an hostap card you need another iocall for channel switching */ - else if (cardtype == CARD_TYPE_HOSTAP) - { - int skfd; - skfd = socket(AF_INET, SOCK_STREAM, 0); - struct iwreq wrq; - iw_float2freq((double) channel, &wrq.u.freq); - - if(iw_set_ext(skfd,(char *) device,SIOCSIWFREQ,&wrq)<0) - { - wl_logerr("Could not set hostap card %s to channel %d", device, channel); - return 0; - } - else - { - wl_loginfo("Successfully set hostap card %s to channel %d", device, channel); - return 1; - } - } - /* For undefined situations */ - return 0; -} - - -int card_detect_channels (char * device) -{ - int skfd; - skfd = socket(AF_INET, SOCK_STREAM, 0); - struct iw_range range; - /* Get list of frequencies / channels */ - printf ("\n hostap card get the frequencies"); - /* Get list of frequencies / channels */ - if(iw_get_range_info(skfd, device, &range) < 0) - { /* We are failsave if something went wrong, asume only 11 channels */ - return 11; - } - else - { - if(range.num_frequency > 0) - { - return range.num_frequency; - } - else - { /* We are failsave asume only 11 channels */ - return 11; - } - } - -} /* End of card_detect_channels */ - -int iw_get_range_info(int skfd, const char * ifname, iw_range * range) -{ - struct iwreq wrq2; - char buffer[sizeof(iw_range) * 2]; /* Large enough */ - - /* Cleanup */ - memset(buffer, 0, sizeof(buffer)); - wrq2.u.data.pointer = (caddr_t) buffer; - wrq2.u.data.length = sizeof(buffer); - wrq2.u.data.flags = 0; - - if(iw_get_ext(skfd, (char *)ifname, SIOCGIWRANGE, &wrq2) < 0) - { - wl_logerr("Could not get the range from the interface"); - return(-1); - } - else - { - /* Copy stuff at the right place, ignore extra */ - memcpy((char *) range, buffer, sizeof(iw_range)); - return 0; - } -} - -/*------------------------------------------------------------------*/ -/* - * Convert our internal representation of frequencies to a floating point. - */ -double iw_freq2float(iw_freq * in) -{ - int i; - double res = (double) in->m; - for(i = 0; i < in->e; i++) - res *= 10; - return(res); -} - - -void iw_float2freq(double in, iw_freq * out) -{ - /* Version without libm : slower */ - out->e = 0; - while(in > 1e9) - { - in /= 10; - out->e++; - } - out->m = (long) in; -} - - - diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh deleted file mode 100644 index 73e0ae1..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh +++ b/dev/null @@ -1,107 +0,0 @@ -/* $Id$ */ - -#ifndef CARDMODE_HH -#define CARDMODE_HH - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Following typedefs are needed here, because linux/wireless.h - includes linux/ethertool.h which is using them */ -typedef signed char s8; -typedef unsigned char u8; -typedef signed short s16; -typedef unsigned short u16; -typedef signed int s32; -typedef unsigned int u32; -typedef signed long long s64; -typedef unsigned long long u64; - -#include - -#ifndef SIOCIWFIRSTPRIV -#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE -#endif - -extern "C" -{ -#include -#include -} - -extern pcap_t *handletopcap; - -/* Defines, used for the card setup */ -#define DEFAULT_PATH "/proc/driver/aironet/%s/Config" -#define CISCO_STATUS "/proc/driver/aironet/%s/Status" -#define CARD_TYPE_CISCO 1 -#define CARD_TYPE_NG 2 -#define CARD_TYPE_HOSTAP 3 -#define CARD_TYPE_ORINOCCO 4 - -/* Some usefull constants for frequencies */ -#define KILO 1e3 -#define MEGA 1e6 -#define GIGA 1e9 - - -/* only for now, until we have the daemon running */ -/*the config file should provide these information */ -#define CARD_TYPE CARD_TYPE_HOSTAP - -/* Prototypes */ -int card_check_rfmon_datalink (const char *device); -int card_into_monitormode (const char *, int); -int check_loopback(); -int card_set_promisc_up (const char *device); -int card_remove_promisc (const char *device); -int card_set_channel (const char *device, int channel,int cardtype); -int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range); -double iw_freq2float(iw_freq * in); -void iw_float2freq(double in, iw_freq * out); -int card_detect_channels (char * device); - -/*------------------------------------------------------------------*/ -/* - * Wrapper to push some Wireless Parameter in the driver - */ -static inline int -iw_set_ext(int skfd, /* Socket to the kernel */ - char * ifname, /* Device name */ - int request, /* WE ID */ - struct iwreq * pwrq) /* Fixed part of the request */ -{ - /* Set device name */ - strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); - /* Do the request */ - return(ioctl(skfd, request, pwrq)); -} - -/*------------------------------------------------------------------*/ -/* - * Wrapper to extract some Wireless Parameter out of the driver - */ -static inline int -iw_get_ext(int skfd, /* Socket to the kernel */ - char * ifname, /* Device name */ - int request, /* WE ID */ - struct iwreq * pwrq) /* Fixed part of the request */ -{ - /* Set device name */ - strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); - /* Do the request */ - return(ioctl(skfd, request, pwrq)); -} - - - -#endif /* CARDMODE_HH */ diff --git a/noncore/net/wellenreiter/libwellenreiter/source/extract.hh b/noncore/net/wellenreiter/libwellenreiter/source/extract.hh deleted file mode 100644 index f948bcb..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/extract.hh +++ b/dev/null @@ -1,59 +0,0 @@ -/* $Id$ */ -/* - * Copyright (c) 1992, 1993, 1994, 1995, 1996 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ -/* Network to host order macros */ - -#ifndef EXTRACT_HH -#define EXTRACT_HH - -#ifdef LBL_ALIGN -#define EXTRACT_16BITS(p) \ - ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ - (u_int16_t)*((const u_int8_t *)(p) + 1))) -#define EXTRACT_32BITS(p) \ - ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ - (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ - (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ - (u_int32_t)*((const u_int8_t *)(p) + 3))) -#else -#define EXTRACT_16BITS(p) \ - ((u_int16_t)ntohs(*(const u_int16_t *)(p))) -#define EXTRACT_32BITS(p) \ - ((u_int32_t)ntohl(*(const u_int32_t *)(p))) -#endif - -#define EXTRACT_24BITS(p) \ - ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ - (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ - (u_int32_t)*((const u_int8_t *)(p) + 2))) - -/* Little endian protocol host order macros */ -#define EXTRACT_LE_8BITS(p) (*(p)) -#define EXTRACT_LE_16BITS(p) \ - ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ - (u_int16_t)*((const u_int8_t *)(p) + 0))) -#define EXTRACT_LE_32BITS(p) \ - ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ - (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ - (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ - (u_int32_t)*((const u_int8_t *)(p) + 0))) - -#endif /* EXTRACT_HH */ diff --git a/noncore/net/wellenreiter/libwellenreiter/source/ieee802_11.hh b/noncore/net/wellenreiter/libwellenreiter/source/ieee802_11.hh deleted file mode 100644 index 872fd40..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/ieee802_11.hh +++ b/dev/null @@ -1,250 +0,0 @@ -/* $Id$ */ -/* - * Copyright (c) 2001 - * Fortress Technologies - * Charlie Lenahan ( clenahan@fortresstech.com ) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef IEEE802_11_HH -#define IEEE802_11_HH - -#define IEEE802_11_FC_LEN 2 - -#define T_MGMT 0x0 /* management */ -#define T_CTRL 0x1 /* control */ -#define T_DATA 0x2 /* data */ -#define T_RESV 0x3 /* reserved */ - -#define ST_ASSOC_REQUEST 0x0 -#define ST_ASSOC_RESPONSE 0x1 -#define ST_REASSOC_REQUEST 0x2 -#define ST_REASSOC_RESPONSE 0x3 -#define ST_PROBE_REQUEST 0x4 -#define ST_PROBE_RESPONSE 0x5 -/* RESERVED 0x6 */ -/* RESERVED 0x7 */ -#define ST_BEACON 0x8 -#define ST_ATIM 0x9 -#define ST_DISASSOC 0xA -#define ST_AUTH 0xB -#define ST_DEAUTH 0xC -/* RESERVED 0xD */ -/* RESERVED 0xE */ -/* RESERVED 0xF */ - - -#define CTRL_PS_POLL 0xA -#define CTRL_RTS 0xB -#define CTRL_CTS 0xC -#define CTRL_ACK 0xD -#define CTRL_CF_END 0xE -#define CTRL_END_ACK 0xF - -/* - * Bits in the frame control field. - */ -#define FC_VERSION(fc) ((fc) & 0x3) -#define FC_TYPE(fc) (((fc) >> 2) & 0x3) -#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF) -#define FC_TO_DS(fc) ((fc) & 0x0100) -#define FC_FROM_DS(fc) ((fc) & 0x0200) -#define FC_MORE_FLAG(fc) ((fc) & 0x0400) -#define FC_RETRY(fc) ((fc) & 0x0800) -#define FC_POWER_MGMT(fc) ((fc) & 0x1000) -#define FC_MORE_DATA(fc) ((fc) & 0x2000) -#define FC_WEP(fc) ((fc) & 0x4000) -#define FC_ORDER(fc) ((fc) & 0x8000) - -struct mgmt_header_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t da[6]; - u_int8_t sa[6]; - u_int8_t bssid[6]; - u_int16_t seq_ctrl; -}; - -#define MGMT_HEADER_LEN (2+2+6+6+6+2) - -#define CAPABILITY_ESS(cap) ((cap) & 0x0001) -#define CAPABILITY_IBSS(cap) ((cap) & 0x0002) -#define CAPABILITY_CFP(cap) ((cap) & 0x0004) -#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008) -#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010) - -struct ssid_t { - u_int8_t element_id; - u_int8_t length; - u_char ssid[33]; /* 32 + 1 for null */ -} ; - -struct rates_t { - u_int8_t element_id; - u_int8_t length; - u_int8_t rate[8]; -}; - -struct challenge_t { - u_int8_t element_id; - u_int8_t length; - u_int8_t text[254]; /* 1-253 + 1 for null */ -}; -struct fh_t { - u_int8_t element_id; - u_int8_t length; - u_int16_t dwell_time; - u_int8_t hop_set; - u_int8_t hop_pattern; - u_int8_t hop_index; -}; - -struct ds_t { - u_int8_t element_id; - u_int8_t length; - u_int8_t channel; -}; - -struct cf_t { - u_int8_t element_id; - u_int8_t length; - u_int8_t count; - u_int8_t period; - u_int16_t max_duration; - u_int16_t dur_remaing; -}; - -struct tim_t { - u_int8_t element_id; - u_int8_t length; - u_int8_t count; - u_int8_t period; - u_int8_t bitmap_control; - u_int8_t bitmap[251]; -}; - -#define E_SSID 0 -#define E_RATES 1 -#define E_FH 2 -#define E_DS 3 -#define E_CF 4 -#define E_TIM 5 -#define E_IBSS 6 -#define E_CISCO 133 -/* reserved 7 */ -/* reserved 8 */ -/* reserved 9 */ -/* reserved 10 */ -/* reserved 11 */ -/* reserved 12 */ -/* reserved 13 */ -/* reserved 14 */ -/* reserved 15 */ -/* reserved 16 */ - -#define E_CHALLENGE 16 -/* reserved 17 */ -/* reserved 18 */ -/* reserved 19 */ -/* reserved 16 */ -/* reserved 16 */ - - -struct mgmt_body_t { - u_int8_t timestamp[8]; - u_int16_t beacon_interval; - u_int16_t listen_interval; - u_int16_t status_code; - u_int16_t aid; - u_char ap[6]; - u_int16_t reason_code; - u_int16_t auth_alg; - u_int16_t auth_trans_seq_num; - struct challenge_t challenge; - u_int16_t capability_info; - struct ssid_t ssid; - struct rates_t rates; - struct ds_t ds; - struct cf_t cf; - struct fh_t fh; - struct tim_t tim; -}; - -struct ctrl_rts_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t ra[6]; - u_int8_t ta[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_RTS_LEN (2+2+6+6+4) - -struct ctrl_cts_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t ra[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_CTS_LEN (2+2+6+4) - -struct ctrl_ack_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t ra[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_ACK_LEN (2+2+6+4) - -struct ctrl_ps_poll_t { - u_int16_t fc; - u_int16_t aid; - u_int8_t bssid[6]; - u_int8_t ta[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_PS_POLL_LEN (2+2+6+6+4) - -struct ctrl_end_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t ra[6]; - u_int8_t bssid[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_END_LEN (2+2+6+6+4) - -struct ctrl_end_ack_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t ra[6]; - u_int8_t bssid[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_END_ACK_LEN (2+2+6+6+4) - -#define IV_IV(iv) ((iv) & 0xFFFFFF) -#define IV_PAD(iv) (((iv) >> 24) & 0x3F) -#define IV_KEYID(iv) (((iv) >> 30) & 0x03) - -#endif /* IEEE802_11_HH */ diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc deleted file mode 100644 index 0616a7e..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc +++ b/dev/null @@ -1,419 +0,0 @@ -/* - * rfmon mode sniffer - * - * $Id$ - */ - -#include "sniff.hh" -#include "ieee802_11.hh" -#include "extract.hh" -#include "wl_log.hh" -#include "wl_types.hh" -#include "wl_proto.hh" -#include "cardmode.hh" - -int start_sniffer(const char *device, int cardtype ) -{ - - /* This function initialize the sniffing - 1. Check for lo interface - 2. bring it into promsicous mode and UP - 3. bring device into rfmon mode - start the pcap sniffing process. - */ - - /* Do we have the device name ? */ - if(device == NULL) - { - wl_logerr("start_sniffer, parameter \"device\" is empty, please check your config"); - return 0; - } - - /* Some Linux System does not have a loopback device lo with 127.0.0.1 so sockets could - not made correctly, let the proggie check that and proceed only if it exists. */ - if (!check_loopback()) - { - wl_logerr("start_sniffer, check_loopback failed, cannot continue without a loopback"); - return 0; - } - - /* Set the card into regulary promiscous mode first and set the UP flag, in case no ip - was given. It would work without the promisc flags but i dont like this */ - if (!card_set_promisc_up(device)) - { - wl_logerr("start_sniffer, card_set_promisc_up failed, cannot continue"); - return 0; - } - - /* Set card into the rfmon/monitoring mode */ - if (!card_into_monitormode(device,cardtype)) - { - wl_logerr("start_sniffer, cannot put wireless card into monitoring mode, aborting"); - return 0; - } - - /* setup pcap handle, used for the packet decoding etc. */ - if((handletopcap = pcap_open_live((char *) device, BUFSIZ, 1, 0, NULL)) == NULL) - { - wl_logerr("pcap_open_live() failed: %s", strerror(errno)); - return 0; - } - -#ifdef HAVE_PCAP_NONBLOCK - pcap_setnonblock(handletopcap, 1, NULL); -#endif - return 1; -} - - -int stop_sniffer(const char *device, int cardtype) -{ - /* This function terminates the sniffing - 1. get the device state - 2. remove the rfmon state - 3. Remove the promisc state - start the pcap sniffing process. - - */ - - /* Do we really have at least a lo interface with the 127.0.0.1 ? */ - return 0; - -} - - -/* Main function, checks packets */ -void process_packets(const struct pcap_pkthdr *pkthdr, - const unsigned char *packet, - char *guihost, - int guiport) -{ - unsigned int caplen = pkthdr->caplen; - unsigned int length = pkthdr->len; - u_int16_t fc; - unsigned int HEADER_LENGTH; - - /* pinfo holds all interresting information for us */ - struct packetinfo pinfo; - struct packetinfo *pinfoptr; - - /* wl_network_t will finally be set and send to the ui */ - wl_network_t wl_net; - - pinfoptr=&pinfo; - - pinfoptr->isvalid = 0; - pinfoptr->pktlen = pkthdr->len; - - if (caplen < IEEE802_11_FC_LEN) - { - /* This is a garbage packet, because is does not long enough - to hold a 802.11b header */ - pinfoptr->isvalid = 0; - return; - } - - /* Gets the framecontrol bits (2bytes long) */ - fc = EXTRACT_LE_16BITS(packet); - - HEADER_LENGTH = GetHeaderLength(fc); - - if (caplen < HEADER_LENGTH) - { - /* This is a garbage packet, because it is not long enough - to hold a correct header of its type */ - pinfoptr->isvalid = 0; - return; - } - - /* Decode 802.11b header out of the packet */ - if (decode_80211b_hdr(packet,pinfoptr) == 0) - { - /* Justification of the ofset to further process the packet */ - length -= HEADER_LENGTH; - caplen -= HEADER_LENGTH; - packet += HEADER_LENGTH; - } - else /* Something is wrong,could not be a correct packet */ - return; - - switch (FC_TYPE(fc)) - { - /* Is it a managemnet frame? */ - case T_MGMT: - switch (FC_SUBTYPE(fc)) - { - case ST_BEACON: - if (handle_beacon(fc, packet,pinfoptr) ==0) - { - if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0) - { - /* Every beacon must have the broadcast as destination - so it must be a shitti packet */ - pinfoptr->isvalid = 0; - return; - } - - if (pinfoptr->cap_ESS == pinfoptr->cap_IBSS) - { - /* Only one of both are possible, so must be - a noise packet, if this comes up */ - pinfoptr->isvalid = 0; - return; - } - if (pinfoptr->channel < 1 || pinfoptr->channel > 14) - { - /* Only channels between 1 and 14 are possible - others must be noise packets */ - pinfoptr->isvalid = 0; - return; - } - - /* Here should be the infos to the gui issued */ - if (pinfoptr->cap_ESS == 1 && pinfoptr->cap_IBSS ==0) - { - wl_loginfo("Found an access point"); - wl_net.net_type=1; - } - else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2) - { - wl_loginfo("Found an ad-hoc network"); - wl_net.net_type=2; - } - - if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0) - wl_loginfo("Net is a non-broadcasting network"); - else - wl_loginfo("SSID is: %s", pinfoptr->ssid); - - wl_loginfo("SSID is: %s", pinfoptr->ssid); - memset(wl_net.bssid, 0, sizeof(wl_net.bssid)); - memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1); - - wl_loginfo("SSID length is: %d", pinfoptr->ssid_len); - wl_net.ssid_len=pinfoptr->ssid_len; - - wl_loginfo("Channel is: %d", pinfoptr->channel); - wl_net.channel=pinfoptr->channel; - wl_net.wep=pinfoptr->cap_WEP; - - wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr); - memset(wl_net.mac, 0, sizeof(wl_net.mac)); - memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1); - - if(!send_network_found((char *)guihost, guiport, &wl_net)) - { - wl_logerr("Error sending data to UI: %s", strerror(errno)); - break; - } - wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport); - } - break; - - default: - wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc)); - break; - } /* End of switch over different mgt frame types */ - - break; - - case T_CTRL: - wl_loginfo("Received control frame, not implemented yet"); - break; - - case T_DATA: - wl_loginfo("Received date frame, not implemented yet"); - break; - - default: - wl_logerr("Unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); - break; - } -} - -/* This decodes the 802.11b frame header out of the 802.11b packet - all the infos is placed into the packetinfo structure */ -int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo) -{ - const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p; - ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc); - - /* Get the sender, bssid and dest mac address */ - etheraddr_string(mgthdr->bssid,ppinfo->bssid); - etheraddr_string(mgthdr->da,ppinfo->desthwaddr); - etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr); - ppinfo->fc_wep = FC_WEP(mgthdr->fc); - return 0; -} - - -void etheraddr_string(register const u_char *ep, char *text) -{ - static char hex[] = "0123456789abcdef"; - register unsigned int i, j; - register char *cp; - char buf[sizeof("00:00:00:00:00:00\0")]; - cp = buf; - if ((j = *ep >> 4) != 0) - { - *cp++ = hex[j]; - } - else - { - *cp++ = '0'; - } - *cp++ = hex[*ep++ & 0xf]; - - for (i = 5; (int)--i >= 0;) - { - *cp++ = ':'; - if ((j = *ep >> 4) != 0) - { - *cp++ = hex[j]; - } - else - { - *cp++ = '0'; - } - - *cp++ = hex[*ep++ & 0xf]; - } - *cp = '\0'; - strcpy(text,buf); -} - -/* beacon handler */ -int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) -{ - struct mgmt_body_t pbody; - int offset = 0; - - /* Get the static informations out of the packet */ - memset(&pbody, 0, sizeof(pbody)); - memcpy(&pbody.timestamp, p, 8); - offset += 8; - pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); - offset += 2; - pbody.capability_info = EXTRACT_LE_16BITS(p+offset); - offset += 2; - - /* Gets the different flags out of the capabilities */ - ppinfo->cap_ESS = CAPABILITY_ESS(pbody.capability_info); - ppinfo->cap_IBSS = CAPABILITY_IBSS(pbody.capability_info); - ppinfo->cap_WEP = CAPABILITY_PRIVACY(pbody.capability_info); - - /* Gets the tagged elements out of the packets */ - while (offset + 1 < ppinfo->pktlen) - { - switch (*(p + offset)) - { - case E_SSID: - memcpy(&(pbody.ssid),p+offset,2); offset += 2; - if (pbody.ssid.length > 0) - { - memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length); - offset += pbody.ssid.length; - pbody.ssid.ssid[pbody.ssid.length]='\0'; - if (strcmp((char *)pbody.ssid.ssid,"")==0) - memcpy(ppinfo->ssid, NONBROADCASTING, sizeof(ppinfo->ssid)); - else - memcpy(ppinfo->ssid, pbody.ssid.ssid, sizeof(ppinfo->ssid)); - ppinfo->ssid_len = pbody.ssid.length; - } - break; - - case E_CHALLENGE: - memcpy(&(pbody.challenge),p+offset,2); offset += 2; - if (pbody.challenge.length > 0) - { - memcpy(&(pbody.challenge.text),p+offset,pbody.challenge.length); - offset += pbody.challenge.length; - pbody.challenge.text[pbody.challenge.length]='\0'; - } - break; - case E_RATES: - memcpy(&(pbody.rates),p+offset,2); offset += 2; - if (pbody.rates.length > 0) - { - memcpy(&(pbody.rates.rate),p+offset,pbody.rates.length); - offset += pbody.rates.length; - } - break; - case E_DS: - memcpy(&(pbody.ds),p+offset,3); - offset +=3; - ppinfo->channel = pbody.ds.channel; - break; - case E_CF: - memcpy(&(pbody.cf),p+offset,8); - offset +=8; - break; - case E_TIM: - memcpy(&(pbody.tim),p+offset,2); - offset +=2; - memcpy(&(pbody.tim.count),p+offset,3); - offset +=3; - if ((pbody.tim.length -3) > 0) - { - memcpy((pbody.tim.bitmap),p+(pbody.tim.length -3),(pbody.tim.length -3)); - offset += pbody.tim.length -3; - } - break; - default: - - offset+= *(p+offset+1) + 2; - break; - } /* end of switch*/ - } /* end of for loop */ - return 0; - -} /* End of handle_beacon */ - - -int GetHeaderLength(u_int16_t fc) -{ - int iLength=0; - - switch (FC_TYPE(fc)) - { - case T_MGMT: - iLength = MGMT_HEADER_LEN; - break; - case T_CTRL: - switch (FC_SUBTYPE(fc)) - { - case CTRL_PS_POLL: - iLength = CTRL_PS_POLL_LEN; - break; - case CTRL_RTS: - iLength = CTRL_RTS_LEN; - break; - case CTRL_CTS: - iLength = CTRL_CTS_LEN; - break; - case CTRL_ACK: - iLength = CTRL_ACK_LEN; - break; - case CTRL_CF_END: - iLength = CTRL_END_LEN; - break; - case CTRL_END_ACK: - iLength = CTRL_END_ACK_LEN; - break; - default: - iLength = 0; - break; - } - break; - case T_DATA: - if (FC_TO_DS(fc) && FC_FROM_DS(fc)) - iLength = 30; - else - iLength = 24; - break; - default: - wl_logerr("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); - break; - } - return iLength; -} diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh deleted file mode 100644 index a4cf4b7..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh +++ b/dev/null @@ -1,73 +0,0 @@ -/* $Id$ */ - -#ifndef SNIFF_HH -#define SNIFF_HH - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern "C" -{ -#include -#include -} - -#define NONBROADCASTING "non-broadcasting" - -/* holds all the interresting data */ -struct packetinfo -{ - int isvalid; - int pktlen; - int fctype; - int fcsubtype; - int fc_wep; - int cap_WEP; - int cap_IBSS; - int cap_ESS; - int channel; - char bssid[sizeof("00:00:00:00:00:00") + 1]; - char desthwaddr[sizeof("00:00:00:00:00:00") + 1]; - char sndhwaddr[sizeof("00:00:00:00:00:00") + 1]; - char ssid[128]; - int ssid_len; -}; - -/* Function definitions */ -/* Used for stoping and starting the sniffer process */ -int start_sniffer(const char *device, int cardtype); -int stop_sniffer(const char *device, int cardtype); -void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int); -int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); -void etheraddr_string(register const u_char *ep,char * text); -int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); -int GetHeaderLength(u_int16_t fc); - -/* - * True if "l" bytes of "var" were captured. - * - * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large - * that "snapend - (l)" underflows. - * - * The check is for <= rather than < because "l" might be 0. - */ -#define TTEST2(var, l) (snapend - (l) <= snapend && \ - (const u_char *)&(var) <= snapend - (l)) - -/* True if "var" was captured */ -#define TTEST(var) TTEST2(var, sizeof(var)) - -/* Bail if "l" bytes of "var" were not captured */ -#define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc - -/* Bail if "var" was not captured */ -#define TCHECK(var) TCHECK2(var, sizeof(var)) - -#endif /* SNIFF_HH */ diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc deleted file mode 100644 index ba56754..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc +++ b/dev/null @@ -1,81 +0,0 @@ -/* - * Configfile operations for wellenreiter - * - * $Id$ - */ - -#include "wl_conf.hh" -#include "wl_log.hh" -#include "wl_types.hh" - -/* Check whether configfile exists and is readable */ -int wl_checkcfg(void) -{ - FILE *wl_config; - - if((wl_config = fopen(WL_CONFFILE, "r")) == NULL) - { - wl_logerr("Cannot open configfile: %s", strerror(errno)); - return 0; - } - else - { - fclose(wl_config); - return 1; - } - -} - -/* Get value for given token from config file */ -int wl_cfgvalue(const char *token, char *out, int maxlen) -{ - FILE *wl_config; - char *ptr, *ptr2; - char confbuf[WL_CONFBUFF]; - - if(token == NULL) - return -1; - - if((wl_config = fopen(WL_CONFFILE, "r")) == NULL) - { - wl_logerr("Cannot open configfile: %s", strerror(errno)); - return -1; - } - - /* Clear buffers */ - memset(out, 0, maxlen); - memset(confbuf, 0, sizeof(confbuf)); - - while((fgets(confbuf, sizeof(confbuf) - 1, wl_config)) != NULL) - { - - /* Ignore comments */ - if(confbuf[0] == '#') continue; - - /* Search for token, if found check whether next character - * is a '=' or a ' ' - */ - if(strstr(confbuf, token) != NULL && - (confbuf[strlen(token)] == '=' || confbuf[strlen(token)] == ' ')) - { - - /* Get value between quotes */ - if((ptr = strstr(confbuf, "\"")) == NULL) - break; - ++ptr; - if((ptr2 = strstr(ptr, "\"")) == NULL) - break; - ptr2[0] = '\0'; - - memcpy(out, ptr, maxlen - 1); - break; - - } - memset(confbuf, 0, sizeof(confbuf)); - } - - fclose(wl_config); - - return (out[0] == '\0' ? 0 : 1); -} - diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.hh deleted file mode 100644 index 4061440..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.hh +++ b/dev/null @@ -1,12 +0,0 @@ -/* $Id$ */ - -#ifndef WLCONF_HH -#define WLCONF_HH - -#include -#include - -int wl_checkcfg(void); -int wl_cfgvalue(const char *, char *, int); - -#endif /* WLCONF_HH */ diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_log.cc deleted file mode 100644 index 7adaba8..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.cc +++ b/dev/null @@ -1,51 +0,0 @@ -/* - * Small functions to log to syslog - * - * $Id$ - */ - -#include "wl_log.hh" - -/* Log to syslog INFO */ -void wl_loginfo(const char *fmt,...) -{ - - char buffer[4096]; - va_list ap; - - memset(buffer, 0, sizeof(buffer)); - va_start(ap, fmt); - vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); - va_end(ap); - - openlog("libwellenreiter", LOG_PID, LOG_SYSLOG); - syslog(LOG_INFO, "(info) %s", buffer); - closelog(); - -#ifdef DEBUG - fprintf(stderr, "(info) %s\n", buffer); -#endif - -} - -/* Log to syslog ERR */ -void wl_logerr(const char *fmt,...) -{ - - char buffer[4096]; - va_list ap; - - memset(buffer, 0, sizeof(buffer)); - va_start(ap, fmt); - vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); - va_end(ap); - - openlog("libwellenreiter", LOG_PID, LOG_SYSLOG); - syslog(LOG_INFO, "(err) %s", buffer); - closelog(); - -#ifdef DEBUG - fprintf(stderr, "(err) %s\n", buffer); -#endif - -} diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_log.hh deleted file mode 100644 index 8f6e543..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.hh +++ b/dev/null @@ -1,14 +0,0 @@ -/* $Id$ */ - -#ifndef WLLOG_HH -#define WLLOG_HH - -#include -#include -#include -#include - -void wl_loginfo(const char *, ...); -void wl_logerr(const char *, ...); - -#endif /* WLLOG_HH */ diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc deleted file mode 100644 index 6c3846f..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc +++ b/dev/null @@ -1,221 +0,0 @@ -/* - * Communication protocol - * - * $Id$ - */ - -#include "wl_types.hh" -#include "wl_proto.hh" -#include "wl_log.hh" -#include "wl_sock.hh" - -/* Adds a field to the buffer */ -unsigned int add_field(char *buffer, const char *string, int len) -{ - char newlen[5]; - - /* 3 Byte = Length */ - memset(newlen, 0, sizeof(newlen)); - snprintf(newlen, sizeof(newlen) - 1, "%.3d", len); - memcpy(buffer, newlen, 3); - - /* Length bytes = Value */ - memcpy(buffer + 3, string, atoi(newlen)); - - /* Return length of attached field */ - return (atoi(newlen) + 3); -} - -unsigned int get_field(const char *buffer, char *out, int maxlen) -{ - char len[5]; - - /* Get length of value */ - memset(len, 0, sizeof(len)); - memcpy(len, buffer, 3); - - /* Copy buffer to out pointer */ - memset(out, 0, maxlen); - if(atoi(len) > maxlen -1) - memcpy(out, buffer + 3, maxlen - 1); - else - memcpy(out, buffer + 3, atoi(len)); - - /* Return length of whole field (including 3 byte length) */ - return (atoi(len) + 3); -} - -/* Send ok message */ -int send_ok(const char *guihost, int guiport, int code) -{ - unsigned int len = 0; - char buffer[128], temp[5]; - - memset(buffer, 0, sizeof(buffer)); - - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", CMD_OK); - memcpy(buffer, temp, 2); - len += 2; - - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", code); - len += add_field(buffer + len, temp, 2); - - /* Send prepared buffer to UI */ -#ifdef DEBUG - wl_loginfo("Sent ok to UI: '%s'", buffer); -#endif - - return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1); -} - -/* Send fail message */ -int send_fail(const char *guihost, int guiport, - int code, const char *errstr) -{ - unsigned int len = 0; - char buffer[128], temp[5]; - - memset(buffer, 0, sizeof(buffer)); - - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", CMD_FAIL); - memcpy(buffer, temp, 2); - len += 2; - - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", code); - len += add_field(buffer + len, temp, 2); - - len += add_field(buffer + len, errstr, strlen(errstr)); - - /* Send prepared buffer to UI */ -#ifdef DEBUG - wl_loginfo("Send CMD_FAIL to UI: '%s'", buffer); -#endif - - return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1); -} - -int get_ok(const char *buffer) -{ - char temp[5]; - unsigned int len = 0; - - /* packet type already determined, skip check */ - len += 2; - - /* what is ok for? */ - memset(temp, 0, sizeof(temp)); - len += get_field(buffer + len, temp, sizeof(temp)); - - return atoi(temp); -} - -/* put failmessage into buffer */ -int get_fail(char *out, const char *buffer, size_t bufflen) -{ - char temp[5]; - int error=0; - unsigned int len = 0; - - /* packet type already determined, skip check */ - len += 2; - - /* what is fail for? */ - memset(temp, 0, sizeof(temp)); - len += get_field(buffer + len, temp, sizeof(temp)); - error=atoi(temp); - - /* get errorstring and fill into buffer */ - memset(out, 0, bufflen); - len += get_field(buffer + len, out, bufflen - 1); - - return error; -} - - -/* Send found network to UI */ -int send_network_found (const char *guihost, int guiport, void *structure) -{ - wl_network_t *ptr; - char buffer[2048], temp[5]; - unsigned int len = 0; - - ptr = (wl_network_t *)structure; - - memset(buffer,0,sizeof(buffer)); - /* Type = Found new net (without length field) */ - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", WL_NETFOUND); - memcpy(buffer, temp, 2); - len += 2; - - /* Set Net-type */ - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%d", ptr->net_type); - len += add_field(buffer + len, temp, 1); - - /* Set channel */ - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", ptr->channel); - len += add_field(buffer + len, temp, 2); - - /* Set WEP y/n */ - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%d", ptr->wep); - len += add_field(buffer + len, temp, 1); - - /* Set Mac */ - len += add_field(buffer + len, ptr->mac, 17); - - /* Set ssid */ - if(len + ptr->ssid_len < sizeof(buffer) - 1) - len += add_field(buffer + len, ptr->bssid, ptr->ssid_len); - else - len += add_field(buffer + len, ptr->bssid, sizeof(buffer) - len - 1); - - /* Send prepared buffer to UI */ -#ifdef DEBUG - wl_loginfo("Sending network to UI: '%s'", buffer); -#endif - - return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1); -} - -/* Fill buffer into structur */ -int get_network_found (void *structure, const char *buffer) -{ - wl_network_t *ptr; - char temp[5]; - unsigned int len = 0; - - ptr = (wl_network_t *)structure; - - /* packet type already determined, skip check */ - len += 2; - - /* Get net type (accesspoint || ad-hoc || ...) */ - memset(temp, 0, sizeof(temp)); - len += get_field(buffer + len, temp, sizeof(temp)); - ptr->net_type = atoi(temp); - - /* Get channel */ - memset(temp, 0, sizeof(temp)); - len += get_field(buffer + len, temp, sizeof(temp)); - ptr->channel = atoi(temp); - - /* Set WEP y/n */ - memset(temp, 0, sizeof(temp)); - len += get_field(buffer + len, temp, sizeof(temp)); - ptr->wep = atoi(temp); - - /* Set MAC address */ - len += get_field(buffer + len, ptr->mac, sizeof(ptr->mac)); - - /* Set BSSID */ - len += get_field(buffer + len, ptr->bssid, sizeof(ptr->bssid)); - - return 1; -} diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh deleted file mode 100644 index 63ac53b..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh +++ b/dev/null @@ -1,27 +0,0 @@ -/* $Id$ */ - -#ifndef WLPROTO_HH -#define WLPROTO_HH - -#include -#include -#include - -/* Type definitions, to be continued */ -#define NETFOUND 01 -#define NETLOST 02 -#define CMD_FAIL 50 -#define CMD_OK 51 -#define STARTSNIFF 98 -#define STOPSNIFF 99 - -unsigned int add_field(char *, const char *, int); -unsigned int get_field(const char *, char *, int); -int send_ok(const char *, int, int); -int get_ok(const char *); -int send_fail(const char *, int, int, const char *); -int get_fail(char *, const char *, size_t); -int send_network_found (const char *, int, void *); -int get_network_found (void *, const char *); - -#endif /* WLPROTO_HH */ diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc deleted file mode 100644 index 6e26cb8..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc +++ b/dev/null @@ -1,92 +0,0 @@ -/* - * Socket operations for wellenreiter - * - * $Id$ - */ - -#include "wl_sock.hh" -#include "wl_log.hh" - -/* Setup UDP Socket for incoming commands */ -int wl_setupsock(const char *host, int port, struct sockaddr_in saddr) -{ - int sock; - - if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - { - wl_logerr("Cannot set up socket: %s", strerror(errno)); - return -1; - } - - memset(&saddr, 0, sizeof(saddr)); - saddr.sin_family = PF_INET; - saddr.sin_port = htons(port); - saddr.sin_addr.s_addr = inet_addr(host); - - if(bind(sock,(struct sockaddr *)&saddr, sizeof(saddr)) < 0) - { - wl_logerr("Cannot bind socket: %s", strerror(errno)); - close(sock); - return -1; - } - - return sock; -} - -/* Send a string to commsock */ -int wl_send(const char *host, int port, const char *string, ...) -{ - int sock; - char buffer[4096]; - struct sockaddr_in saddr; - va_list ap; - - /* Generate string */ - memset(buffer, 0, sizeof(buffer)); - va_start(ap, string); - vsnprintf(buffer, sizeof(buffer)-1, string, ap); - va_end(ap); - - saddr.sin_family = AF_INET; - saddr.sin_port = htons(port); - saddr.sin_addr.s_addr = inet_addr(host); - - /* Setup socket */ - if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - { - wl_logerr("Cannot set up socket: %s", strerror(errno)); - return 0; - } - - if(sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) - { - wl_logerr("Cannot write to socket: %s", strerror(errno)); - close(sock); - return 0; - } - - if(close(sock) < 0) - wl_logerr("Cannot close socket: %s", strerror(errno)); - - return 1; -} - -/* Check for new messages on commsock */ -int wl_recv(int *sock, struct sockaddr_in cliaddr, char *out, int maxlen) -{ - socklen_t len = sizeof(struct sockaddr); - char retval[3]; - - memset(out, 0, maxlen); - if(recvfrom(*sock, out, maxlen - 1, 0, (struct sockaddr *)&cliaddr, &len) < 0) - { - wl_logerr("Cannot receive from socket: %s", strerror(errno)); - return -1; - } - - /* Get packet type and return it */ - memset(retval, 0, sizeof(retval)); - memcpy(retval, out, 2); - - return atoi(retval); -} diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh deleted file mode 100644 index e7d9747..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh +++ b/dev/null @@ -1,21 +0,0 @@ -/* $Id */ - -#ifndef WLSOCK_HH -#define WLSOCK_HH - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int wl_setupsock(const char *, int, struct sockaddr_in); -int wl_send(const char *, int, const char *, ...); -int wl_recv(int *, struct sockaddr_in, char *, int); - -#endif /* WLSOCK_HH */ diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_types.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_types.hh deleted file mode 100644 index afc105c..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_types.hh +++ b/dev/null @@ -1,43 +0,0 @@ -/* - * Global bufffer size and type definitions - * - * $Id$ - * - */ - -#ifndef WL_TYPES_HH -#define WL_TYPES_HH - -/* Type definitions, to be continued */ -#define WL_NETFOUND 01 -#define WL_NETLOST 02 -#define WL_STARTSNIFF 98 -#define WL_STOPSNIFF 99 - -/* Socket specific */ -#define WL_SOCKBUF 512 /* Buffer for wl_send and wl_recv calls */ - -/* Channelswitching */ -typedef struct { - int type; /* Type of card (chip) */ - char iface[6]; /* Interface of card */ -} wl_cardtype_t; - - -/* WL network structure */ -typedef struct { - int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ - int ssid_len; /* Length of SSID */ - int channel; /* Channel */ - int wep; /* 1 = WEP enabled ; 0 = disabled */ - char mac[64]; /* MAC address of Accesspoint */ - char bssid[128]; /* BSSID of Net */ -} wl_network_t; - -/* Config specific */ -#define WL_CONFFILE "sample.conf" -#define WL_CONFBUFF 128 - - -#endif /* WL_TYPES_HH */ - -- cgit v0.9.0.2