bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 60/68] device/net_io.c: remove forward declarations


From: Marin Ramesa
Subject: [PATCH 60/68] device/net_io.c: remove forward declarations
Date: Fri, 29 Nov 2013 22:54:25 +0100

* device/net_io.c (net_rcv_port, net_hash_entry, net_hash_header): Move structs 
to net_io.h.
(net_do_filter, bpf_do_filter, hash_ent_remove, net_free_dead_infp, 
net_free_dead_entp, bpf_validate, bpf_eq, net_add_q_info, bpf_match): Remove 
forward declarations.
* device/net_io.h (net_do_filter, bpf_do_filter, hash_ent_remove, 
net_free_dead_infp, net_free_dead_entp, bpf_validate, bpf_eq, net_add_q_info, 
bpf_match): Add prototypes.  

---
 device/net_io.c | 115 ----------------------------------------------------
 device/net_io.h | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 122 insertions(+), 115 deletions(-)

diff --git a/device/net_io.c b/device/net_io.c
index 1e3b109..2a18776 100644
--- a/device/net_io.c
+++ b/device/net_io.c
@@ -253,88 +253,10 @@ net_kmsg_more(void)
        }
 }
 
-/*
- *     Packet Filter Data Structures
- *
- *     Each network interface has a set of packet filters
- *     that are run on incoming packets.
- *
- *     Each packet filter may represent a single network
- *     session or multiple network sessions.  For example,
- *     all application level TCP sessions would be represented
- *     by a single packet filter data structure.
- *     
- *     If a packet filter has a single session, we use a
- *     struct net_rcv_port to represent it.  If the packet
- *     filter represents multiple sessions, we use a 
- *     struct net_hash_header to represent it.
- */
-
-/*
- * Each interface has a write port and a set of read ports.
- * Each read port has one or more filters to determine what packets
- * should go to that port.
- */
-
-/*
- * Receive port for net, with packet filter.
- * This data structure by itself represents a packet
- * filter for a single session.
- */
-struct net_rcv_port {
-       queue_chain_t   input;          /* list of input open_descriptors */
-       queue_chain_t   output;         /* list of output open_descriptors */
-       ipc_port_t      rcv_port;       /* port to send packet to */
-       int             rcv_qlimit;     /* port's qlimit */
-       int             rcv_count;      /* number of packets received */
-       int             priority;       /* priority for filter */
-       filter_t        *filter_end;    /* pointer to end of filter */
-       filter_t        filter[NET_MAX_FILTER];
-                                       /* filter operations */
-};
-typedef struct net_rcv_port *net_rcv_port_t;
-
 struct kmem_cache      net_rcv_cache;  /* cache of net_rcv_port structs */
 
-
-#define NET_HASH_SIZE   256
-#define N_NET_HASH      4
-#define N_NET_HASH_KEYS 4
-
-unsigned int bpf_hash (int, unsigned int *);
-
-/*
- * A single hash entry.
- */
-struct net_hash_entry {
-       queue_chain_t   chain;          /* list of entries with same hval */
-#define he_next chain.next
-#define he_prev chain.prev
-       ipc_port_t      rcv_port;       /* destination port */
-       int             rcv_qlimit;     /* qlimit for the port */
-       unsigned int    keys[N_NET_HASH_KEYS];
-};
-typedef struct net_hash_entry *net_hash_entry_t;
-
 struct kmem_cache      net_hash_entry_cache;
 
-/*
- * This structure represents a packet filter with multiple sessions.
- *
- * For example, all application level TCP sessions might be
- * represented by one of these structures.  It looks like a 
- * net_rcv_port struct so that both types can live on the
- * same packet filter queues.
- */
-struct net_hash_header {
-       struct net_rcv_port rcv;
-        int n_keys;                    /* zero if not used */
-        int ref_count;                 /* reference count */
-        net_hash_entry_t table[NET_HASH_SIZE];
-} filter_hash_header[N_NET_HASH];
-
-typedef struct net_hash_header *net_hash_header_t;
-
 decl_simple_lock_data(,net_hash_header_lock)
 
 #define HASH_ITERATE(head, elt) (elt) = (net_hash_entry_t) (head); do {
@@ -342,7 +264,6 @@ decl_simple_lock_data(,net_hash_header_lock)
        (elt) = (net_hash_entry_t) queue_next((queue_entry_t) (elt));      \
        } while ((elt) != (head));
 
-
 #define FILTER_ITERATE(if_port_list, fp, nextfp, chain)        \
        for ((fp) = (net_rcv_port_t) queue_first(if_port_list); \
             !queue_end(if_port_list, (queue_entry_t)(fp));     \
@@ -356,40 +277,6 @@ decl_simple_lock_data(,net_hash_header_lock)
        (dead) = (queue_entry_t)(entry_p);                      \
 }
 
-extern boolean_t net_do_filter();      /* CSPF */
-extern int bpf_do_filter();            /* BPF */
-
-int hash_ent_remove (
-   struct ifnet *ifp,
-   net_hash_header_t hp,
-   int used,
-   net_hash_entry_t *head, 
-       net_hash_entry_t entp,
-   queue_entry_t *dead_p);
-
-void net_free_dead_infp (queue_entry_t dead_infp);
-void net_free_dead_entp (queue_entry_t dead_entp);
-
-int bpf_validate(
-    bpf_insn_t f,
-    int bytes,
-    bpf_insn_t *match);
-
-int bpf_eq (
-    bpf_insn_t f1,
-       bpf_insn_t f2,
-    int bytes);
-
-int net_add_q_info (ipc_port_t rcv_port);
-
-int bpf_match (
-   net_hash_header_t hash,
-   int n_keys,
-   unsigned int *keys,
-   net_hash_entry_t **hash_headpp,
-      net_hash_entry_t *entpp);
-
-
 /*
  *     ethernet_priority:
  *
@@ -1999,7 +1886,6 @@ bpf_hash(
        return (hval % NET_HASH_SIZE);
 }
 
-
 int
 bpf_match(
        net_hash_header_t       hash,
@@ -2035,7 +1921,6 @@ bpf_match(
        return FALSE;
 }      
 
-
 /*
  * Removes a hash entry (ENTP) from its queue (HEAD).
  * If the reference count of filter (HP) becomes zero and not USED,
diff --git a/device/net_io.h b/device/net_io.h
index cbf6845..c950d5d 100644
--- a/device/net_io.h
+++ b/device/net_io.h
@@ -47,6 +47,81 @@
 #include <device/net_status.h>
 
 /*
+ *     Packet Filter Data Structures
+ *
+ *     Each network interface has a set of packet filters
+ *     that are run on incoming packets.
+ *
+ *     Each packet filter may represent a single network
+ *     session or multiple network sessions.  For example,
+ *     all application level TCP sessions would be represented
+ *     by a single packet filter data structure.
+ *     
+ *     If a packet filter has a single session, we use a
+ *     struct net_rcv_port to represent it.  If the packet
+ *     filter represents multiple sessions, we use a 
+ *     struct net_hash_header to represent it.
+ */
+
+/*
+ * Each interface has a write port and a set of read ports.
+ * Each read port has one or more filters to determine what packets
+ * should go to that port.
+ */
+
+/*
+ * Receive port for net, with packet filter.
+ * This data structure by itself represents a packet
+ * filter for a single session.
+ */
+struct net_rcv_port {
+       queue_chain_t   input;          /* list of input open_descriptors */
+       queue_chain_t   output;         /* list of output open_descriptors */
+       ipc_port_t      rcv_port;       /* port to send packet to */
+       int             rcv_qlimit;     /* port's qlimit */
+       int             rcv_count;      /* number of packets received */
+       int             priority;       /* priority for filter */
+       filter_t        *filter_end;    /* pointer to end of filter */
+       filter_t        filter[NET_MAX_FILTER];
+                                       /* filter operations */
+};
+typedef struct net_rcv_port *net_rcv_port_t;
+
+#define NET_HASH_SIZE   256
+#define N_NET_HASH      4
+#define N_NET_HASH_KEYS 4
+
+/*
+ * A single hash entry.
+ */
+struct net_hash_entry {
+       queue_chain_t   chain;          /* list of entries with same hval */
+#define he_next chain.next
+#define he_prev chain.prev
+       ipc_port_t      rcv_port;       /* destination port */
+       int             rcv_qlimit;     /* qlimit for the port */
+       unsigned int    keys[N_NET_HASH_KEYS];
+};
+typedef struct net_hash_entry *net_hash_entry_t;
+
+/*
+ * This structure represents a packet filter with multiple sessions.
+ *
+ * For example, all application level TCP sessions might be
+ * represented by one of these structures.  It looks like a 
+ * net_rcv_port struct so that both types can live on the
+ * same packet filter queues.
+ */
+struct net_hash_header {
+       struct net_rcv_port rcv;
+        int n_keys;                    /* zero if not used */
+        int ref_count;                 /* reference count */
+        net_hash_entry_t table[NET_HASH_SIZE];
+} filter_hash_header[N_NET_HASH];
+
+typedef struct net_hash_header *net_hash_header_t;
+
+/*
  * A network packet is wrapped in a kernel message while in
  * the kernel.
  */
@@ -91,4 +166,51 @@ extern unsigned short int   ntohs(unsigned short int);
 extern unsigned int            htonl(unsigned int);
 extern unsigned short int      htons(unsigned short int);
 
+unsigned int bpf_hash(int n, unsigned int *keys);
+
+int hash_ent_remove(
+    struct ifnet       *ifp,
+    net_hash_header_t  hp,
+    int                used,
+    net_hash_entry_t   *head,
+    net_hash_entry_t   entp,
+    queue_entry_t      *dead_p);
+
+void net_free_dead_infp(queue_entry_t dead_infp);
+void net_free_dead_entp(queue_entry_t dead_entp);
+
+int bpf_validate(
+       bpf_insn_t      f,
+       int             bytes,
+       bpf_insn_t      *match);
+
+int bpf_eq(
+       bpf_insn_t      f1, 
+       bpf_insn_t      f2,
+       int             bytes);
+
+int net_add_q_info(ipc_port_t rcv_port);
+
+int bpf_match(
+       net_hash_header_t       hash,
+       int                     n_keys,
+       unsigned int            *keys,
+       net_hash_entry_t        **hash_headpp, 
+       net_hash_entry_t        *entpp);
+
+extern boolean_t net_do_filter( /* CSPF */
+       net_rcv_port_t  infp,
+       char *          data,
+       unsigned int    data_count,
+       char *          header);
+
+extern int bpf_do_filter( /* BPF */
+       net_rcv_port_t          infp,
+       char *                  p,              
+       unsigned int            wirelen,        
+       char *                  header,
+       unsigned int            hlen,           
+       net_hash_entry_t        **hash_headpp, 
+       net_hash_entry_t        *entpp);
+
 #endif /* _DEVICE_NET_IO_H_ */
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]