ia64/xen-unstable

view tools/vnet/vnet-module/esp.h @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 0a4b76b6b5a0
children 71b0f00f6344
line source
1 /*
2 * Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free software Foundation, Inc.,
16 * 59 Temple Place, suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19 #ifndef __VNET_ESP_H__
20 #define __VNET_ESP_H__
22 #include <linux/config.h>
23 #include <linux/types.h>
24 #include <linux/crypto.h>
26 /** Header used by IPSEC ESP (Encapsulated Security Payload). */
27 typedef struct ESPHdr {
28 /** The spi (security parameters index). */
29 u32 spi;
30 /** Sequence number. */
31 u32 seq;
32 /* Variable length data (depends on crypto suite).
33 Mind the 64 bit alignment! */
34 u8 data[0];
35 } ESPHdr;
37 /** Padding trailer used by IPSEC ESP.
38 * Follows the padding itself with the padding length and the
39 * protocol being encapsulated.
40 */
41 typedef struct ESPPadding {
42 u8 pad_n;
43 u8 protocol;
44 } ESPPadding;
46 /** Size of the esp header (spi and seq). */
47 static const int ESP_HDR_N = sizeof(ESPHdr);
49 /** Size of the esp pad and next protocol field. */
50 static const int ESP_PAD_N = sizeof(ESPPadding);
52 enum {
53 SASTATE_VOID,
54 SASTATE_ACQUIRE,
55 SASTATE_VALID,
56 SASTATE_ERROR,
57 SASTATE_EXPIRED,
58 SASTATE_DEAD,
59 };
61 struct ESPState;
63 /** A cipher instance. */
64 typedef struct ESPCipher {
65 /** Cipher key. */
66 u8 *key;
67 /** Key size (bytes). */
68 int key_n;
69 /** Initialization vector (IV). */
70 u8 *iv;
71 /** IV size (bytes). */
72 int iv_n;
73 /** Block size for padding (bytes). */
74 int pad_n;
75 /** Cipher block size (bytes). */
76 int block_n;
77 /** Cipher crypto transform. */
78 struct crypto_tfm *tfm;
79 } ESPCipher;
81 /** A digest instance. */
82 typedef struct ESPDigest {
83 /** Digest key. */
84 u8 *key;
85 /** Key size (bytes) */
86 int key_n;
87 /** ICV size used (bytes). */
88 u8 icv_n;
89 /** Full ICV size when computed (bytes). */
90 u8 icv_full_n;
91 /** Working storage for computing ICV. */
92 u8 *icv_tmp;
93 /** Function used to compute ICV (e.g. HMAC). */
94 void (*icv)(struct ESPState *esp,
95 struct sk_buff *skb,
96 int offset,
97 int len,
98 u8 *icv);
99 /** Digest crypto transform (e.g. SHA). */
100 struct crypto_tfm *tfm;
101 } ESPDigest;
103 typedef struct ESPState {
104 struct ESPCipher cipher;
105 struct ESPDigest digest;
106 } ESPState;
108 extern int esp_module_init(void);
109 extern void esp_module_exit(void);
111 #endif /* !__VNET_ESP_H__ */