Added the new version for dummynet.
[ipfw.git] / glue.h
diff --git a/glue.h b/glue.h
index 86b229a..de0ab23 100644 (file)
--- a/glue.h
+++ b/glue.h
@@ -23,7 +23,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id$
+ * $Id: glue.h 4661 2010-01-04 11:56:12Z luigi $
  *
  * glue code to adapt the FreeBSD version to linux and windows,
  * userland and kernel.
@@ -55,6 +55,7 @@ enum sopt_dir { SOPT_GET, SOPT_SET };
 #include <sys/types.h>         /* for size_t */
 #include <sys/ioctl.h>
 #include <time.h>
+#include <errno.h>
 
 #include <netinet/ether.h>
 
@@ -205,7 +206,7 @@ struct clockinfo {
         int     profhz;         /* profiling clock frequency */
 };
 
-/* 
+/*
  * linux does not have a reentrant version of qsort,
  * so we the FreeBSD stdlib version.
  */
@@ -213,6 +214,20 @@ void
 qsort_r(void *a, size_t n, size_t es, void *thunk,
        int cmp_t(void *, const void *, const void *));
 
+/* prototypes from libutil */
+/* humanize_number(3) */
+#define HN_DECIMAL              0x01
+#define HN_NOSPACE              0x02
+#define HN_B                    0x04
+#define HN_DIVISOR_1000         0x08
+
+#define HN_GETSCALE             0x10
+#define HN_AUTOSCALE            0x20
+
+int     humanize_number(char *_buf, size_t _len, int64_t _number,
+            const char *_suffix, int _scale, int _flags);
+int     expand_number(const char *_buf, int64_t *_num);
+
 #define setprogname(x) /* not present in linux */
 
 extern int optreset;   /* not present in linux */
@@ -226,6 +241,11 @@ int
 sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp,
          size_t newlen);
  
+#ifdef __linux__
+/* linux does not have sin_len in sockaddr, we only remap in userland */
+#define        sin_len sin_zero[0]
+#endif /* __linux__ */
+
 #else /* KERNEL_MODULE */
 
 /* linux and windows kernel do not have bcopy ? */
@@ -235,12 +255,22 @@ sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp,
 #include <linux/in6.h>
 #endif
 
+/* skb_dst() was introduced from linux 2.6.31 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)        // or 2.4.x
+#define skb_dst(_dummy) skb->dst
+#endif
+
 /* definitions useful for the kernel side */
 
 struct route_in6 { };
 
 #endif /* KERNEL_MODULE */
 
+/* missing in netinet/in.h */
+
+#define INET_ADDRSTRLEN                16
+
+
 /*
  * List of values used for set/getsockopt options.
  * The base value on FreeBSD is defined as a macro,
@@ -255,13 +285,17 @@ enum ipfw_msg_type {
        IP_FW_TABLE_FLUSH,
        IP_FW_TABLE_GETSIZE,
        IP_FW_TABLE_LIST,
+       IP_FW_DYN_GET,          /* new addition */
+
+       /* IP_FW3 and IP_DUMMYNET3 are the new API */
+       IP_FW3                  = _IPFW_SOCKOPT_BASE + 8,
+       IP_DUMMYNET3,
 
        IP_FW_ADD               = _IPFW_SOCKOPT_BASE + 10,
        IP_FW_DEL,
        IP_FW_FLUSH,
        IP_FW_ZERO,
        IP_FW_GET,
-       IP_FW_DYN_GET,
        IP_FW_RESETLOG,
 
        IP_FW_NAT_CFG,