diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-07-07 22:13:09 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-07-07 22:13:09 +0000 |
commit | c0154638d6299a042e61ab56802a06c8e00d8d70 (patch) | |
tree | f00cac32f117740daf58fca535c0b6a4a952f81b /sbin/isakmpd | |
parent | 85584f6cd775fad17571093cc675cfdb7c36015d (diff) |
ipsec.c: Merge with EOM 1.113
ipsec.h: Merge with EOM 1.37
author: niklas
Add a function giving the size of a certain ID-payload
Diffstat (limited to 'sbin/isakmpd')
-rw-r--r-- | sbin/isakmpd/ipsec.c | 37 | ||||
-rw-r--r-- | sbin/isakmpd/ipsec.h | 5 |
2 files changed, 38 insertions, 4 deletions
diff --git a/sbin/isakmpd/ipsec.c b/sbin/isakmpd/ipsec.c index 3270f12cfc6..96b2fb70c15 100644 --- a/sbin/isakmpd/ipsec.c +++ b/sbin/isakmpd/ipsec.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ipsec.c,v 1.20 1999/06/02 06:33:36 niklas Exp $ */ -/* $EOM: ipsec.c,v 1.112 1999/05/25 07:57:18 niklas Exp $ */ +/* $OpenBSD: ipsec.c,v 1.21 1999/07/07 22:13:08 niklas Exp $ */ +/* $EOM: ipsec.c,v 1.113 1999/06/10 13:34:56 niklas Exp $ */ /* * Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved. @@ -1744,3 +1744,36 @@ ipsec_informational_post_hook (struct message *msg) return 0; return ipsec_fill_in_hash (msg); } + +ssize_t +ipsec_id_size (char *section, u_int8_t *id) +{ + char *type, *data; + + type = conf_get_str (section, "ID-type"); + if (!type) + { + log_print ("ipsec_id_size: section %s has no \"ID-type\" tag", section); + return -1; + } + + *id = constant_value (ipsec_id_cst, type); + switch (*id) + { + case IPSEC_ID_IPV4_ADDR: + return sizeof (in_addr_t); + case IPSEC_ID_IPV4_ADDR_SUBNET: + return 2 * sizeof (in_addr_t); + case IPSEC_ID_FQDN: + case IPSEC_ID_USER_FQDN: + data = conf_get_str (section, "Name"); + if (!data) + { + log_print ("ipsec_id_size: section %s has no \"Name\" tag", section); + return -1; + } + return strlen (data); + } + log_print ("ipsec_id_size: unrecognized ID-type %d (%s)", *id, type); + return -1; +} diff --git a/sbin/isakmpd/ipsec.h b/sbin/isakmpd/ipsec.h index 9515f062179..59b18435919 100644 --- a/sbin/isakmpd/ipsec.h +++ b/sbin/isakmpd/ipsec.h @@ -1,5 +1,5 @@ -/* $OpenBSD: ipsec.h,v 1.9 1999/05/02 19:20:33 niklas Exp $ */ -/* $EOM: ipsec.h,v 1.36 1999/05/02 12:48:55 niklas Exp $ */ +/* $OpenBSD: ipsec.h,v 1.10 1999/07/07 22:13:08 niklas Exp $ */ +/* $EOM: ipsec.h,v 1.37 1999/06/10 13:34:58 niklas Exp $ */ /* * Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved. @@ -136,6 +136,7 @@ extern int ipsec_esp_enckeylength (struct proto *); extern int ipsec_fill_in_hash (struct message *msg); extern int ipsec_gen_g_x (struct message *); extern int ipsec_get_id (char *, int *, struct in_addr *, struct in_addr *); +extern ssize_t ipsec_id_size (char *, u_int8_t *); extern void ipsec_init (void); extern int ipsec_initial_contact (struct message *msg); extern int ipsec_is_attribute_incompatible (u_int16_t, u_int8_t *, u_int16_t, |