linux/include/uapi/linux/xfrm.h
<<
>>
Prefs
   1#ifndef _LINUX_XFRM_H
   2#define _LINUX_XFRM_H
   3
   4#include <linux/in6.h>
   5#include <linux/types.h>
   6
   7/* All of the structures in this file may not change size as they are
   8 * passed into the kernel from userspace via netlink sockets.
   9 */
  10
  11/* Structure to encapsulate addresses. I do not want to use
  12 * "standard" structure. My apologies.
  13 */
  14typedef union {
  15        __be32          a4;
  16        __be32          a6[4];
  17#ifndef __GENKSYMS__
  18        struct in6_addr in6;
  19#endif
  20} xfrm_address_t;
  21
  22/* Ident of a specific xfrm_state. It is used on input to lookup
  23 * the state by (spi,daddr,ah/esp) or to store information about
  24 * spi, protocol and tunnel address on output.
  25 */
  26struct xfrm_id {
  27        xfrm_address_t  daddr;
  28        __be32          spi;
  29        __u8            proto;
  30};
  31
  32struct xfrm_sec_ctx {
  33        __u8    ctx_doi;
  34        __u8    ctx_alg;
  35        __u16   ctx_len;
  36        __u32   ctx_sid;
  37        char    ctx_str[0];
  38};
  39
  40/* Security Context Domains of Interpretation */
  41#define XFRM_SC_DOI_RESERVED 0
  42#define XFRM_SC_DOI_LSM 1
  43
  44/* Security Context Algorithms */
  45#define XFRM_SC_ALG_RESERVED 0
  46#define XFRM_SC_ALG_SELINUX 1
  47
  48/* Selector, used as selector both on policy rules (SPD) and SAs. */
  49
  50struct xfrm_selector {
  51        xfrm_address_t  daddr;
  52        xfrm_address_t  saddr;
  53        __be16  dport;
  54        __be16  dport_mask;
  55        __be16  sport;
  56        __be16  sport_mask;
  57        __u16   family;
  58        __u8    prefixlen_d;
  59        __u8    prefixlen_s;
  60        __u8    proto;
  61        int     ifindex;
  62        __kernel_uid32_t        user;
  63};
  64
  65#define XFRM_INF (~(__u64)0)
  66
  67struct xfrm_lifetime_cfg {
  68        __u64   soft_byte_limit;
  69        __u64   hard_byte_limit;
  70        __u64   soft_packet_limit;
  71        __u64   hard_packet_limit;
  72        __u64   soft_add_expires_seconds;
  73        __u64   hard_add_expires_seconds;
  74        __u64   soft_use_expires_seconds;
  75        __u64   hard_use_expires_seconds;
  76};
  77
  78struct xfrm_lifetime_cur {
  79        __u64   bytes;
  80        __u64   packets;
  81        __u64   add_time;
  82        __u64   use_time;
  83};
  84
  85struct xfrm_replay_state {
  86        __u32   oseq;
  87        __u32   seq;
  88        __u32   bitmap;
  89};
  90
  91#define XFRMA_REPLAY_ESN_MAX    4096
  92
  93struct xfrm_replay_state_esn {
  94        unsigned int    bmp_len;
  95        __u32           oseq;
  96        __u32           seq;
  97        __u32           oseq_hi;
  98        __u32           seq_hi;
  99        __u32           replay_window;
 100        __u32           bmp[0];
 101};
 102
 103struct xfrm_algo {
 104        char            alg_name[64];
 105        unsigned int    alg_key_len;    /* in bits */
 106        char            alg_key[0];
 107};
 108
 109struct xfrm_algo_auth {
 110        char            alg_name[64];
 111        unsigned int    alg_key_len;    /* in bits */
 112        unsigned int    alg_trunc_len;  /* in bits */
 113        char            alg_key[0];
 114};
 115
 116struct xfrm_algo_aead {
 117        char            alg_name[64];
 118        unsigned int    alg_key_len;    /* in bits */
 119        unsigned int    alg_icv_len;    /* in bits */
 120        char            alg_key[0];
 121};
 122
 123struct xfrm_stats {
 124        __u32   replay_window;
 125        __u32   replay;
 126        __u32   integrity_failed;
 127};
 128
 129enum {
 130        XFRM_POLICY_TYPE_MAIN   = 0,
 131        XFRM_POLICY_TYPE_SUB    = 1,
 132        XFRM_POLICY_TYPE_MAX    = 2,
 133        XFRM_POLICY_TYPE_ANY    = 255
 134};
 135
 136enum {
 137        XFRM_POLICY_IN  = 0,
 138        XFRM_POLICY_OUT = 1,
 139        XFRM_POLICY_FWD = 2,
 140        XFRM_POLICY_MASK = 3,
 141        XFRM_POLICY_MAX = 3
 142};
 143
 144enum {
 145        XFRM_SHARE_ANY,         /* No limitations */
 146        XFRM_SHARE_SESSION,     /* For this session only */
 147        XFRM_SHARE_USER,        /* For this user only */
 148        XFRM_SHARE_UNIQUE       /* Use once */
 149};
 150
 151#define XFRM_MODE_TRANSPORT 0
 152#define XFRM_MODE_TUNNEL 1
 153#define XFRM_MODE_ROUTEOPTIMIZATION 2
 154#define XFRM_MODE_IN_TRIGGER 3
 155#define XFRM_MODE_BEET 4
 156#define XFRM_MODE_MAX 5
 157
 158/* Netlink configuration messages.  */
 159enum {
 160        XFRM_MSG_BASE = 0x10,
 161
 162        XFRM_MSG_NEWSA = 0x10,
 163#define XFRM_MSG_NEWSA XFRM_MSG_NEWSA
 164        XFRM_MSG_DELSA,
 165#define XFRM_MSG_DELSA XFRM_MSG_DELSA
 166        XFRM_MSG_GETSA,
 167#define XFRM_MSG_GETSA XFRM_MSG_GETSA
 168
 169        XFRM_MSG_NEWPOLICY,
 170#define XFRM_MSG_NEWPOLICY XFRM_MSG_NEWPOLICY
 171        XFRM_MSG_DELPOLICY,
 172#define XFRM_MSG_DELPOLICY XFRM_MSG_DELPOLICY
 173        XFRM_MSG_GETPOLICY,
 174#define XFRM_MSG_GETPOLICY XFRM_MSG_GETPOLICY
 175
 176        XFRM_MSG_ALLOCSPI,
 177#define XFRM_MSG_ALLOCSPI XFRM_MSG_ALLOCSPI
 178        XFRM_MSG_ACQUIRE,
 179#define XFRM_MSG_ACQUIRE XFRM_MSG_ACQUIRE
 180        XFRM_MSG_EXPIRE,
 181#define XFRM_MSG_EXPIRE XFRM_MSG_EXPIRE
 182
 183        XFRM_MSG_UPDPOLICY,
 184#define XFRM_MSG_UPDPOLICY XFRM_MSG_UPDPOLICY
 185        XFRM_MSG_UPDSA,
 186#define XFRM_MSG_UPDSA XFRM_MSG_UPDSA
 187
 188        XFRM_MSG_POLEXPIRE,
 189#define XFRM_MSG_POLEXPIRE XFRM_MSG_POLEXPIRE
 190
 191        XFRM_MSG_FLUSHSA,
 192#define XFRM_MSG_FLUSHSA XFRM_MSG_FLUSHSA
 193        XFRM_MSG_FLUSHPOLICY,
 194#define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY
 195
 196        XFRM_MSG_NEWAE,
 197#define XFRM_MSG_NEWAE XFRM_MSG_NEWAE
 198        XFRM_MSG_GETAE,
 199#define XFRM_MSG_GETAE XFRM_MSG_GETAE
 200
 201        XFRM_MSG_REPORT,
 202#define XFRM_MSG_REPORT XFRM_MSG_REPORT
 203
 204        XFRM_MSG_MIGRATE,
 205#define XFRM_MSG_MIGRATE XFRM_MSG_MIGRATE
 206
 207        XFRM_MSG_NEWSADINFO,
 208#define XFRM_MSG_NEWSADINFO XFRM_MSG_NEWSADINFO
 209        XFRM_MSG_GETSADINFO,
 210#define XFRM_MSG_GETSADINFO XFRM_MSG_GETSADINFO
 211
 212        XFRM_MSG_NEWSPDINFO,
 213#define XFRM_MSG_NEWSPDINFO XFRM_MSG_NEWSPDINFO
 214        XFRM_MSG_GETSPDINFO,
 215#define XFRM_MSG_GETSPDINFO XFRM_MSG_GETSPDINFO
 216
 217        XFRM_MSG_MAPPING,
 218#define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
 219        __XFRM_MSG_MAX
 220};
 221#define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
 222
 223#define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)
 224
 225/*
 226 * Generic LSM security context for comunicating to user space
 227 * NOTE: Same format as sadb_x_sec_ctx
 228 */
 229struct xfrm_user_sec_ctx {
 230        __u16                   len;
 231        __u16                   exttype;
 232        __u8                    ctx_alg;  /* LSMs: e.g., selinux == 1 */
 233        __u8                    ctx_doi;
 234        __u16                   ctx_len;
 235};
 236
 237struct xfrm_user_tmpl {
 238        struct xfrm_id          id;
 239        __u16                   family;
 240        xfrm_address_t          saddr;
 241        __u32                   reqid;
 242        __u8                    mode;
 243        __u8                    share;
 244        __u8                    optional;
 245        __u32                   aalgos;
 246        __u32                   ealgos;
 247        __u32                   calgos;
 248};
 249
 250struct xfrm_encap_tmpl {
 251        __u16           encap_type;
 252        __be16          encap_sport;
 253        __be16          encap_dport;
 254        xfrm_address_t  encap_oa;
 255};
 256
 257/* AEVENT flags  */
 258enum xfrm_ae_ftype_t {
 259        XFRM_AE_UNSPEC,
 260        XFRM_AE_RTHR=1, /* replay threshold*/
 261        XFRM_AE_RVAL=2, /* replay value */
 262        XFRM_AE_LVAL=4, /* lifetime value */
 263        XFRM_AE_ETHR=8, /* expiry timer threshold */
 264        XFRM_AE_CR=16, /* Event cause is replay update */
 265        XFRM_AE_CE=32, /* Event cause is timer expiry */
 266        XFRM_AE_CU=64, /* Event cause is policy update */
 267        __XFRM_AE_MAX
 268
 269#define XFRM_AE_MAX (__XFRM_AE_MAX - 1)
 270};
 271
 272struct xfrm_userpolicy_type {
 273        __u8            type;
 274        __u16           reserved1;
 275        __u8            reserved2;
 276};
 277
 278/* Netlink message attributes.  */
 279enum xfrm_attr_type_t {
 280        XFRMA_UNSPEC,
 281        XFRMA_ALG_AUTH,         /* struct xfrm_algo */
 282        XFRMA_ALG_CRYPT,        /* struct xfrm_algo */
 283        XFRMA_ALG_COMP,         /* struct xfrm_algo */
 284        XFRMA_ENCAP,            /* struct xfrm_algo + struct xfrm_encap_tmpl */
 285        XFRMA_TMPL,             /* 1 or more struct xfrm_user_tmpl */
 286        XFRMA_SA,               /* struct xfrm_usersa_info  */
 287        XFRMA_POLICY,           /*struct xfrm_userpolicy_info */
 288        XFRMA_SEC_CTX,          /* struct xfrm_sec_ctx */
 289        XFRMA_LTIME_VAL,
 290        XFRMA_REPLAY_VAL,
 291        XFRMA_REPLAY_THRESH,
 292        XFRMA_ETIMER_THRESH,
 293        XFRMA_SRCADDR,          /* xfrm_address_t */
 294        XFRMA_COADDR,           /* xfrm_address_t */
 295        XFRMA_LASTUSED,         /* unsigned long  */
 296        XFRMA_POLICY_TYPE,      /* struct xfrm_userpolicy_type */
 297        XFRMA_MIGRATE,
 298        XFRMA_ALG_AEAD,         /* struct xfrm_algo_aead */
 299        XFRMA_KMADDRESS,        /* struct xfrm_user_kmaddress */
 300        XFRMA_ALG_AUTH_TRUNC,   /* struct xfrm_algo_auth */
 301        XFRMA_MARK,             /* struct xfrm_mark */
 302        XFRMA_TFCPAD,           /* __u32 */
 303        XFRMA_REPLAY_ESN_VAL,   /* struct xfrm_replay_esn */
 304        XFRMA_SA_EXTRA_FLAGS,   /* __u32 */
 305        __RH_RESERVED_XFRMA_PROTO,      /* __u8 */
 306        __RH_RESERVED_XFRMA_ADDRESS_FILTER,     /* struct xfrm_address_filter */
 307        XFRMA_PAD,
 308        __XFRMA_MAX
 309
 310#define XFRMA_MAX (__XFRMA_MAX - 1)
 311};
 312
 313struct xfrm_mark {
 314        __u32           v; /* value */
 315        __u32           m; /* mask */
 316};
 317
 318enum xfrm_sadattr_type_t {
 319        XFRMA_SAD_UNSPEC,
 320        XFRMA_SAD_CNT,
 321        XFRMA_SAD_HINFO,
 322        __XFRMA_SAD_MAX
 323
 324#define XFRMA_SAD_MAX (__XFRMA_SAD_MAX - 1)
 325};
 326
 327struct xfrmu_sadhinfo {
 328        __u32 sadhcnt; /* current hash bkts */
 329        __u32 sadhmcnt; /* max allowed hash bkts */
 330};
 331
 332enum xfrm_spdattr_type_t {
 333        XFRMA_SPD_UNSPEC,
 334        XFRMA_SPD_INFO,
 335        XFRMA_SPD_HINFO,
 336        XFRMA_SPD_IPV4_HTHRESH,
 337        XFRMA_SPD_IPV6_HTHRESH,
 338        __XFRMA_SPD_MAX
 339
 340#define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1)
 341};
 342
 343struct xfrmu_spdinfo {
 344        __u32 incnt;
 345        __u32 outcnt;
 346        __u32 fwdcnt;
 347        __u32 inscnt;
 348        __u32 outscnt;
 349        __u32 fwdscnt;
 350};
 351
 352struct xfrmu_spdhinfo {
 353        __u32 spdhcnt;
 354        __u32 spdhmcnt;
 355};
 356
 357struct xfrmu_spdhthresh {
 358        __u8 lbits;
 359        __u8 rbits;
 360};
 361
 362struct xfrm_usersa_info {
 363        struct xfrm_selector            sel;
 364        struct xfrm_id                  id;
 365        xfrm_address_t                  saddr;
 366        struct xfrm_lifetime_cfg        lft;
 367        struct xfrm_lifetime_cur        curlft;
 368        struct xfrm_stats               stats;
 369        __u32                           seq;
 370        __u32                           reqid;
 371        __u16                           family;
 372        __u8                            mode;           /* XFRM_MODE_xxx */
 373        __u8                            replay_window;
 374        __u8                            flags;
 375#define XFRM_STATE_NOECN        1
 376#define XFRM_STATE_DECAP_DSCP   2
 377#define XFRM_STATE_NOPMTUDISC   4
 378#define XFRM_STATE_WILDRECV     8
 379#define XFRM_STATE_ICMP         16
 380#define XFRM_STATE_AF_UNSPEC    32
 381#define XFRM_STATE_ALIGN4       64
 382#define XFRM_STATE_ESN          128
 383};
 384
 385#define XFRM_SA_XFLAG_DONT_ENCAP_DSCP   1
 386
 387struct xfrm_usersa_id {
 388        xfrm_address_t                  daddr;
 389        __be32                          spi;
 390        __u16                           family;
 391        __u8                            proto;
 392};
 393
 394struct xfrm_aevent_id {
 395        struct xfrm_usersa_id           sa_id;
 396        xfrm_address_t                  saddr;
 397        __u32                           flags;
 398        __u32                           reqid;
 399};
 400
 401struct xfrm_userspi_info {
 402        struct xfrm_usersa_info         info;
 403        __u32                           min;
 404        __u32                           max;
 405};
 406
 407struct xfrm_userpolicy_info {
 408        struct xfrm_selector            sel;
 409        struct xfrm_lifetime_cfg        lft;
 410        struct xfrm_lifetime_cur        curlft;
 411        __u32                           priority;
 412        __u32                           index;
 413        __u8                            dir;
 414        __u8                            action;
 415#define XFRM_POLICY_ALLOW       0
 416#define XFRM_POLICY_BLOCK       1
 417        __u8                            flags;
 418#define XFRM_POLICY_LOCALOK     1       /* Allow user to override global policy */
 419        /* Automatically expand selector to include matching ICMP payloads. */
 420#define XFRM_POLICY_ICMP        2
 421        __u8                            share;
 422};
 423
 424struct xfrm_userpolicy_id {
 425        struct xfrm_selector            sel;
 426        __u32                           index;
 427        __u8                            dir;
 428};
 429
 430struct xfrm_user_acquire {
 431        struct xfrm_id                  id;
 432        xfrm_address_t                  saddr;
 433        struct xfrm_selector            sel;
 434        struct xfrm_userpolicy_info     policy;
 435        __u32                           aalgos;
 436        __u32                           ealgos;
 437        __u32                           calgos;
 438        __u32                           seq;
 439};
 440
 441struct xfrm_user_expire {
 442        struct xfrm_usersa_info         state;
 443        __u8                            hard;
 444};
 445
 446struct xfrm_user_polexpire {
 447        struct xfrm_userpolicy_info     pol;
 448        __u8                            hard;
 449};
 450
 451struct xfrm_usersa_flush {
 452        __u8                            proto;
 453};
 454
 455struct xfrm_user_report {
 456        __u8                            proto;
 457        struct xfrm_selector            sel;
 458};
 459
 460/* Used by MIGRATE to pass addresses IKE should use to perform
 461 * SA negotiation with the peer */
 462struct xfrm_user_kmaddress {
 463        xfrm_address_t                  local;
 464        xfrm_address_t                  remote;
 465        __u32                           reserved;
 466        __u16                           family;
 467};
 468
 469struct xfrm_user_migrate {
 470        xfrm_address_t                  old_daddr;
 471        xfrm_address_t                  old_saddr;
 472        xfrm_address_t                  new_daddr;
 473        xfrm_address_t                  new_saddr;
 474        __u8                            proto;
 475        __u8                            mode;
 476        __u16                           reserved;
 477        __u32                           reqid;
 478        __u16                           old_family;
 479        __u16                           new_family;
 480};
 481
 482struct xfrm_user_mapping {
 483        struct xfrm_usersa_id           id;
 484        __u32                           reqid;
 485        xfrm_address_t                  old_saddr;
 486        xfrm_address_t                  new_saddr;
 487        __be16                          old_sport;
 488        __be16                          new_sport;
 489};
 490
 491#ifndef __KERNEL__
 492/* backwards compatibility for userspace */
 493#define XFRMGRP_ACQUIRE         1
 494#define XFRMGRP_EXPIRE          2
 495#define XFRMGRP_SA              4
 496#define XFRMGRP_POLICY          8
 497#define XFRMGRP_REPORT          0x20
 498#endif
 499
 500enum xfrm_nlgroups {
 501        XFRMNLGRP_NONE,
 502#define XFRMNLGRP_NONE          XFRMNLGRP_NONE
 503        XFRMNLGRP_ACQUIRE,
 504#define XFRMNLGRP_ACQUIRE       XFRMNLGRP_ACQUIRE
 505        XFRMNLGRP_EXPIRE,
 506#define XFRMNLGRP_EXPIRE        XFRMNLGRP_EXPIRE
 507        XFRMNLGRP_SA,
 508#define XFRMNLGRP_SA            XFRMNLGRP_SA
 509        XFRMNLGRP_POLICY,
 510#define XFRMNLGRP_POLICY        XFRMNLGRP_POLICY
 511        XFRMNLGRP_AEVENTS,
 512#define XFRMNLGRP_AEVENTS       XFRMNLGRP_AEVENTS
 513        XFRMNLGRP_REPORT,
 514#define XFRMNLGRP_REPORT        XFRMNLGRP_REPORT
 515        XFRMNLGRP_MIGRATE,
 516#define XFRMNLGRP_MIGRATE       XFRMNLGRP_MIGRATE
 517        XFRMNLGRP_MAPPING,
 518#define XFRMNLGRP_MAPPING       XFRMNLGRP_MAPPING
 519        __XFRMNLGRP_MAX
 520};
 521#define XFRMNLGRP_MAX   (__XFRMNLGRP_MAX - 1)
 522
 523#endif /* _LINUX_XFRM_H */
 524