~ubuntu-branches/ubuntu/feisty/wpasupplicant/feisty

« back to all changes in this revision

Viewing changes to l2_packet_winpcap.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2007-04-01 10:53:37 UTC
  • Revision ID: james.westby@ubuntu.com-20070401105337-3dd89n3g8ecdhjsl
Tags: 0.5.7-0ubuntu2
Apply patch from upstream after private email discussion:
http://w1.fi/gitweb/gitweb.cgi?p=hostap.git;a=commitdiff;h=33673d3f43da6f5ec0f0aa5a8245a1617b6eb2fd#patch1
Fixes LP: #98895, #98925

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
 
71
71
int l2_packet_get_own_addr(struct l2_packet_data *l2, u8 *addr)
72
72
{
73
 
        os_memcpy(addr, l2->own_addr, ETH_ALEN);
 
73
        memcpy(addr, l2->own_addr, ETH_ALEN);
74
74
        return 0;
75
75
}
76
76
 
88
88
                ret = pcap_sendpacket(l2->pcap, buf, len);
89
89
        } else {
90
90
                size_t mlen = sizeof(*eth) + len;
91
 
                eth = os_malloc(mlen);
 
91
                eth = malloc(mlen);
92
92
                if (eth == NULL)
93
93
                        return -1;
94
94
 
95
 
                os_memcpy(eth->h_dest, dst_addr, ETH_ALEN);
96
 
                os_memcpy(eth->h_source, l2->own_addr, ETH_ALEN);
 
95
                memcpy(eth->h_dest, dst_addr, ETH_ALEN);
 
96
                memcpy(eth->h_source, l2->own_addr, ETH_ALEN);
97
97
                eth->h_proto = htons(proto);
98
 
                os_memcpy(eth + 1, buf, len);
 
98
                memcpy(eth + 1, buf, len);
99
99
                ret = pcap_sendpacket(l2->pcap, (u8 *) eth, mlen);
100
 
                os_free(eth);
 
100
                free(eth);
101
101
        }
102
102
 
103
103
        return ret;
178
178
                fprintf(stderr, "ifname='%s'\n", l2->ifname);
179
179
                return -1;
180
180
        }
181
 
        os_snprintf(pcap_filter, sizeof(pcap_filter),
182
 
                    "not ether src " MACSTR " and "
183
 
                    "( ether dst " MACSTR " or ether dst " MACSTR " ) and "
184
 
                    "ether proto 0x%x",
185
 
                    MAC2STR(l2->own_addr), /* do not receive own packets */
186
 
                    MAC2STR(l2->own_addr), MAC2STR(pae_group_addr),
187
 
                    protocol);
 
181
        snprintf(pcap_filter, sizeof(pcap_filter),
 
182
                 "not ether src " MACSTR " and "
 
183
                 "( ether dst " MACSTR " or ether dst " MACSTR " ) and "
 
184
                 "ether proto 0x%x",
 
185
                 MAC2STR(l2->own_addr), /* do not receive own packets */
 
186
                 MAC2STR(l2->own_addr), MAC2STR(pae_group_addr),
 
187
                 protocol);
188
188
        if (pcap_compile(l2->pcap, &pcap_fp, pcap_filter, 1, pcap_netp) < 0) {
189
189
                fprintf(stderr, "pcap_compile: %s\n", pcap_geterr(l2->pcap));
190
190
                return -1;
210
210
        struct l2_packet_data *l2;
211
211
        DWORD thread_id;
212
212
 
213
 
        l2 = os_zalloc(sizeof(struct l2_packet_data));
 
213
        l2 = wpa_zalloc(sizeof(struct l2_packet_data));
214
214
        if (l2 == NULL)
215
215
                return NULL;
216
 
        if (os_strncmp(ifname, "\\Device\\NPF_", 12) == 0)
217
 
                os_strncpy(l2->ifname, ifname, sizeof(l2->ifname));
 
216
        if (strncmp(ifname, "\\Device\\NPF_", 12) == 0)
 
217
                strncpy(l2->ifname, ifname, sizeof(l2->ifname));
218
218
        else
219
 
                os_snprintf(l2->ifname, sizeof(l2->ifname), "\\Device\\NPF_%s",
220
 
                            ifname);
 
219
                snprintf(l2->ifname, sizeof(l2->ifname), "\\Device\\NPF_%s",
 
220
                         ifname);
221
221
        l2->rx_callback = rx_callback;
222
222
        l2->rx_callback_ctx = rx_callback_ctx;
223
223
        l2->l2_hdr = l2_hdr;
224
224
 
225
225
        if (own_addr)
226
 
                os_memcpy(l2->own_addr, own_addr, ETH_ALEN);
 
226
                memcpy(l2->own_addr, own_addr, ETH_ALEN);
227
227
 
228
228
        if (l2_packet_init_libpcap(l2, protocol)) {
229
 
                os_free(l2);
 
229
                free(l2);
230
230
                return NULL;
231
231
        }
232
232
 
239
239
                CloseHandle(l2->rx_done);
240
240
                CloseHandle(l2->rx_notify);
241
241
                pcap_close(l2->pcap);
242
 
                os_free(l2);
 
242
                free(l2);
243
243
                return NULL;
244
244
        }
245
245
 
272
272
        CloseHandle(l2->rx_avail);
273
273
        CloseHandle(l2->rx_done);
274
274
        CloseHandle(l2->rx_notify);
275
 
        os_free(l2);
 
275
        free(l2);
276
276
}
277
277
 
278
278
 
312
312
        }
313
313
 
314
314
        for (dev = devs; dev && !found; dev = dev->next) {
315
 
                if (os_strcmp(dev->name, l2->ifname) != 0)
 
315
                if (strcmp(dev->name, l2->ifname) != 0)
316
316
                        continue;
317
317
 
318
318
                addr = dev->addresses;
319
319
                while (addr) {
320
320
                        saddr = (struct sockaddr_in *) addr->addr;
321
321
                        if (saddr && saddr->sin_family == AF_INET) {
322
 
                                os_snprintf(buf, len, "%s",
323
 
                                            inet_ntoa(saddr->sin_addr));
 
322
                                snprintf(buf, len, "%s",
 
323
                                         inet_ntoa(saddr->sin_addr));
324
324
                                found = 1;
325
325
                                break;
326
326
                        }