Reverted the changes to the log() function, deleting the void* cast. The problem...
[ipfw.git] / dummynet / missing.h
index 1d2f2ec..5b04dce 100644 (file)
@@ -33,6 +33,8 @@
 #ifndef _MISSING_H_
 #define _MISSING_H_
 
+#include <sys/cdefs.h>
+
 #ifdef _WIN32
 
 #ifndef DEFINE_SPINLOCK
@@ -50,6 +52,7 @@
 
 #else  /* __linux__ */
 
+#define MALLOC_DECLARE(x)      /* nothing */
 #include <linux/time.h>                /* do_gettimeofday */
 #include <netinet/ip.h>                /* local version */
 struct inpcb;
@@ -75,6 +78,7 @@ struct inpcb;
 #define rw_runlock(_l)         spin_unlock_bh(_l)
 #define rw_wlock(_l)           spin_lock_bh(_l)
 #define rw_wunlock(_l)         spin_unlock_bh(_l)
+#define rw_init_flags(_l, s, v)
 
 #define mtx_assert(a, b)
 #define        mtx_destroy(m)
@@ -121,7 +125,11 @@ struct malloc_type {
 
 #define CTASSERT(x)
 
-#define log(_level, fmt, arg...)  printk(KERN_ERR fmt, ##arg)
+/* log... does not use the first argument */
+#define        LOG_ERR         0x100
+#define        LOG_INFO        0x200
+#define log(_level, fmt, arg...)  do {                 \
+       int __unused x=_level;printk(KERN_ERR fmt, ##arg); } while (0)
 
 /*
  * gettimeofday would be in sys/time.h but it is not
@@ -262,6 +270,10 @@ int in_cksum(struct mbuf *m, int len);
 #define INADDR_TO_IFP(a, b) b = NULL
 #define pf_find_mtag(a) NULL
 #define pf_get_mtag(a) NULL
+/* we don't pullup, fail */
+#define m_pullup(m, x)                                 \
+       ((m)->m_len >= x ? (m) : (netisr_dispatch(-1, m), NULL))
+
 #ifndef _WIN32
 #define AF_LINK AF_ASH /* ? our sys/socket.h */
 #endif
@@ -346,6 +358,17 @@ int sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen);
 /* defined in session.c */
 int priv_check(struct thread *td, int priv);
 
+/* struct ucred is in linux/socket.h and has pid, uid, gid.
+ * We need a 'bsd_ucred' to store also the extra info
+ */
+
+struct bsd_ucred {
+       uid_t           uid;
+       gid_t           gid;
+       uint32_t        xid;
+       uint32_t        nid;
+};
+
 int securelevel_ge(struct ucred *cr, int level);
 
 struct sysctl_oid;
@@ -363,6 +386,23 @@ struct sysctl_req;
 #ifdef _WIN32
 #define module_param_named(_name, _var, _ty, _perm)
 #else
+
+/* Linux 2.4 is mostly for openwrt */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+#include <linux/bitops.h>       /* generic_ffs() used in ip_fw2.c */
+typedef uint32_t __be32;
+typedef uint16_t __be16;
+struct sock;
+struct net;
+struct inet_hashinfo;
+struct sock *inet_lookup(
+       struct inet_hashinfo *hashinfo,
+        const __be32 saddr, const __be16 sport,
+        const __be32 daddr, const __be16 dport,
+        const int dif);
+struct sock *tcp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport, int dif);
+#endif /* Linux < 2.6 */
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
 #define module_param_named(_name, _var, _ty, _perm)    \
        //module_param(_name, _ty, 0644)
@@ -387,7 +427,7 @@ struct sysctl_req;
        _SYSCTL_BASE(_name, _var, ulong, _mode)
 
 #define SYSCTL_UINT(_base, _oid, _name, _mode, _var, _val, _desc)      \
-       // _SYSCTL_BASE(_name, _var, uint, _mode)
+        _SYSCTL_BASE(_name, _var, uint, _mode)
 
 #define SYSCTL_HANDLER_ARGS            \
        struct sysctl_oid *oidp, void *arg1, int arg2, struct sysctl_req *req
@@ -413,8 +453,6 @@ u_short in_cksum_skip(struct mbuf *m, int len, int skip);
 #define INP_LOCK_ASSERT(a)
 #endif
 
-int rn_inithead(void **head, int off);
-
 int jailed(struct ucred *cred);
 
 /*
@@ -430,11 +468,10 @@ int in_localaddr(struct in_addr in);
 
 int fnmatch(const char *pattern, const char *string, int flags);
 
-struct ip_fw_ugid;
 int
 linux_lookup(const int proto, const __be32 saddr, const __be16 sport,
        const __be32 daddr, const __be16 dport,
-       struct sk_buff *skb, int dir, struct ip_fw_ugid *ugp);
+       struct sk_buff *skb, int dir, struct bsd_ucred *u);
 
 /* vnet wrappers, in vnet.h and ip_var.h */
 int ipfw_init(void);
@@ -477,4 +514,6 @@ extern  ip_fw_chk_t     *ip_fw_chk_ptr;
 #define SYSCTL_VNET_PROC       SYSCTL_PROC
 #define SYSCTL_VNET_INT                SYSCTL_INT
 
+int my_mod_register(struct moduledata *mod, const char *name, int order);
+
 #endif /* !_MISSING_H_ */