<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:Courier New,courier,monaco,monospace,sans-serif;font-size:10pt">Hi all<br><br><span style="font-weight: bold;">Setup</span>: PC1-------AP-----------STA----------PC2<br> eth0 br0 br0 eth0 <br> eth0+ath0 eth0+ath0 <br><br><span style="font-weight: bold;">Invocation:</span> wpa_supplicant -Dmadwifi -iath0 -bbr0 -c/etc/wpa_cupplicant.conf<br><br><span style="font-weight: bold;">Background</span>: I wanted to achieve association with AP with a mac address of PC2 not with STA, thus rendering STA invisible to the AP. Things working fine till here. Can
ping all nodes adding ebtables and iptables rules.<br><br><span style="font-weight: bold;">Goal</span>: Want to run WPA-PSK/WPA2-PSK for the authentication AP----STA. hostap/wpa_supplicant should be running on AP/STA (wpa_supplicant not to run on PC2 although STA has associated with PC2 mac).<br><br><span style="font-weight: bold;">Problem:</span> Now 4 way handshake fails to happen. As the wpa_supplicant sends 2 out of 4 message it sends it with own mac and i guess the hostapd rejects it as it associated with PC2 mac. i am using l2_packet_linux.c for layer two send. <br><br><span style="font-weight: bold;">What i have done</span>: modified the l2_packet send as follows. As well as i have enabled the l2->l2_hdr = 1 to include layer 2 header in l2_packet_init (my changes in <span style="color: rgb(0, 0, 255);">blue</span>)<br><br><span style="font-weight: bold;">Question</span>: Am i correct in my implementation. i can't still get the handshake
going. Hostapd -dd shows<br><span style="font-style: italic;">eth0: <PC2 MAC> WPA: sending 1/4 msg of 4 way handshake</span><br style="font-style: italic;"><span style="font-style: italic;">eth0: <PC2 MAC> EAPOL-Key timeout</span><br><br><br><br><span style="font-family: lucida console,sans-serif;">int l2_packet_send(struct l2_packet_data *l2, const u8 *dst_addr, u16 proto,</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> const u8 *buf, size_t len)</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">{</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</span><br style="font-family: lucida console,sans-serif;"><span
style="font-family: lucida console,sans-serif;"> <span style="color: rgb(0, 0, 255);">int ret;</span></span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> struct l2_ethhdr *eth;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> uint8_t src[ETH_ALEN] = {0x00, 0x13, 0x20, 0x5b, 0x40, 0xaa};// PC2 addr</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> size_t mlen = sizeof(*eth) + len;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida
console,sans-serif; color: rgb(0, 0, 255);"> </span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> eth = os_malloc(mlen);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> if (!eth) return -1;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> os_memset(&eth, 0, sizeof(eth));</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">
os_memcpy(eth->h_dest, dst_addr, ETH_ALEN);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> os_memcpy(eth->h_source, src, ETH_ALEN);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> eth->h_proto = host_to_be16(proto);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> os_memcpy(eth + 1, buf, len);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> ret = send(l2->fd,
buf, mlen, 0);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> if (ret < 0) perror("l2_packet_send - error pramod ");</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"> return ret;</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">#if 0</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> int ret;</span><br
style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> if (l2 == NULL)</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> return -1;</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> if (l2->l2_hdr) {</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> ret = send(l2->fd, buf, len, 0);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> wpa_printf(MSG_DEBUG, "pramod sending using send l2->l2_hdr=%d", l2->l2_hdr);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida
console,sans-serif;"> if (ret < 0)</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> perror("l2_packet_send - send 55");</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> } else {</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> struct sockaddr_ll ll;</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> os_memset(&ll, 0, sizeof(ll));</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> ll.sll_family = AF_PACKET;</span><br
style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> ll.sll_ifindex = l2->ifindex;</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> ll.sll_protocol = htons(proto);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> ll.sll_halen = ETH_ALEN;</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> os_memcpy(ll.sll_addr, dst_addr, ETH_ALEN);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> ret = sendto(l2->fd, buf, len, 0, (struct sockaddr *) &ll,</span><br
style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> sizeof(ll));</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> wpa_printf(MSG_DEBUG, "pramod sending using sendto l2->l2_hdr=%d", l2->l2_hdr);</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> if (ret < 0)</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> perror("l2_packet_send - sendto");</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> }</span><br
style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;"> return ret;</span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">#endif </span><br style="font-family: lucida console,sans-serif;"><span style="font-family: lucida console,sans-serif;">}</span><br><br><span style="font-weight: bold;">Finally:</span> if i am filling src dest proto of the ETH header is linux going to fill the CRC checksum? Is the is another way to implement this easily so that i can send the packets on the socket using my changed SRC mac address.<br><br><div> </div><div>Regards,</div> <div>Anirban De</div> <div>Yahoo: anirbande</div> <div>Skype: anirbande</div> <div>Gtalk : ade.sxc</div><div><br></div></div><br>
<!--6--><hr size=1></hr> Add more friends to your messenger and enjoy! <a href="http://in.rd.yahoo.com/tagline_messenger_6/*http://messenger.yahoo.com/invite/"> Invite them now.</a></body></html>