"Fossies" - the Fresh Open Source Software Archive

Member "fake-1.1.11/send_arp.request_reply.patch" (8 Jul 2009, 1510 Bytes) of package /linux/misc/old/fake-1.1.11.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Diff source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 --- send_arp.orig/send_arp.c    2004-06-08 12:28:24.000000000 +0900
    2 +++ send_arp.orig/send_arp.c    2004-06-08 13:47:59.000000000 +0900
    3 @@ -29,14 +29,15 @@
    4  #define ARP_FRAME_TYPE 0x0806
    5  #define ETHER_HW_TYPE 1
    6  #define IP_PROTO_TYPE 0x0800
    7 -#define OP_ARP_REQUEST 2
    8 +#define OP_ARP_REQUEST 1
    9 +#define OP_ARP_REPLY   2
   10  
   11  #define DEFAULT_DEVICE "eth0"
   12  
   13  char usage[]={"send_arp: sends out custom ARP packet. yuri volobuev'97\n\n\
   14  usage: send_arp sndr_ip_addr sndr_hw_addr\n\
   15                  targ_ip_addr targ_hw_addr\n\
   16 -                [targ_int [src_hw_addr [dest_hw_addr]]]\n\n"};
   17 +                [[targ_int [src_hw_addr [dest_hw_addr] [request|reply]]\n\n"};
   18  
   19  struct arp_packet {
   20          u_char dest_hw_addr[ETH_HW_ADDR_LEN];
   21 @@ -67,7 +68,7 @@
   22  char *c;
   23  int n;
   24  
   25 -if(argc < 5 || argc > 8) die(usage);
   26 +if(argc < 5 || argc > 9) die(usage);
   27  
   28  sock=socket(AF_INET,SOCK_PACKET,htons(ETH_P_RARP));
   29  if(sock<0){
   30 @@ -80,9 +81,22 @@
   31  pkt.prot_type = htons(IP_PROTO_TYPE);
   32  pkt.hw_addr_size = ETH_HW_ADDR_LEN;
   33  pkt.prot_addr_size = IP_ADDR_LEN;
   34 -pkt.op=htons(OP_ARP_REQUEST);
   35  
   36 -if ( argc == 8 ) {
   37 +if ( argc == 9 ) {
   38 +   if (! strcasecmp("request", argv[8])) {
   39 +       pkt.op=htons(OP_ARP_REQUEST);
   40 +   }
   41 +   else if (! strcasecmp("reply", argv[8])) {
   42 +       pkt.op=htons(OP_ARP_REPLY);
   43 +   }
   44 +   else {
   45 +       die("Invalid arp type. Must be \"request\" or \"reply\"");
   46 +   }
   47 +} else {
   48 +   pkt.op=htons(OP_ARP_REQUEST);
   49 +}
   50 +
   51 +if ( argc >= 8 ) {
   52     get_hw_addr(pkt.dest_hw_addr,argv[7]);
   53  } else {
   54     get_hw_addr(pkt.dest_hw_addr,argv[4]);