]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/net/xfrm.h
ACPI: check a return value correctly in acpi_power_get_context()
[linux-2.6-omap-h63xx.git] / include / net / xfrm.h
index 4e6f9568cbe7271bed9df9085c9328cfe7547a6b..baa9f372cfd165b7496954bef31510990d4190bd 100644 (file)
@@ -121,6 +121,7 @@ extern struct mutex xfrm_cfg_mutex;
 struct xfrm_state
 {
        /* Note: bydst is re-used during gc */
+       struct list_head        all;
        struct hlist_node       bydst;
        struct hlist_node       bysrc;
        struct hlist_node       byspi;
@@ -435,6 +436,9 @@ struct xfrm_tmpl
 /* May skip this transfomration if no SA is found */
        __u8                    optional;
 
+/* Skip aalgos/ealgos/calgos checks. */
+       __u8                    allalgs;
+
 /* Bit mask of algos allowed for acquisition */
        __u32                   aalgos;
        __u32                   ealgos;
@@ -446,6 +450,7 @@ struct xfrm_tmpl
 struct xfrm_policy
 {
        struct xfrm_policy      *next;
+       struct list_head        bytype;
        struct hlist_node       bydst;
        struct hlist_node       byidx;
 
@@ -552,6 +557,9 @@ struct xfrm_mode_skb_cb {
        __be16 id;
        __be16 frag_off;
 
+       /* IP header length (excluding options or extension headers). */
+       u8 ihl;
+
        /* TOS for IPv4, class for IPv6. */
        u8 tos;
 
@@ -561,6 +569,9 @@ struct xfrm_mode_skb_cb {
        /* Protocol for IPv4, NH for IPv6. */
        u8 protocol;
 
+       /* Option length for IPv4, zero for IPv6. */
+       u8 optlen;
+
        /* Used by IPv6 only, zero for IPv4. */
        u8 flow_lbl[3];
 };
@@ -1065,6 +1076,23 @@ xfrm_address_t *xfrm_flowi_saddr(struct flowi *fl, unsigned short family)
        return NULL;
 }
 
+static __inline__
+void xfrm_flowi_addr_get(struct flowi *fl,
+                        xfrm_address_t *saddr, xfrm_address_t *daddr,
+                        unsigned short family)
+{
+       switch(family) {
+       case AF_INET:
+               memcpy(&saddr->a4, &fl->fl4_src, sizeof(saddr->a4));
+               memcpy(&daddr->a4, &fl->fl4_dst, sizeof(daddr->a4));
+               break;
+       case AF_INET6:
+               ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->fl6_src);
+               ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->fl6_dst);
+               break;
+       }
+}
+
 static __inline__ int
 __xfrm4_state_addr_check(struct xfrm_state *x,
                         xfrm_address_t *daddr, xfrm_address_t *saddr)
@@ -1182,6 +1210,18 @@ struct xfrm6_tunnel {
        int priority;
 };
 
+struct xfrm_state_walk {
+       struct xfrm_state *state;
+       int count;
+       u8 proto;
+};
+
+struct xfrm_policy_walk {
+       struct xfrm_policy *policy;
+       int count;
+       u8 type, cur_type;
+};
+
 extern void xfrm_init(void);
 extern void xfrm4_init(void);
 extern void xfrm_state_init(void);
@@ -1206,7 +1246,23 @@ static inline void xfrm6_fini(void)
 extern int xfrm_proc_init(void);
 #endif
 
-extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *);
+static inline void xfrm_state_walk_init(struct xfrm_state_walk *walk, u8 proto)
+{
+       walk->proto = proto;
+       walk->state = NULL;
+       walk->count = 0;
+}
+
+static inline void xfrm_state_walk_done(struct xfrm_state_walk *walk)
+{
+       if (walk->state != NULL) {
+               xfrm_state_put(walk->state);
+               walk->state = NULL;
+       }
+}
+
+extern int xfrm_state_walk(struct xfrm_state_walk *walk,
+                          int (*func)(struct xfrm_state *, int, void*), void *);
 extern struct xfrm_state *xfrm_state_alloc(void);
 extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, 
                                          struct flowi *fl, struct xfrm_tmpl *tmpl,
@@ -1329,7 +1385,25 @@ static inline int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb)
 #endif
 
 struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp);
-extern int xfrm_policy_walk(u8 type, int (*func)(struct xfrm_policy *, int, int, void*), void *);
+
+static inline void xfrm_policy_walk_init(struct xfrm_policy_walk *walk, u8 type)
+{
+       walk->cur_type = XFRM_POLICY_TYPE_MAIN;
+       walk->type = type;
+       walk->policy = NULL;
+       walk->count = 0;
+}
+
+static inline void xfrm_policy_walk_done(struct xfrm_policy_walk *walk)
+{
+       if (walk->policy != NULL) {
+               xfrm_pol_put(walk->policy);
+               walk->policy = NULL;
+       }
+}
+
+extern int xfrm_policy_walk(struct xfrm_policy_walk *walk,
+       int (*func)(struct xfrm_policy *, int, int, void*), void *);
 int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl);
 struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir,
                                          struct xfrm_selector *sel,