[email protected]
[Top] [All Lists]

PERFORCE change 114230 for review

Subject: PERFORCE change 114230 for review
From: Paolo Pisati
Date: Thu, 8 Feb 2007 08:49:50 GMT
http://perforce.freebsd.org/chv.cgi?CH=114230

Change 114230 by [email protected]_newluxor on 2007/02/08 08:49:42

        o redefine mtod() -> MYMTOD() and correctly check for NULL value after 
an m_pullup()
        o add a new PULLUP macro (PULLUP_SIZE()) to m_pullup() an arbitrary num 
of bytes

Affected files ...

.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_local.h#23 edit

Differences ...

==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_local.h#23 
(text+ko) ====

@@ -179,27 +179,29 @@
 #ifdef _KERNEL
 typedef struct mbuf ** pkt_t;
 
+#define MYMTOD(p, foo) (p != NULL) ? mtod(p, foo) : NULL
+
 #define PULLUP_IPHDR(pip, ptr) do {             \
        *ptr = m_pullup((*ptr), sizeof(struct ip)); \
-        (pip) = mtod(*ptr, struct ip *);           \
+        (pip) = MYMTOD(*ptr, struct ip *);           \
 } while (0)
 
 #define PULLUP_UDPHDR(pip, ptr) do {            \
        pip = mtod(*ptr, struct ip *);             \
        *ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct udphdr)); \
-       (pip) = mtod(*ptr, struct ip *);           \
+       (pip) = MYMTOD(*ptr, struct ip *);           \
 } while (0)
 
 #define PULLUP_TCPHDR(pip, ptr) do {            \
        pip = mtod(*ptr, struct ip *);             \
        *ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct tcphdr)); \
-       (pip) = mtod(*ptr, struct ip *);           \
+       (pip) = MYMTOD(*ptr, struct ip *);           \
 } while (0)
 
 #define PULLUP_ICMPHDR(pip, ptr) do {           \
        pip = mtod(*ptr, struct ip *);           \
        *ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct icmp)); \
-       (pip) = mtod(*ptr, struct ip *);           \
+       (pip) = MYMTOD(*ptr, struct ip *);           \
 } while (0)
 
 #define PULLUP_ICMPIP64(pip, ptr, ic) do {      \
@@ -208,26 +210,32 @@
         s = (pip->ip_hl << 2) + sizeof(struct icmp) + \
             (ic->icmp_ip.ip_hl << 2) - sizeof(struct ip) + 8; \
        *ptr = m_pullup((*ptr), s);                 \
-       (pip) = mtod(*ptr, struct ip *);           \
+       (pip) = MYMTOD(*ptr, struct ip *);           \
 } while (0)
 
 #define PULLUP_IPTCPHDR(pip, ptr) do {          \
        *ptr = m_pullup((*ptr), sizeof(struct ip)); \
-        (pip) = mtod(*ptr, struct ip *);           \
+        (pip) = MYMTOD(*ptr, struct ip *);           \
         if (pip != NULL) {                       \
                 *ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct 
tcphdr)); \
-               (pip) = mtod(*ptr, struct ip *);           \
+               (pip) = MYMTOD(*ptr, struct ip *);           \
         }                                       \
 } while (0)
 
 #define PULLUP_IPUDPHDR(pip, ptr) do {          \
        *ptr = m_pullup((*ptr), sizeof(struct ip)); \
-        (pip) = mtod(*ptr, struct ip *);           \
+        (pip) = MYMTOD(*ptr, struct ip *);           \
         if (pip != NULL) {                       \
                 *ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct 
udphdr)); \
-               (pip) = mtod(*ptr, struct ip *);           \
+               (pip) = MYMTOD(*ptr, struct ip *);           \
         }                                       \
 } while (0)
+
+#define PULLUP_SIZE(pip, ptr, s) do {           \
+        *ptr = m_pullup((*ptr), s);             \
+        (pip) = MYMTOD(*ptr, struct ip *);        \
+} while (0)
+
 #else
 typedef char * pkt_t;
 
@@ -238,6 +246,7 @@
 #define PULLUP_ICMPIP64(pip, ptr, ic) pip = (struct ip *)ptr
 #define PULLUP_IPTCPHDR(pip, ptr) pip = (struct ip *)ptr
 #define PULLUP_IPUDPHDR(pip, ptr) pip = (struct ip *)ptr
+#define PULLUP_SIZE(pip, ptr, s) pip = (struct ip *)ptr
 #endif
 
 /*
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/p4-projects
To unsubscribe, send any mail to "[email protected]"

<Prev in Thread] Current Thread [Next in Thread>
  • PERFORCE change 114230 for review, Paolo Pisati <=