summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc9
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/sniff.cc6
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc17
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc6
4 files changed, 19 insertions, 19 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
index c29f4d0..7362f14 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
@@ -11,25 +11,25 @@
11int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype) 11int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype)
12{ 12{
13 char CiscoRFMON[35] = "/proc/driver/aironet/"; 13 char CiscoRFMON[35] = "/proc/driver/aironet/";
14 FILE *CISCO_CONFIG_FILE; 14 FILE *CISCO_CONFIG_FILE;
15 15
16 /* Checks if we have a device to sniff on */ 16 /* Checks if we have a device to sniff on */
17 if(device == NULL) 17 if(device == NULL)
18 { 18 {
19 wl_logerr("No device given"); 19 wl_logerr("No device given");
20 return 0; 20 return 0;
21 } 21 }
22 22
23 /* Setting the prmiscous and up flag to the interface */ 23 /* Setting the promiscous and up flag to the interface */
24 if (!card_set_promisc_up(device)) 24 if (!card_set_promisc_up(device))
25 { 25 {
26 wl_logerr("Cannot set interface to promisc mode: %s", strerror(errno)); 26 wl_logerr("Cannot set interface to promisc mode: %s", strerror(errno));
27 return 0; 27 return 0;
28 } 28 }
29 wl_loginfo("Interface set to promisc mode"); 29 wl_loginfo("Interface set to promisc mode");
30 30
31 /* Check the cardtype and executes the commands to go into monitor mode */ 31 /* Check the cardtype and executes the commands to go into monitor mode */
32 if (cardtype == CARD_TYPE_CISCO) 32 if (cardtype == CARD_TYPE_CISCO)
33 { 33 {
34 /* bring the sniffer into rfmon mode */ 34 /* bring the sniffer into rfmon mode */
35 snprintf(CiscoRFMON, sizeof(CiscoRFMON) - 1, DEFAULT_PATH, device); 35 snprintf(CiscoRFMON, sizeof(CiscoRFMON) - 1, DEFAULT_PATH, device);
@@ -55,23 +55,20 @@ int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype)
55 } 55 }
56 else if (cardtype == CARD_TYPE_HOSTAP) 56 else if (cardtype == CARD_TYPE_HOSTAP)
57 { 57 {
58 wl_logerr("Got a host-ap card, nothing is implemented now"); 58 wl_logerr("Got a host-ap card, nothing is implemented now");
59 } 59 }
60 60
61 return 1; 61 return 1;
62} 62}
63 63
64/* Set card into promisc mode */ 64/* Set card into promisc mode */
65int card_set_promisc_up (const char *device) 65int card_set_promisc_up (const char *device)
66{ 66{
67 char ifconfigcmd[32]; 67 char ifconfigcmd[48];
68 int retval=0; 68 int retval=0;
69 69
70 snprintf(ifconfigcmd, sizeof(ifconfigcmd) - 1, SBIN_PATH, device); 70 snprintf(ifconfigcmd, sizeof(ifconfigcmd) - 1, SBIN_PATH, device);
71 retval = system(ifconfigcmd); 71 retval = system(ifconfigcmd);
72 72
73 if(retval != 0) 73 return (retval ? 0 : 1);
74 return 0;
75
76return 1;
77} 74}
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
index e2169ca..9b4e360 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
@@ -115,25 +115,29 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack
115 memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1); 115 memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1);
116 116
117 wl_loginfo("SSID length is: %d", pinfoptr->ssid_len); 117 wl_loginfo("SSID length is: %d", pinfoptr->ssid_len);
118 wl_net.ssid_len=pinfoptr->ssid_len; 118 wl_net.ssid_len=pinfoptr->ssid_len;
119 119
120 wl_loginfo("Channel is: %d", pinfoptr->channel); 120 wl_loginfo("Channel is: %d", pinfoptr->channel);
121 wl_net.channel=pinfoptr->channel; 121 wl_net.channel=pinfoptr->channel;
122 wl_net.wep=pinfoptr->cap_WEP; 122 wl_net.wep=pinfoptr->cap_WEP;
123 123
124 wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr); 124 wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr);
125 memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1);; 125 memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1);;
126 126
127 send_network_found((char *)guihost, guiport, &wl_net); 127 if(!send_network_found((char *)guihost, guiport, &wl_net))
128 {
129 wl_logerr("Error sending data to UI: %s", strerror(errno));
130 break;
131 }
128 wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport); 132 wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport);
129 } 133 }
130 break; 134 break;
131 135
132 default: 136 default:
133 wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc)); 137 wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc));
134 break; 138 break;
135 } /* End of switch over different mgt frame types */ 139 } /* End of switch over different mgt frame types */
136 140
137 break; 141 break;
138 142
139 case T_CTRL: 143 case T_CTRL:
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
index f15523f..5317f52 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
@@ -26,28 +26,29 @@ int add_field(char *buffer, char *string, int len)
26 26
27int get_field(const char *buffer, char *out) 27int get_field(const char *buffer, char *out)
28{ 28{
29 char len[5]; 29 char len[5];
30 30
31 /* Get length of value */ 31 /* Get length of value */
32 memcpy(len, buffer, 3); 32 memcpy(len, buffer, 3);
33 33
34 /* Copy buffer to out pointer */ 34 /* Copy buffer to out pointer */
35 memset(out, 0, atoi(len) + 1); 35 memset(out, 0, atoi(len) + 1);
36 memcpy(out, buffer + 3, atoi(len)); 36 memcpy(out, buffer + 3, atoi(len));
37 37
38 return atoi(len) + 3; 38 /* Return length of whole field (including 3 byte length) */
39 return (atoi(len) + 3);
39} 40}
40 41
41/* Send found network to GUI */ 42/* Send found network to UI */
42int send_network_found (const char *guihost, int guiport, void *structure) 43int send_network_found (const char *guihost, int guiport, void *structure)
43{ 44{
44 wl_network_t *ptr; 45 wl_network_t *ptr;
45 char buffer[2048]; 46 char buffer[2048];
46 char temp[128]; 47 char temp[128];
47 int retval=0, len=0; 48 int retval=0, len=0;
48 49
49 memset(temp, 0, sizeof(temp)); 50 memset(temp, 0, sizeof(temp));
50 51
51 ptr = (wl_network_t *)structure; 52 ptr = (wl_network_t *)structure;
52 53
53 /* Type = Found new net (without length field) */ 54 /* Type = Found new net (without length field) */
@@ -66,38 +67,36 @@ int send_network_found (const char *guihost, int guiport, void *structure)
66 memset(temp, 0, sizeof(temp)); 67 memset(temp, 0, sizeof(temp));
67 snprintf(temp, sizeof(temp), "%.2d", ptr->channel); 68 snprintf(temp, sizeof(temp), "%.2d", ptr->channel);
68 retval = add_field(buffer + len, temp, 2); 69 retval = add_field(buffer + len, temp, 2);
69 len += retval; 70 len += retval;
70 71
71 /* Set WEP y/n */ 72 /* Set WEP y/n */
72 memset(temp, 0, sizeof(temp)); 73 memset(temp, 0, sizeof(temp));
73 snprintf(temp, sizeof(temp), "%d", ptr->wep); 74 snprintf(temp, sizeof(temp), "%d", ptr->wep);
74 retval = add_field(buffer + len, temp, 1); 75 retval = add_field(buffer + len, temp, 1);
75 len += retval; 76 len += retval;
76 77
77 /* Set Mac */ 78 /* Set Mac */
78 retval = add_field(buffer + len, (char *)ptr->mac, 17); 79 retval = add_field(buffer + len, ptr->mac, 17);
79 len += retval; 80 len += retval;
80 81
81 /* Set ssid */ 82 /* Set ssid */
82 retval = add_field(buffer + len, (char *)ptr->bssid, ptr->ssid_len); 83 retval = add_field(buffer + len, ptr->bssid, ptr->ssid_len);
83 84
84 /* Send prepared buffer to GUI */ 85 /* Send prepared buffer to UI */
85#ifdef DEBUG 86#ifdef DEBUG
86 wl_loginfo("Sending network to GUI: '%s'", buffer); 87 wl_loginfo("Sending network to UI: '%s'", buffer);
87#endif 88#endif
88 89
89 wl_send(guihost, guiport, buffer); 90 return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1);
90
91 return 1;
92} 91}
93 92
94/* Fill buffer into structur */ 93/* Fill buffer into structur */
95int get_network_found (void *structure, const char *buffer) 94int get_network_found (void *structure, const char *buffer)
96{ 95{
97 wl_network_t *ptr; 96 wl_network_t *ptr;
98 char temp[512]; 97 char temp[512];
99 int retval=0, len=0; 98 int retval=0, len=0;
100 99
101 ptr = (wl_network_t *)structure; 100 ptr = (wl_network_t *)structure;
102 101
103 /* packet type already determined */ 102 /* packet type already determined */
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc
index 5714afb..4942fba 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc
@@ -47,38 +47,38 @@ int wl_send(const char *host, int port, const char *string, ...)
47 va_start(ap, string); 47 va_start(ap, string);
48 vsnprintf(buffer, sizeof(buffer)-1, string, ap); 48 vsnprintf(buffer, sizeof(buffer)-1, string, ap);
49 va_end(ap); 49 va_end(ap);
50 50
51 saddr.sin_family = AF_INET; 51 saddr.sin_family = AF_INET;
52 saddr.sin_port = htons(port); 52 saddr.sin_port = htons(port);
53 saddr.sin_addr.s_addr = inet_addr(host); 53 saddr.sin_addr.s_addr = inet_addr(host);
54 54
55 /* Setup socket */ 55 /* Setup socket */
56 if((sock=socket(AF_INET, SOCK_DGRAM, 0)) < 0) 56 if((sock=socket(AF_INET, SOCK_DGRAM, 0)) < 0)
57 { 57 {
58 wl_logerr("Cannot set up socket: %s", strerror(errno)); 58 wl_logerr("Cannot set up socket: %s", strerror(errno));
59 return -1; 59 return 0;
60 } 60 }
61 61
62 if(sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) 62 if(sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&saddr, sizeof(saddr)) < 0)
63 { 63 {
64 wl_logerr("Cannot write to socket: %s", strerror(errno)); 64 wl_logerr("Cannot write to socket: %s", strerror(errno));
65 close(sock); 65 close(sock);
66 return -1; 66 return 0;
67 } 67 }
68 68
69 if(close(sock) < 0) 69 if(close(sock) < 0)
70 wl_logerr("Cannot close socket: %s", strerror(errno)); 70 wl_logerr("Cannot close socket: %s", strerror(errno));
71 71
72 return 0; 72 return 1;
73} 73}
74 74
75/* Check for new messages on commsock */ 75/* Check for new messages on commsock */
76int wl_recv(int *sock, char *out, int maxlen) 76int wl_recv(int *sock, char *out, int maxlen)
77{ 77{
78 struct sockaddr_in *cliaddr; 78 struct sockaddr_in *cliaddr;
79 socklen_t len=sizeof(struct sockaddr); 79 socklen_t len=sizeof(struct sockaddr);
80 char retval[3]; 80 char retval[3];
81 81
82 memset(out, 0, maxlen); 82 memset(out, 0, maxlen);
83 if(recvfrom(*sock, out, maxlen - 1, 0, (struct sockaddr *)cliaddr, &len) < 0) 83 if(recvfrom(*sock, out, maxlen - 1, 0, (struct sockaddr *)cliaddr, &len) < 0)
84 return -1; 84 return -1;