summaryrefslogtreecommitdiff
path: root/noncore
authormjm <mjm>2002-12-28 12:59:38 (UTC)
committer mjm <mjm>2002-12-28 12:59:38 (UTC)
commit1adf0d153cd8c4714719183af45ed703abef0a43 (patch) (side-by-side diff)
tree8845f1bbee4d050a18a6e5fa970bb5adaa277bc0 /noncore
parent7a6a55d19048de7920eb885e80a26e1bef0f66e4 (diff)
downloadopie-1adf0d153cd8c4714719183af45ed703abef0a43.zip
opie-1adf0d153cd8c4714719183af45ed703abef0a43.tar.gz
opie-1adf0d153cd8c4714719183af45ed703abef0a43.tar.bz2
cleanup
Diffstat (limited to 'noncore') (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 @@
int card_into_monitormode (pcap_t **orighandle, 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 prmiscous and up flag to the interface */
+ /* Setting the promiscous and up flag to the interface */
if (!card_set_promisc_up(device))
{
wl_logerr("Cannot set interface to promisc mode: %s", strerror(errno));
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);
@@ -55,23 +55,20 @@ int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype)
}
else if (cardtype == CARD_TYPE_HOSTAP)
{
wl_logerr("Got a host-ap card, nothing is implemented now");
}
return 1;
}
/* Set card into promisc mode */
int card_set_promisc_up (const char *device)
{
- char ifconfigcmd[32];
+ char ifconfigcmd[48];
int retval=0;
snprintf(ifconfigcmd, sizeof(ifconfigcmd) - 1, SBIN_PATH, device);
retval = system(ifconfigcmd);
- if(retval != 0)
- return 0;
-
-return 1;
+ return (retval ? 0 : 1);
}
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
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);
memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1);;
- send_network_found((char *)guihost, guiport, &wl_net);
+ 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:
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)
int get_field(const char *buffer, char *out)
{
char len[5];
/* Get length of value */
memcpy(len, buffer, 3);
/* Copy buffer to out pointer */
memset(out, 0, atoi(len) + 1);
memcpy(out, buffer + 3, atoi(len));
- return atoi(len) + 3;
+ /* Return length of whole field (including 3 byte length) */
+ return (atoi(len) + 3);
}
-/* Send found network to GUI */
+/* Send found network to UI */
int send_network_found (const char *guihost, int guiport, void *structure)
{
wl_network_t *ptr;
char buffer[2048];
char temp[128];
int retval=0, len=0;
memset(temp, 0, sizeof(temp));
ptr = (wl_network_t *)structure;
/* Type = Found new net (without length field) */
@@ -66,38 +67,36 @@ int send_network_found (const char *guihost, int guiport, void *structure)
memset(temp, 0, sizeof(temp));
snprintf(temp, sizeof(temp), "%.2d", ptr->channel);
retval = add_field(buffer + len, temp, 2);
len += retval;
/* Set WEP y/n */
memset(temp, 0, sizeof(temp));
snprintf(temp, sizeof(temp), "%d", ptr->wep);
retval = add_field(buffer + len, temp, 1);
len += retval;
/* Set Mac */
- retval = add_field(buffer + len, (char *)ptr->mac, 17);
+ retval = add_field(buffer + len, ptr->mac, 17);
len += retval;
/* Set ssid */
- retval = add_field(buffer + len, (char *)ptr->bssid, ptr->ssid_len);
+ retval = add_field(buffer + len, ptr->bssid, ptr->ssid_len);
- /* Send prepared buffer to GUI */
+ /* Send prepared buffer to UI */
#ifdef DEBUG
- wl_loginfo("Sending network to GUI: '%s'", buffer);
+ wl_loginfo("Sending network to UI: '%s'", buffer);
#endif
- wl_send(guihost, guiport, buffer);
-
- return 1;
+ 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[512];
int retval=0, len=0;
ptr = (wl_network_t *)structure;
/* 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, ...)
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 -1;
+ 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 -1;
+ return 0;
}
if(close(sock) < 0)
wl_logerr("Cannot close socket: %s", strerror(errno));
- return 0;
+ return 1;
}
/* Check for new messages on commsock */
int wl_recv(int *sock, char *out, int maxlen)
{
struct sockaddr_in *cliaddr;
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)
return -1;