2 * Algorithm info parsing and creation functions
3 * Author: JuanJo Ciarlante <jjo-ipsec@mendoza.gov.ar>
5 * $Id: alg_info.h,v 1.1 2002-07-15 05:55:21 danield Exp $
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>.
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
20 u_int8_t transid; /* ESP transform */
21 u_int16_t auth; /* AUTH */
22 size_t enckeylen; /* keylength for ESP transform */
23 size_t authkeylen; /* keylength for AUTH */
24 u_int8_t encryptalg; /* normally encryptalg=transid */
25 u_int8_t authalg; /* normally authalg=auth+1 */
28 u_int16_t ike_ealg; /* high 16 bit nums for reserved */
34 #define ALG_INFO_COMMON \
37 unsigned alg_info_flags; \
38 unsigned alg_info_protoid
44 struct esp_info esp[64];
49 struct ike_info ike[64];
51 #define esp_ealg_id transid
52 #define esp_aalg_id auth
53 #define esp_ealg_keylen enckeylen /* bits */
54 #define esp_aalg_keylen authkeylen /* bits */
56 /* alg_info_flags bits */
57 #define ALG_INFO_F_STRICT 0x01
59 int alg_info_esp_aa2sadb(int auth);
60 int alg_info_esp_sadb2aa(int sadb_aalg);
61 void alg_info_free(struct alg_info *alg_info);
62 void alg_info_addref(struct alg_info *alg_info);
63 void alg_info_delref(struct alg_info **alg_info);
64 struct alg_info_esp * alg_info_esp_create_from_str (const char *alg_str, const char **err_p);
65 struct alg_info_ike * alg_info_ike_create_from_str (const char *alg_str, const char **err_p);
66 int alg_info_parse(const char *str);
67 int alg_info_snprint(char *buf, int buflen, struct alg_info *alg_info);
68 int alg_info_snprint_esp(char *buf, int buflen, struct alg_info_esp *alg_info);
69 int alg_info_snprint_ike(char *buf, int buflen, struct alg_info_ike *alg_info);
70 #define ALG_INFO_ESP_FOREACH(ai, ai_esp, i) \
71 for (i=(ai)->alg_info_cnt,ai_esp=(ai)->esp; i--; ai_esp++)
72 #define ALG_INFO_IKE_FOREACH(ai, ai_ike, i) \
73 for (i=(ai)->alg_info_cnt,ai_ike=(ai)->ike; i--; ai_ike++)
74 #endif /* ALG_INFO_H */