fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / linux / xfrm.h
index 430370b..9529ea1 100644 (file)
@@ -12,8 +12,8 @@
  */
 typedef union
 {
-       __u32           a4;
-       __u32           a6[4];
+       __be32          a4;
+       __be32          a6[4];
 } xfrm_address_t;
 
 /* Ident of a specific xfrm_state. It is used on input to lookup
@@ -23,20 +23,36 @@ typedef union
 struct xfrm_id
 {
        xfrm_address_t  daddr;
-       __u32           spi;
+       __be32          spi;
        __u8            proto;
 };
 
+struct xfrm_sec_ctx {
+       __u8    ctx_doi;
+       __u8    ctx_alg;
+       __u16   ctx_len;
+       __u32   ctx_sid;
+       char    ctx_str[0];
+};
+
+/* Security Context Domains of Interpretation */
+#define XFRM_SC_DOI_RESERVED 0
+#define XFRM_SC_DOI_LSM 1
+
+/* Security Context Algorithms */
+#define XFRM_SC_ALG_RESERVED 0
+#define XFRM_SC_ALG_SELINUX 1
+
 /* Selector, used as selector both on policy rules (SPD) and SAs. */
 
 struct xfrm_selector
 {
        xfrm_address_t  daddr;
        xfrm_address_t  saddr;
-       __u16   dport;
-       __u16   dport_mask;
-       __u16   sport;
-       __u16   sport_mask;
+       __be16  dport;
+       __be16  dport_mask;
+       __be16  sport;
+       __be16  sport_mask;
        __u16   family;
        __u8    prefixlen_d;
        __u8    prefixlen_s;
@@ -86,6 +102,13 @@ struct xfrm_stats {
        __u32   integrity_failed;
 };
 
+enum
+{
+       XFRM_POLICY_TYPE_MAIN   = 0,
+       XFRM_POLICY_TYPE_SUB    = 1,
+       XFRM_POLICY_TYPE_MAX    = 2
+};
+
 enum
 {
        XFRM_POLICY_IN  = 0,
@@ -102,27 +125,76 @@ enum
        XFRM_SHARE_UNIQUE       /* Use once */
 };
 
-/* Netlink configuration messages.  */
-#define XFRM_MSG_BASE          0x10
+#define XFRM_MODE_TRANSPORT 0
+#define XFRM_MODE_TUNNEL 1
+#define XFRM_MODE_ROUTEOPTIMIZATION 2
+#define XFRM_MODE_IN_TRIGGER 3
+#define XFRM_MODE_BEET 4
+#define XFRM_MODE_MAX 5
 
-#define XFRM_MSG_NEWSA         (XFRM_MSG_BASE + 0)
-#define XFRM_MSG_DELSA         (XFRM_MSG_BASE + 1)
-#define XFRM_MSG_GETSA         (XFRM_MSG_BASE + 2)
-
-#define XFRM_MSG_NEWPOLICY     (XFRM_MSG_BASE + 3)
-#define XFRM_MSG_DELPOLICY     (XFRM_MSG_BASE + 4)
-#define XFRM_MSG_GETPOLICY     (XFRM_MSG_BASE + 5)
-
-#define XFRM_MSG_ALLOCSPI      (XFRM_MSG_BASE + 6)
-#define XFRM_MSG_ACQUIRE       (XFRM_MSG_BASE + 7)
-#define XFRM_MSG_EXPIRE                (XFRM_MSG_BASE + 8)
-
-#define XFRM_MSG_UPDPOLICY     (XFRM_MSG_BASE + 9)
-#define XFRM_MSG_UPDSA         (XFRM_MSG_BASE + 10)
+/* Netlink configuration messages.  */
+enum {
+       XFRM_MSG_BASE = 0x10,
+
+       XFRM_MSG_NEWSA = 0x10,
+#define XFRM_MSG_NEWSA XFRM_MSG_NEWSA
+       XFRM_MSG_DELSA,
+#define XFRM_MSG_DELSA XFRM_MSG_DELSA
+       XFRM_MSG_GETSA,
+#define XFRM_MSG_GETSA XFRM_MSG_GETSA
+
+       XFRM_MSG_NEWPOLICY,
+#define XFRM_MSG_NEWPOLICY XFRM_MSG_NEWPOLICY
+       XFRM_MSG_DELPOLICY,
+#define XFRM_MSG_DELPOLICY XFRM_MSG_DELPOLICY
+       XFRM_MSG_GETPOLICY,
+#define XFRM_MSG_GETPOLICY XFRM_MSG_GETPOLICY
+
+       XFRM_MSG_ALLOCSPI,
+#define XFRM_MSG_ALLOCSPI XFRM_MSG_ALLOCSPI
+       XFRM_MSG_ACQUIRE,
+#define XFRM_MSG_ACQUIRE XFRM_MSG_ACQUIRE
+       XFRM_MSG_EXPIRE,
+#define XFRM_MSG_EXPIRE XFRM_MSG_EXPIRE
+
+       XFRM_MSG_UPDPOLICY,
+#define XFRM_MSG_UPDPOLICY XFRM_MSG_UPDPOLICY
+       XFRM_MSG_UPDSA,
+#define XFRM_MSG_UPDSA XFRM_MSG_UPDSA
+
+       XFRM_MSG_POLEXPIRE,
+#define XFRM_MSG_POLEXPIRE XFRM_MSG_POLEXPIRE
+
+       XFRM_MSG_FLUSHSA,
+#define XFRM_MSG_FLUSHSA XFRM_MSG_FLUSHSA
+       XFRM_MSG_FLUSHPOLICY,
+#define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY
+
+       XFRM_MSG_NEWAE,
+#define XFRM_MSG_NEWAE XFRM_MSG_NEWAE
+       XFRM_MSG_GETAE,
+#define XFRM_MSG_GETAE XFRM_MSG_GETAE
+
+       XFRM_MSG_REPORT,
+#define XFRM_MSG_REPORT XFRM_MSG_REPORT
+
+       __XFRM_MSG_MAX
+};
+#define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
 
-#define XFRM_MSG_POLEXPIRE     (XFRM_MSG_BASE + 11)
+#define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)
 
-#define XFRM_MSG_MAX           (XFRM_MSG_POLEXPIRE+1)
+/*
+ * Generic LSM security context for comunicating to user space
+ * NOTE: Same format as sadb_x_sec_ctx
+ */
+struct xfrm_user_sec_ctx {
+       __u16                   len;
+       __u16                   exttype;
+       __u8                    ctx_alg;  /* LSMs: e.g., selinux == 1 */
+       __u8                    ctx_doi;
+       __u16                   ctx_len;
+};
 
 struct xfrm_user_tmpl {
        struct xfrm_id          id;
@@ -139,11 +211,32 @@ struct xfrm_user_tmpl {
 
 struct xfrm_encap_tmpl {
        __u16           encap_type;
-       __u16           encap_sport;
-       __u16           encap_dport;
+       __be16          encap_sport;
+       __be16          encap_dport;
        xfrm_address_t  encap_oa;
 };
 
+/* AEVENT flags  */
+enum xfrm_ae_ftype_t {
+       XFRM_AE_UNSPEC,
+       XFRM_AE_RTHR=1, /* replay threshold*/
+       XFRM_AE_RVAL=2, /* replay value */
+       XFRM_AE_LVAL=4, /* lifetime value */
+       XFRM_AE_ETHR=8, /* expiry timer threshold */
+       XFRM_AE_CR=16, /* Event cause is replay update */
+       XFRM_AE_CE=32, /* Event cause is timer expiry */
+       XFRM_AE_CU=64, /* Event cause is policy update */
+       __XFRM_AE_MAX
+
+#define XFRM_AE_MAX (__XFRM_AE_MAX - 1)
+};
+
+struct xfrm_userpolicy_type {
+       __u8            type;
+       __u16           reserved1;
+       __u8            reserved2;
+};
+
 /* Netlink message attributes.  */
 enum xfrm_attr_type_t {
        XFRMA_UNSPEC,
@@ -152,8 +245,20 @@ enum xfrm_attr_type_t {
        XFRMA_ALG_COMP,         /* struct xfrm_algo */
        XFRMA_ENCAP,            /* struct xfrm_algo + struct xfrm_encap_tmpl */
        XFRMA_TMPL,             /* 1 or more struct xfrm_user_tmpl */
-
-#define XFRMA_MAX XFRMA_TMPL
+       XFRMA_SA,
+       XFRMA_POLICY,
+       XFRMA_SEC_CTX,          /* struct xfrm_sec_ctx */
+       XFRMA_LTIME_VAL,
+       XFRMA_REPLAY_VAL,
+       XFRMA_REPLAY_THRESH,
+       XFRMA_ETIMER_THRESH,
+       XFRMA_SRCADDR,          /* xfrm_address_t */
+       XFRMA_COADDR,           /* xfrm_address_t */
+       XFRMA_LASTUSED,
+       XFRMA_POLICY_TYPE,      /* struct xfrm_userpolicy_type */
+       __XFRMA_MAX
+
+#define XFRMA_MAX (__XFRMA_MAX - 1)
 };
 
 struct xfrm_usersa_info {
@@ -166,19 +271,29 @@ struct xfrm_usersa_info {
        __u32                           seq;
        __u32                           reqid;
        __u16                           family;
-       __u8                            mode; /* 0=transport,1=tunnel */
+       __u8                            mode;           /* XFRM_MODE_xxx */
        __u8                            replay_window;
        __u8                            flags;
 #define XFRM_STATE_NOECN       1
+#define XFRM_STATE_DECAP_DSCP  2
+#define XFRM_STATE_NOPMTUDISC  4
+#define XFRM_STATE_WILDRECV    8
 };
 
 struct xfrm_usersa_id {
        xfrm_address_t                  daddr;
-       __u32                           spi;
+       __be32                          spi;
        __u16                           family;
        __u8                            proto;
 };
 
+struct xfrm_aevent_id {
+       struct xfrm_usersa_id           sa_id;
+       xfrm_address_t                  saddr;
+       __u32                           flags;
+       __u32                           reqid;
+};
+
 struct xfrm_userspi_info {
        struct xfrm_usersa_info         info;
        __u32                           min;
@@ -227,7 +342,41 @@ struct xfrm_user_polexpire {
        __u8                            hard;
 };
 
+struct xfrm_usersa_flush {
+       __u8                            proto;
+};
+
+struct xfrm_user_report {
+       __u8                            proto;
+       struct xfrm_selector            sel;
+};
+
+#ifndef __KERNEL__
+/* backwards compatibility for userspace */
 #define XFRMGRP_ACQUIRE                1
 #define XFRMGRP_EXPIRE         2
+#define XFRMGRP_SA             4
+#define XFRMGRP_POLICY         8
+#define XFRMGRP_REPORT         0x20
+#endif
+
+enum xfrm_nlgroups {
+       XFRMNLGRP_NONE,
+#define XFRMNLGRP_NONE         XFRMNLGRP_NONE
+       XFRMNLGRP_ACQUIRE,
+#define XFRMNLGRP_ACQUIRE      XFRMNLGRP_ACQUIRE
+       XFRMNLGRP_EXPIRE,
+#define XFRMNLGRP_EXPIRE       XFRMNLGRP_EXPIRE
+       XFRMNLGRP_SA,
+#define XFRMNLGRP_SA           XFRMNLGRP_SA
+       XFRMNLGRP_POLICY,
+#define XFRMNLGRP_POLICY       XFRMNLGRP_POLICY
+       XFRMNLGRP_AEVENTS,
+#define XFRMNLGRP_AEVENTS      XFRMNLGRP_AEVENTS
+       XFRMNLGRP_REPORT,
+#define XFRMNLGRP_REPORT       XFRMNLGRP_REPORT
+       __XFRMNLGRP_MAX
+};
+#define XFRMNLGRP_MAX  (__XFRMNLGRP_MAX - 1)
 
 #endif /* _LINUX_XFRM_H */