Package: rbootd
Version: 2.0-6.1
Severity: normal

I got tired of seeing "kernel: rbootd uses obsolete 
(PF_INET,SOCK_PACKET)" entries in my syslog, so I decided to rewrite the 
packet sending code to use PF_PACKET instead. It uses SOCK_DGRAM to send 
IEEE 802.3 frames now.

Kars.

*** /tmp/rbootd.diff
diff -urN rbootd-2.0/debian/changelog rbootd-2.1/debian/changelog
--- rbootd-2.0/debian/changelog 2005-05-05 12:59:55.000000000 +0200
+++ rbootd-2.1/debian/changelog 2005-05-05 13:57:20.000000000 +0200
@@ -1,3 +1,9 @@
+rbootd (2.1-1) unstable; urgency=low
+
+  * Changed to use PF_PACKET socket instead of SOCK_PACKET
+
+ -- Kars de Jong <[EMAIL PROTECTED]>  Thu, 05 May 2005 13:56:17 +0200
+
 rbootd (2.0-6.1) unstable; urgency=low
 
   * Non maintainer upload
diff -urN rbootd-2.0/pcap.c rbootd-2.1/pcap.c
--- rbootd-2.0/pcap.c   1998-05-05 03:46:15.000000000 +0200
+++ rbootd-2.1/pcap.c   2005-05-05 13:52:11.000000000 +0200
@@ -27,7 +27,8 @@
 #include <unistd.h>                            /* close() */
 #include <syslog.h>                            /* syslog() */
 #include <net/if.h>                            /* struct ifreq */
-#include <linux/if_ether.h>                    /* ETH_P_ALL */
+#include <net/ethernet.h>                      /* ETH_P_802_3 */
+#include <netpacket/packet.h>                  /* PF_PACKET stuff */
 #include <string.h>                            /* strncpy(), bcopy() */
 #include "defs.h"
 
@@ -186,53 +187,46 @@
    * rconn->bootfd filedesc of open bootfile
    * rconn->next   ptr to next RMPCONN... 
    * 
-   * All we need to do is fill out source addr and send rconn->rmp. 
-   * This is all BpfWrite does, although there it's the BPF that does 
-   * the adding of source address.
-   * NOTE : we do *not* just set the source addr in the rconn we get given!
-   * We copy the old source addr and reset it, since code in rmpproto.c
-   * depends on the source address being the address of the *destination* 
-   * machine. (see the comment in rmp
-   *  
-   * Bits of this code borrowed from a post by 
-   * Jamie Lokier ([EMAIL PROTECTED]) giving source for a program that
-   * used SOCK_PACKET. Documentation on this facility is *really* rare...
+   * We use a PF_PACKET socket in IEEE 802.3 mode.
+   * All we need to do is fill out the destination addres and send rconn->rmp,
+   * skipping the Ethernet header (it will be filled in by the kernel).
    */ 
    int s,cs;
-   struct sockaddr sa;
-   char saveaddr[RMP_ADDRLEN];
-   
-   sa.sa_family = AF_INET;
-   strcpy (sa.sa_data, IntfName);
-   
-   s=socket(AF_INET, SOCK_PACKET, htons(ETH_P_ALL));
+   struct sockaddr_ll sa;
+
+   memset (&sa, 0, sizeof(sa));
+   s=socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_802_3));
    if (s == -1)
    {
       syslog(LOG_ERR, "attempt to open socket for write failed!");
       return 1;
    }
    
-   /* Get the source address for the packets. */
+   /* Get the interface index to be used. */
    {
       struct ifreq req;
       int status;
         
       strcpy (req.ifr_name, IntfName);
-      status = ioctl (s, SIOCGIFHWADDR, &req);
+      status = ioctl (s, SIOCGIFINDEX, &req);
       if (status == -1)
       {
-         syslog(LOG_ERR, "SIOCGIFHWADDR: couldn't get source address!");
+         syslog(LOG_ERR, "SIOCGIFINDEX: couldn't get interface index!");
          return 0;
       }
-      /* save old source addr, then write real source addr into packet */
-      memcpy (saveaddr, &(rconn->rmp.hp_hdr.saddr), RMP_ADDRLEN);
-      memcpy (&(rconn->rmp.hp_hdr.saddr), req.ifr_hwaddr.sa_data, RMP_ADDRLEN);
+      sa.sll_ifindex = req.ifr_ifindex;
    }
-   /* perform the actual raw packet send */
-   cs = sendto(s, &(rconn->rmp), rconn->rmplen, 0, &sa, sizeof(sa));       
 
-   /* restore previous contents of the source address field before return */
-   memcpy  (&(rconn->rmp.hp_hdr.saddr),saveaddr, RMP_ADDRLEN);
+   /* Fill in the socket address */
+   sa.sll_protocol = htons(ETH_P_802_3);
+   sa.sll_family = AF_PACKET;
+   memcpy (&sa.sll_addr, &(rconn->rmp.hp_hdr.daddr), RMP_ADDRLEN);
+   sa.sll_halen = RMP_ADDRLEN;
+
+   /* perform the actual packet send */
+   cs = sendto(s, &(rconn->rmp.hp_llc), rconn->rmplen - sizeof(struct hp_hdr),
+              0, (struct sockaddr *)&sa, sizeof(sa));
+
    close (s);
 
    if (cs == -1)


-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.11-1.14_FC3
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages rbootd depends on:
ii  libc6                       2.3.2.ds1-21 GNU C Library: Shared libraries an
ii  libpcap0.7                  0.7.2-7      System interface for user-level pa
ii  netbase                     4.21         Basic TCP/IP networking system

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to