raw socket on orinoco driver
Giscard Wepiwe
wepiwe at fokus.gmd.de
Fri Oct 5 21:29:05 EST 2001
Hi everybody,
i have a problem while sending raw packet with raw socket under linux with a
wlan card ( from Lucent Technology).
-------------------------------------
[root at station2 wlan]# lsmod
Module Size Used by
orinoco_cs 4768 1
orinoco 28208 0 [orinoco_cs]
hermes 3584 0 [orinoco_cs orinoco]
ds 6928 2 [orinoco_cs]
i82365 12896 2
pcmcia_core 40128 0 [orinoco_cs ds i82365]
...
------------------------------------------
Here the code of the test application:
int main(int argc, char **argv) {
int sockfd;
struct sockaddr_ll mysocket;
unsigned char dest_mac_addr[6] = {0x00, 0x02, 0x2d, 0x1d, 0x13, 0xfa};
unsigned char src_mac_addr[6] = {0x00, 0x02, 0x2d, 0x20, 0x64, 0xcb};
unsigned char buffer[1024], puffer[1024];
int i, recv_ret;
if ((sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0 ) {
perror("socket");
exit(-1);
}
mysocket.sll_family = AF_PACKET;
mysocket.sll_protocol = ETH_P_ALL;
mysocket.sll_ifindex = 3;
mysocket.sll_hatype = 1;
mysocket.sll_halen = 8;
while ((recv_ret = recvfrom(sockfd, puffer, 1024, 0, 0,0)) > 0) {
/* Print out the packet */
for ( i = 0; i < recv_ret; i++) {
fprintf(stdout, "%02x%s", puffer[i],
i == recv_ret - 1 ? "\n":" ");
}
/* Set the MAC address of the destination */
for ( i=0; i<6; i++)
mysocket.sll_addr[i] = dest_mac_addr[i];
mysocket.sll_addr[6] = 0x00;
mysocket.sll_addr[7] = 0x00;
/* Set the destination and source mac_addresses */
for ( i = 0; i < 6; i++) {
buffer[i] = dest_mac_addr[i];
}
for (i = 6; i < 12; i++) {
buffer[i] = src_mac_addr[i-6];
}
//buffer[12] = 0x08;
//buffer[13] = 0x00;
memcpy(buffer+12, puffer+12, recv_ret);
if (sendto(sockfd, buffer, recv_ret, 0x00,
(struct sockaddr *)&mysocket, sizeof(mysocket)) < 0 ) {
perror("sendto");
exit(-1);
}
fprintf(stdout, "To send\n");
for ( i = 0; i < recv_ret; i++) {
fprintf(stdout, "%02x%s", buffer[i],
i == recv_ret + 13 ? "\n":" ");
}
fprintf(stdout, "I've sent\n");
}
return 0;
}
----iwconfig output
[root at station2 wlan]# iwconfig
lo no wireless extensions.
eth1 IEEE 802.11-DS ESSID:"FOKUS" Nickname:"station2"
Mode:Ad-Hoc Frequency:2.472GHz Cell: 00:60:1D:F1:F1:AD
Bit Rate=11Mb/s Tx-Power=15 dBm Sensitivity:1/3
Retry limit:4 RTS thr:off Fragment thr:off
Encryption key:6F6E-6169-72
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 invalid crypt:0 invalid misc:0
--- Output ifconfig
[root at station2 wlan]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:02:B3:1F:B1:84
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0
eth1 Link encap:Ethernet HWaddr 00:02:2D:20:64:CB
inet addr:195.37.78.208 Bcast:195.37.78.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:394 errors:0 dropped:0 overruns:0 frame:0
TX packets:175 errors:0 dropped:0 overruns:0 carrier:0
collisions:0
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0
-- Program output
[root at station2 wlan]# ./test
00 02 2d 20 64 cb 00 e0 2b 40 d4 00 08 00 45 10 00 34 37 3f 40 00 3e 06 aa 53
c1 af 87 7c c3 25 4e d0 b0 da 00 16 37 f6 48 4a 39 ec f0 ec 80 10 f8 e0 83 b3
00 00 01 01 08 0a 02 8a b2 1f 00 01 8e 52
sendto: No such device or address
By sending i still have this message. Why ?
Thanks already for the help.
--
MfG. Giscard Wépiwé
\\/////
(.) (.)
+------------------------+--------+---------oOO---(_)---OOo-------+
| Giscard Wépiwé | office: +49 30 34637283 |
| GMD-FOKUS | mobil: +49 179 4154809 |
| Research Institute | Kaiserin-Augusta-Allee 31 /10589 Berlin|
| for Open Communication +-----+----------------------------------+
| Systems | e-mail: wepiwe at fokus.gmd.de |
+------------------------+--------------+-----.oooO-Oooo.---------+
| http://user.cs.tu-berlin.de/~wepicard | ( ) ( )
+---------------------------------------+ \ ( ) /
\_) (_/
More information about the wireless
mailing list