Hi

I hope this mailing list is not completely wrong for sending these
patches...  If so, here goes a few bits of waste more.

A new debugbootpRequest which outputs readable (wow!) output :-)


diff -ur anaconda-rawhide.orig/pump/dhcp.c anaconda-rawhide/pump/dhcp.c
--- anaconda-rawhide.orig/pump/dhcp.c   Wed Nov 10 18:51:36 1999
+++ anaconda-rawhide/pump/dhcp.c        Mon Nov 29 12:41:42 1999
@@ -34,6 +34,9 @@
 
 #define _(a) (a)
 
+#define BOOTP_OPTION_PAD               0
+#define BOOTP_OPTION_END               255
+
 #define BOOTP_OPTION_NETMASK           1
 #define BOOTP_OPTION_GATEWAY           3
 #define BOOTP_OPTION_DNS               6
@@ -611,78 +614,72 @@
 }
 
 void debugbootpRequest(char *name, struct bootpRequest *breq)  {
-    char vendor[28], vendor2[28];
-    int i;
-    struct in_addr address;
-    unsigned char *vndptr;
-    unsigned char option, length;
-    
-    syslog (LOG_DEBUG, "%s: opcode: %i", name, breq->opcode);
-    syslog (LOG_DEBUG, "%s: hw: %i", name, breq->hw);
-    syslog (LOG_DEBUG, "%s: hwlength: %i", name, breq->hwlength);
-    syslog (LOG_DEBUG, "%s: hopcount: %i", name, breq->hopcount);
-    syslog (LOG_DEBUG, "%s: id: 0x%8x", name, breq->id);
-    syslog (LOG_DEBUG, "%s: secs: %i", name, breq->secs);
-    syslog (LOG_DEBUG, "%s: flags: 0x%4x", name, breq->flags);
-    
-    address.s_addr = breq->ciaddr;
-    syslog (LOG_DEBUG, "%s: ciaddr: %s", name, inet_ntoa (address));
-    
-    address.s_addr = breq->yiaddr;
-    syslog (LOG_DEBUG, "%s: yiaddr: %s", name, inet_ntoa (address));
-    
-    address.s_addr = breq->server_ip;
-    syslog (LOG_DEBUG, "%s: server_ip: %s", name, inet_ntoa (address));
-    
-    address.s_addr = breq->bootp_gw_ip;
-    syslog (LOG_DEBUG, "%s: bootp_gw_ip: %s", name, inet_ntoa (address));
+  char buf1[80], buf2[80];
+  int i;
+  struct in_addr address;
+  uint8_t *optptr, *optend, option, length;
+  
+  syslog (LOG_DEBUG, "%s: op: %i", name, breq->opcode);
+  syslog (LOG_DEBUG, "%s: htype: %i", name, breq->hw);
+  syslog (LOG_DEBUG, "%s: hlen: %i", name, breq->hwlength);
+  syslog (LOG_DEBUG, "%s: hops: %i", name, breq->hopcount);
+  syslog (LOG_DEBUG, "%s: xid: 0x%8x", name, breq->id);
+  syslog (LOG_DEBUG, "%s: secs: %i", name, breq->secs);
+  syslog (LOG_DEBUG, "%s: flags: 0x%4x", name, breq->flags);
+  address.s_addr = breq->ciaddr;
+  syslog (LOG_DEBUG, "%s: ciaddr: %s", name, inet_ntoa (address));
+  address.s_addr = breq->yiaddr;
+  syslog (LOG_DEBUG, "%s: yiaddr: %s", name, inet_ntoa (address));
+  address.s_addr = breq->server_ip;
+  syslog (LOG_DEBUG, "%s: siaddr: %s", name, inet_ntoa (address));
+  address.s_addr = breq->bootp_gw_ip;
+  syslog (LOG_DEBUG, "%s: giaddr: %s", name, inet_ntoa (address));
+  syslog (LOG_DEBUG, "%s: chaddr: %s", name, breq->hwaddr);
+  syslog (LOG_DEBUG, "%s: sname: %s", name, breq->servername);
+  syslog (LOG_DEBUG, "%s: file: %s", name, breq->bootfile);
     
-    syslog (LOG_DEBUG, "%s: hwaddr: %s", name, breq->hwaddr);
-    syslog (LOG_DEBUG, "%s: servername: %s", name, breq->servername);
-    syslog (LOG_DEBUG, "%s: bootfile: %s", name, breq->bootfile);
+  optptr = breq->vendor;
+  optend = optptr + DHCP_VENDOR_LENGTH;
+  buf1[0] = '\0';
     
-    vndptr = breq->vendor;
-    sprintf (vendor, "0x%2x 0x%2x 0x%2x 0x%2x", *vndptr++, *vndptr++, *vndptr++, 
*vndptr++);
-    syslog (LOG_DEBUG, "%s: vendor: %s", name, vendor);
+  syslog (LOG_DEBUG, "%s: magic cookie: 0x%2x 0x%2x 0x%2x 0x%2x", name,
+         *optptr++, *optptr++, *optptr++, *optptr++);
     
-    
-    for (; (void *) vndptr < (void *) breq->vendor + DHCP_VENDOR_LENGTH;)
-      {
-       option = *vndptr++;
-       if (option == 0xFF)
-         {
-           sprintf (vendor, "0x%2x", option);
-           vndptr = breq->vendor + DHCP_VENDOR_LENGTH;
-         }
-       else if (option == 0x00)
-         {
-           for (i = 1; *vndptr == 0x00; i++, vndptr++);
-           sprintf (vendor, "0x%2x x %i", option, i);
-         }
-       else
-         {
-           length = *vndptr++;
-           sprintf (vendor, "%3u %3u", option, length);
-           for (i = 0; i < length; i++)
-             {
-               if (strlen (vendor) > 22)
-                 {
-                   syslog (LOG_DEBUG, "%s: vendor: %s", name, vendor);
-                   strcpy (vendor, "++++++");
-                 }
-               snprintf (vendor2, 27, "%s 0x%2x", vendor, *vndptr++);
-               strcpy (vendor, vendor2);
-               
-             }
-         }
-       
-       syslog (LOG_DEBUG, "%s: vendor: %s", name, vendor);
+  while (optptr < optend) {
+    option = *optptr++;
+    if (option == BOOTP_OPTION_END) {
+      strcat (buf1, "[END] ");
+      optptr = optend;
+    }
+    else if (option == BOOTP_OPTION_PAD) {
+      for (i = 1; *optptr == BOOTP_OPTION_PAD; i++, optptr++)
+       ;
+      snprintf (buf1, 79, "[PAD x %i] ", i);
+    }
+    else {
+      length = *optptr++;
+      snprintf (buf1, 79, "[%u %u", option, length);
+      for (i = 0; i < length; i++) {
+       if (strlen(buf1) > 42) {
+         syslog (LOG_DEBUG, "%s: options: %s", name, buf1);
+         buf1[0] = '\0';
+       }
+       snprintf (buf2, 79, "%s 0x%02x", buf1, *optptr++);
+       strcpy (buf1, buf2);
       }
-
-    return;
-
+      strcat (buf1, "] ");
+    }
+    if (strlen(buf1) > 30) {
+      syslog (LOG_DEBUG, "%s: options: %s", name, buf1);
+      buf1[0] = '\0';
+    }
+  }
+  
+  
+  return;
 }
 
+
 static char * handleTransaction(int s, struct pumpOverrideInfo * override, 
                                struct bootpRequest * breq,
                                struct bootpRequest * bresp, 



/bart
-- 
caffeine low .... brain halted

-- 
To unsubscribe:
mail -s unsubscribe [EMAIL PROTECTED] < /dev/null

Reply via email to