File: send_arp.dev.patch

package info (click to toggle)
fake 1.1.11-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 336 kB
  • ctags: 42
  • sloc: sh: 258; makefile: 110; ansic: 103
file content (43 lines) | stat: -rw-r--r-- 1,214 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--- send_arp.orig/send_arp.c	Mon Jan  7 05:07:03 2002
+++ send_arp/send_arp.c	Mon Jan  7 05:08:09 2002
@@ -35,7 +35,7 @@
 #define DEFAULT_DEVICE "eth0"
 
 char usage[]={"send_arp: sends out custom ARP packet. yuri volobuev'97\n\
-\tusage: send_arp src_ip_addr src_hw_addr targ_ip_addr tar_hw_addr\n\n"};
+usage: send_arp src_ip_addr src_hw_addr targ_ip_addr targ_hw_addr [targ_int]\n\n"};
 
 struct arp_packet {
         u_char targ_hw_addr[ETH_HW_ADDR_LEN];
@@ -62,9 +62,11 @@
 struct in_addr src_in_addr,targ_in_addr;
 struct arp_packet pkt;
 struct sockaddr sa;
+char *c;
+int n;
 int sock;
 
-if(argc != 5)die(usage);
+if(argc != 5 && argc !=6)die(usage);
 
 sock=socket(AF_INET,SOCK_PACKET,htons(ETH_P_RARP));
 if(sock<0){
@@ -92,7 +94,17 @@
 
 bzero(pkt.padding,18);
 
-strcpy(sa.sa_data,DEFAULT_DEVICE);
+if (argc!=6) {
+        strcpy(sa.sa_data,DEFAULT_DEVICE);
+} else {
+       if ((c=strchr(argv[5], ':'))) {
+               n=c-argv[5];
+               strncpy(sa.sa_data, argv[5], n);
+               *(sa.sa_data+n)='\0';
+       } else {
+               strcpy(sa.sa_data, argv[5]);
+       }
+}
 if(sendto(sock,&pkt,sizeof(pkt),0,&sa,sizeof(sa)) < 0){
         perror("sendto");
         exit(1);