-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/sniff.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc index 9b4e360..e516177 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc | |||
@@ -61,113 +61,116 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack | |||
61 | } | 61 | } |
62 | else /* Something is wrong,could not be a correct packet */ | 62 | else /* Something is wrong,could not be a correct packet */ |
63 | return; | 63 | return; |
64 | 64 | ||
65 | switch (FC_TYPE(fc)) | 65 | switch (FC_TYPE(fc)) |
66 | { | 66 | { |
67 | /* Is it a managemnet frame? */ | 67 | /* Is it a managemnet frame? */ |
68 | case T_MGMT: | 68 | case T_MGMT: |
69 | switch (FC_SUBTYPE(fc)) | 69 | switch (FC_SUBTYPE(fc)) |
70 | { | 70 | { |
71 | case ST_BEACON: | 71 | case ST_BEACON: |
72 | if (handle_beacon(fc, packet,pinfoptr) ==0) | 72 | if (handle_beacon(fc, packet,pinfoptr) ==0) |
73 | { | 73 | { |
74 | if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0) | 74 | if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0) |
75 | { | 75 | { |
76 | /* Every beacon must have the broadcast as destination | 76 | /* Every beacon must have the broadcast as destination |
77 | so it must be a shitti packet */ | 77 | so it must be a shitti packet */ |
78 | pinfoptr->isvalid = 0; | 78 | pinfoptr->isvalid = 0; |
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | 81 | ||
82 | if (pinfoptr->cap_ESS == pinfoptr->cap_IBSS) | 82 | if (pinfoptr->cap_ESS == pinfoptr->cap_IBSS) |
83 | { | 83 | { |
84 | /* Only one of both are possible, so must be | 84 | /* Only one of both are possible, so must be |
85 | a noise packet, if this comes up */ | 85 | a noise packet, if this comes up */ |
86 | pinfoptr->isvalid = 0; | 86 | pinfoptr->isvalid = 0; |
87 | return; | 87 | return; |
88 | } | 88 | } |
89 | if (pinfoptr->channel < 1 || pinfoptr->channel > 14) | 89 | if (pinfoptr->channel < 1 || pinfoptr->channel > 14) |
90 | { | 90 | { |
91 | /* Only channels between 1 and 14 are possible | 91 | /* Only channels between 1 and 14 are possible |
92 | others must be noise packets */ | 92 | others must be noise packets */ |
93 | pinfoptr->isvalid = 0; | 93 | pinfoptr->isvalid = 0; |
94 | return; | 94 | return; |
95 | } | 95 | } |
96 | 96 | ||
97 | /* Here should be the infos to the gui issued */ | 97 | /* Here should be the infos to the gui issued */ |
98 | if (pinfoptr->cap_ESS == 1 &&pinfoptr->cap_IBSS ==0) | 98 | if (pinfoptr->cap_ESS == 1 &&pinfoptr->cap_IBSS ==0) |
99 | { | 99 | { |
100 | wl_loginfo("Found an access point"); | 100 | wl_loginfo("Found an access point"); |
101 | wl_net.net_type=1; | 101 | wl_net.net_type=1; |
102 | } | 102 | } |
103 | else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2) | 103 | else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2) |
104 | { | 104 | { |
105 | wl_loginfo("Found an ad-hoc network"); | 105 | wl_loginfo("Found an ad-hoc network"); |
106 | wl_net.net_type=2; | 106 | wl_net.net_type=2; |
107 | } | 107 | } |
108 | 108 | ||
109 | memset(wl_net.bssid, 0, sizeof(wl_net.bssid)); | ||
110 | |||
109 | if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0) | 111 | if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0) |
110 | wl_loginfo("Net is a non-broadcasting network"); | 112 | wl_loginfo("Net is a non-broadcasting network"); |
111 | else | 113 | else |
112 | wl_loginfo("SSID is: %s", pinfoptr->ssid); | 114 | wl_loginfo("SSID is: %s", pinfoptr->ssid); |
113 | 115 | ||
114 | wl_loginfo("SSID is: %s", pinfoptr->ssid); | 116 | wl_loginfo("SSID is: %s", pinfoptr->ssid); |
115 | memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1); | 117 | memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1); |
116 | 118 | ||
117 | wl_loginfo("SSID length is: %d", pinfoptr->ssid_len); | 119 | wl_loginfo("SSID length is: %d", pinfoptr->ssid_len); |
118 | wl_net.ssid_len=pinfoptr->ssid_len; | 120 | wl_net.ssid_len=pinfoptr->ssid_len; |
119 | 121 | ||
120 | wl_loginfo("Channel is: %d", pinfoptr->channel); | 122 | wl_loginfo("Channel is: %d", pinfoptr->channel); |
121 | wl_net.channel=pinfoptr->channel; | 123 | wl_net.channel=pinfoptr->channel; |
122 | wl_net.wep=pinfoptr->cap_WEP; | 124 | wl_net.wep=pinfoptr->cap_WEP; |
123 | 125 | ||
124 | wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr); | 126 | wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr); |
125 | memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1);; | 127 | memset(wl_net.mac, 0, sizeof(wl_net.mac)); |
128 | memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1); | ||
126 | 129 | ||
127 | if(!send_network_found((char *)guihost, guiport, &wl_net)) | 130 | if(!send_network_found((char *)guihost, guiport, &wl_net)) |
128 | { | 131 | { |
129 | wl_logerr("Error sending data to UI: %s", strerror(errno)); | 132 | wl_logerr("Error sending data to UI: %s", strerror(errno)); |
130 | break; | 133 | break; |
131 | } | 134 | } |
132 | wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport); | 135 | wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport); |
133 | } | 136 | } |
134 | break; | 137 | break; |
135 | 138 | ||
136 | default: | 139 | default: |
137 | wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc)); | 140 | wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc)); |
138 | break; | 141 | break; |
139 | } /* End of switch over different mgt frame types */ | 142 | } /* End of switch over different mgt frame types */ |
140 | 143 | ||
141 | break; | 144 | break; |
142 | 145 | ||
143 | case T_CTRL: | 146 | case T_CTRL: |
144 | wl_loginfo("Received control frame, not implemented yet"); | 147 | wl_loginfo("Received control frame, not implemented yet"); |
145 | break; | 148 | break; |
146 | 149 | ||
147 | case T_DATA: | 150 | case T_DATA: |
148 | wl_loginfo("Received date frame, not implemented yet"); | 151 | wl_loginfo("Received date frame, not implemented yet"); |
149 | break; | 152 | break; |
150 | 153 | ||
151 | default: | 154 | default: |
152 | wl_logerr("Unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); | 155 | wl_logerr("Unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); |
153 | break; | 156 | break; |
154 | } | 157 | } |
155 | } | 158 | } |
156 | 159 | ||
157 | /* This decodes the 802.11b frame header out of the 802.11b packet | 160 | /* This decodes the 802.11b frame header out of the 802.11b packet |
158 | all the infos is placed into the packetinfo structure */ | 161 | all the infos is placed into the packetinfo structure */ |
159 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo) | 162 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo) |
160 | { | 163 | { |
161 | const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p; | 164 | const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p; |
162 | ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc); | 165 | ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc); |
163 | 166 | ||
164 | /* Get the sender, bssid and dest mac address */ | 167 | /* Get the sender, bssid and dest mac address */ |
165 | etheraddr_string(mgthdr->bssid,ppinfo->bssid); | 168 | etheraddr_string(mgthdr->bssid,ppinfo->bssid); |
166 | etheraddr_string(mgthdr->da,ppinfo->desthwaddr); | 169 | etheraddr_string(mgthdr->da,ppinfo->desthwaddr); |
167 | etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr); | 170 | etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr); |
168 | ppinfo->fc_wep = FC_WEP(mgthdr->fc); | 171 | ppinfo->fc_wep = FC_WEP(mgthdr->fc); |
169 | return 0; | 172 | return 0; |
170 | } | 173 | } |
171 | 174 | ||
172 | 175 | ||
173 | void etheraddr_string(register const u_char *ep, char *text) | 176 | void etheraddr_string(register const u_char *ep, char *text) |