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/ipsec.c | |
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/ipsec.c')
-rw-r--r-- | sbin/isakmpd/ipsec.c | 37 |
1 files changed, 35 insertions, 2 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; +} |