OSDN Git Service

Add MS7619SE
[uclinux-h8/uClinux-dist.git] / openswan / include / kernel_alg.h
1 /*
2  * Kernel runtime algorithm handling interface definitions
3  * Author: JuanJo Ciarlante <jjo-ipsec@mendoza.gov.ar>
4  *
5  * kernel_alg.h,v 1.1.2.1 2003/11/21 18:12:23 jjo Exp
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation; either version 2 of the License, or (at your
10  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15  * for more details.
16  */
17
18 #ifndef _KERNEL_ALG_H
19 #define _KERNEL_ALG_H
20 #include "openswan/pfkeyv2.h"
21
22 struct sadb_msg; /* forward definition */
23
24 /* Registration messages from pluto */
25 extern void kernel_alg_register_pfkey(const struct sadb_msg *msg, int buflen);
26
27 struct alg_info;
28 struct esp_info;
29 struct alg_info_ike;
30 struct alg_info_esp;
31 /* ESP interface */
32 extern struct sadb_alg *kernel_alg_esp_sadb_alg(int alg_id);
33 extern int kernel_alg_esp_ivlen(int alg_id);
34 /* returns bool success if esp encrypt alg is present  */
35 extern err_t kernel_alg_esp_enc_ok(int alg_id, unsigned int key_len, struct alg_info_esp *nfo);
36 extern bool kernel_alg_esp_ok_final(int ealg, unsigned int key_len, int aalg, struct alg_info_esp *alg_info);
37 /* returns encrypt keylen in BYTES for esp enc alg passed */
38 extern int kernel_alg_esp_enc_keylen(int alg_id);
39 /* returns bool success if esp auth alg is present  */
40 extern err_t kernel_alg_esp_auth_ok(int auth, struct alg_info_esp *nfo);
41
42 extern int kernel_alg_ah_auth_keylen(int auth);
43 extern err_t kernel_alg_ah_auth_ok(int auth,struct alg_info_esp *alg_info);
44
45
46 /* returns auth keylen in BYTES for esp auth alg passed */
47 extern int kernel_alg_esp_auth_keylen(int auth);
48 /* returns 0 if read ok from /proc/net/pf_key_supported */
49 extern int kernel_alg_proc_read(void);
50
51 /* get sadb_alg for passed args */
52 extern const struct sadb_alg * kernel_alg_sadb_alg_get(int satype, int exttype, int alg_id);
53
54 struct db_prop;
55 extern struct db_context * kernel_alg_db_new(struct alg_info_esp *ai
56                                              , lset_t policy
57                                              , bool logit);
58
59 /* returns pointer to static buffer, no reentrant */
60 extern struct esp_info *kernel_alg_esp_info(u_int8_t transid
61                                             , u_int16_t keylen
62                                             , u_int16_t auth);
63
64 extern struct sadb_alg esp_aalg[];
65 extern struct sadb_alg esp_ealg[];
66 extern int esp_ealg_num;
67 extern int esp_aalg_num;
68
69 #define ESP_EALG_PRESENT(algo) (((algo)<=K_SADB_EALG_MAX)&&(esp_ealg[(algo)].sadb_alg_id==(algo)))
70 #define ESP_EALG_FOR_EACH(algo) \
71         for (algo=1; algo <= K_SADB_EALG_MAX; algo++) \
72                 if (ESP_EALG_PRESENT(algo))
73 #define ESP_EALG_FOR_EACH_UPDOWN(algo) \
74         for (algo=K_SADB_EALG_MAX; algo >0 ; algo--) \
75                 if (ESP_EALG_PRESENT(algo))
76 #define ESP_AALG_PRESENT(algo) ((algo<=SADB_AALG_MAX)&&(esp_aalg[(algo)].sadb_alg_id==(algo)))
77 #define ESP_AALG_FOR_EACH(algo) \
78         for (algo=1; algo <= SADB_AALG_MAX; algo++) \
79                 if (ESP_AALG_PRESENT(algo))
80 #define ESP_AALG_FOR_EACH_UPDOWN(algo) \
81         for (algo=SADB_AALG_MAX; algo >0 ; algo--) \
82                 if (ESP_AALG_PRESENT(algo))
83
84 /* used by test skaffold */
85 extern int kernel_alg_add(int satype, int exttype
86                           , const struct sadb_alg *sadb_alg);
87
88
89 #endif /* _KERNEL_ALG_H */