"Fossies" - the Fresh Open Source Software Archive

Member "fake-1.1.11/send_arp.l2.patch" (8 Jul 2009, 2466 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    2002-10-21 14:19:27.000000000 +0900
    2 +++ send_arp/send_arp.c 2002-10-21 14:25:03.000000000 +0900
    3 @@ -33,11 +33,13 @@
    4  
    5  #define DEFAULT_DEVICE "eth0"
    6  
    7 -char usage[]={"send_arp: sends out custom ARP packet. yuri volobuev'97\n\
    8 -usage: send_arp src_ip_addr src_hw_addr targ_ip_addr targ_hw_addr [targ_int]\n\n"};
    9 +char usage[]={"send_arp: sends out custom ARP packet. yuri volobuev'97\n\n\
   10 +usage: send_arp sndr_ip_addr sndr_hw_addr\n\
   11 +                targ_ip_addr targ_hw_addr\n\
   12 +                [targ_int [src_hw_addr [dest_hw_addr]]]\n\n"};
   13  
   14  struct arp_packet {
   15 -        u_char targ_hw_addr[ETH_HW_ADDR_LEN];
   16 +        u_char dest_hw_addr[ETH_HW_ADDR_LEN];
   17          u_char src_hw_addr[ETH_HW_ADDR_LEN];
   18          u_short frame_type;
   19          u_short hw_type;
   20 @@ -47,8 +49,8 @@
   21          u_short op;
   22          u_char sndr_hw_addr[ETH_HW_ADDR_LEN];
   23          u_char sndr_ip_addr[IP_ADDR_LEN];
   24 -        u_char rcpt_hw_addr[ETH_HW_ADDR_LEN];
   25 -        u_char rcpt_ip_addr[IP_ADDR_LEN];
   26 +        u_char targ_hw_addr[ETH_HW_ADDR_LEN];
   27 +        u_char targ_ip_addr[IP_ADDR_LEN];
   28          u_char padding[18];
   29  };
   30  
   31 @@ -58,14 +60,14 @@
   32  
   33  int main(int argc,char** argv){
   34  
   35 -struct in_addr src_in_addr,targ_in_addr;
   36 +struct in_addr sndr_in_addr,targ_in_addr;
   37  struct arp_packet pkt;
   38  struct sockaddr sa;
   39 +int sock;
   40  char *c;
   41  int n;
   42 -int sock;
   43  
   44 -if(argc != 5 && argc !=6)die(usage);
   45 +if(argc < 5 || argc > 8) die(usage);
   46  
   47  sock=socket(AF_INET,SOCK_PACKET,htons(ETH_P_RARP));
   48  if(sock<0){
   49 @@ -80,20 +82,30 @@
   50  pkt.prot_addr_size = IP_ADDR_LEN;
   51  pkt.op=htons(OP_ARP_REQUEST);
   52  
   53 +if ( argc == 8 ) {
   54 +   get_hw_addr(pkt.dest_hw_addr,argv[7]);
   55 +} else {
   56 +   get_hw_addr(pkt.dest_hw_addr,argv[4]);
   57 +}
   58 +
   59 +if ( argc >= 7 ) {
   60 +   get_hw_addr(pkt.src_hw_addr,argv[6]);
   61 +} else {
   62 +   get_hw_addr(pkt.src_hw_addr,argv[2]);
   63 +}
   64 +
   65  get_hw_addr(pkt.targ_hw_addr,argv[4]);
   66 -get_hw_addr(pkt.rcpt_hw_addr,argv[4]);
   67 -get_hw_addr(pkt.src_hw_addr,argv[2]);
   68  get_hw_addr(pkt.sndr_hw_addr,argv[2]);
   69  
   70 -get_ip_addr(&src_in_addr,argv[1]);
   71 +get_ip_addr(&sndr_in_addr,argv[1]);
   72  get_ip_addr(&targ_in_addr,argv[3]);
   73  
   74 -memcpy(pkt.sndr_ip_addr,&src_in_addr,IP_ADDR_LEN);
   75 -memcpy(pkt.rcpt_ip_addr,&targ_in_addr,IP_ADDR_LEN);
   76 +memcpy(pkt.sndr_ip_addr,&sndr_in_addr,IP_ADDR_LEN);
   77 +memcpy(pkt.targ_ip_addr,&targ_in_addr,IP_ADDR_LEN);
   78  
   79  bzero(pkt.padding,18);
   80  
   81 -if (argc!=6) {
   82 +if (argc==5) {
   83          strcpy(sa.sa_data,DEFAULT_DEVICE);
   84  } else {
   85         if ((c=strchr(argv[5], ':'))) {