diff options
author | Hans-Joerg Hoexer <hshoexer@cvs.openbsd.org> | 2005-04-08 23:15:27 +0000 |
---|---|---|
committer | Hans-Joerg Hoexer <hshoexer@cvs.openbsd.org> | 2005-04-08 23:15:27 +0000 |
commit | 9967edda194eb32d6402b621364e4f48c784e1a8 (patch) | |
tree | 702f75ac2519f01081ed76a0ee2cfc3052625bb8 /sbin/isakmpd | |
parent | cb04993a6a5ad3e448426e96a948cdef66528031 (diff) |
get rid of sysdep_sa_len
ok cloder@
Diffstat (limited to 'sbin/isakmpd')
-rw-r--r-- | sbin/isakmpd/cookie.c | 8 | ||||
-rw-r--r-- | sbin/isakmpd/ipsec.c | 17 | ||||
-rw-r--r-- | sbin/isakmpd/message.c | 6 | ||||
-rw-r--r-- | sbin/isakmpd/monitor.c | 10 | ||||
-rw-r--r-- | sbin/isakmpd/pf_key_v2.c | 72 | ||||
-rw-r--r-- | sbin/isakmpd/sa.c | 10 | ||||
-rw-r--r-- | sbin/isakmpd/sysdep.h | 3 | ||||
-rw-r--r-- | sbin/isakmpd/sysdep/openbsd/sysdep.c | 9 | ||||
-rw-r--r-- | sbin/isakmpd/transport.c | 8 | ||||
-rw-r--r-- | sbin/isakmpd/udp.c | 31 | ||||
-rw-r--r-- | sbin/isakmpd/udp_encap.c | 11 | ||||
-rw-r--r-- | sbin/isakmpd/util.c | 14 | ||||
-rw-r--r-- | sbin/isakmpd/virtual.c | 13 |
13 files changed, 94 insertions, 118 deletions
diff --git a/sbin/isakmpd/cookie.c b/sbin/isakmpd/cookie.c index ec8f8265331..bebf475b74f 100644 --- a/sbin/isakmpd/cookie.c +++ b/sbin/isakmpd/cookie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cookie.c,v 1.14 2004/05/14 08:42:56 hshoexer Exp $ */ +/* $OpenBSD: cookie.c,v 1.15 2005/04/08 23:15:25 hshoexer Exp $ */ /* $EOM: cookie.c,v 1.21 1999/08/05 15:00:04 niklas Exp $ */ /* @@ -34,8 +34,6 @@ #include <stdlib.h> #include <string.h> -#include "sysdep.h" - #include "cookie.h" #include "exchange.h" #include "hash.h" @@ -61,9 +59,9 @@ cookie_gen(struct transport *t, struct exchange *exchange, u_int8_t *buf, hash->Init(hash->ctx); (*t->vtbl->get_dst)(t, &name); - hash->Update(hash->ctx, (u_int8_t *)name, sysdep_sa_len(name)); + hash->Update(hash->ctx, (u_int8_t *)name, SA_LEN(name)); (*t->vtbl->get_src)(t, &name); - hash->Update(hash->ctx, (u_int8_t *)name, sysdep_sa_len(name)); + hash->Update(hash->ctx, (u_int8_t *)name, SA_LEN(name)); if (exchange->initiator == 0) hash->Update(hash->ctx, exchange->cookies + ISAKMP_HDR_ICOOKIE_OFF, ISAKMP_HDR_ICOOKIE_LEN); diff --git a/sbin/isakmpd/ipsec.c b/sbin/isakmpd/ipsec.c index 3b5c54a80ec..bace4f0f49b 100644 --- a/sbin/isakmpd/ipsec.c +++ b/sbin/isakmpd/ipsec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec.c,v 1.116 2005/04/08 19:40:03 deraadt Exp $ */ +/* $OpenBSD: ipsec.c,v 1.117 2005/04/08 23:15:26 hshoexer Exp $ */ /* $EOM: ipsec.c,v 1.143 2000/12/11 23:57:42 niklas Exp $ */ /* @@ -1601,8 +1601,7 @@ ipsec_handle_leftover_payload(struct message *msg, u_int8_t type, * disappear too. */ msg->transport->vtbl->get_dst(msg->transport, &dst); - while ((sa = sa_lookup_by_peer(dst, - sysdep_sa_len(dst))) != 0) { + while ((sa = sa_lookup_by_peer(dst, SA_LEN(dst))) != 0) { /* * Don't delete the current SA -- we received * the notification over it, so it's obviously @@ -2152,15 +2151,15 @@ ipsec_add_contact(struct message *msg) contacts = new_contacts; } msg->transport->vtbl->get_dst(msg->transport, &dst); - addr = malloc(sysdep_sa_len(dst)); + addr = malloc(SA_LEN(dst)); if (!addr) { - log_error("ipsec_add_contact: malloc (%d) failed", - sysdep_sa_len(dst)); + log_error("ipsec_add_contact: malloc (%lu) failed", + (unsigned long)SA_LEN(dst)); return -1; } - memcpy(addr, dst, sysdep_sa_len(dst)); + memcpy(addr, dst, SA_LEN(dst)); contacts[contact_cnt].addr = addr; - contacts[contact_cnt++].len = sysdep_sa_len(dst); + contacts[contact_cnt++].len = SA_LEN(dst); /* * XXX There are better algorithms for already mostly-sorted data like @@ -2177,7 +2176,7 @@ ipsec_contacted(struct message *msg) struct contact contact; msg->transport->vtbl->get_dst(msg->transport, &contact.addr); - contact.len = sysdep_sa_len(contact.addr); + contact.len = SA_LEN(contact.addr); return contacts ? (bsearch(&contact, contacts, contact_cnt, sizeof *contacts, addr_cmp) != 0) : 0; } diff --git a/sbin/isakmpd/message.c b/sbin/isakmpd/message.c index 746358b9d5e..fb34857e1dc 100644 --- a/sbin/isakmpd/message.c +++ b/sbin/isakmpd/message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: message.c,v 1.106 2005/04/08 20:55:21 deraadt Exp $ */ +/* $OpenBSD: message.c,v 1.107 2005/04/08 23:15:26 hshoexer Exp $ */ /* $EOM: message.c,v 1.156 2000/10/10 12:36:39 provos Exp $ */ /* @@ -38,8 +38,6 @@ #include <stdlib.h> #include <string.h> -#include "sysdep.h" - #include "attribute.h" #include "cert.h" #include "constants.h" @@ -1677,7 +1675,7 @@ message_send_delete(struct sa *sa) struct sockaddr *dst; sa->transport->vtbl->get_dst(sa->transport, &dst); - isakmp_sa = sa_isakmp_lookup_by_peer(dst, sysdep_sa_len(dst)); + isakmp_sa = sa_isakmp_lookup_by_peer(dst, SA_LEN(dst)); if (!isakmp_sa) { /* * XXX We ought to setup an ISAKMP SA with our peer here and diff --git a/sbin/isakmpd/monitor.c b/sbin/isakmpd/monitor.c index 33aa75392e8..548a62ea70a 100644 --- a/sbin/isakmpd/monitor.c +++ b/sbin/isakmpd/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.38 2005/04/08 17:15:01 deraadt Exp $ */ +/* $OpenBSD: monitor.c,v 1.39 2005/04/08 23:15:26 hshoexer Exp $ */ /* * Copyright (c) 2003 Håkan Olsson. All rights reserved. @@ -44,8 +44,6 @@ #include <regex.h> #include <keynote.h> -#include "sysdep.h" - #include "conf.h" #include "log.h" #include "monitor.h" @@ -1059,9 +1057,9 @@ m_priv_check_bind(const struct sockaddr *sa, socklen_t salen) log_print("NULL address"); return 1; } - if (sysdep_sa_len((struct sockaddr *)sa) != salen) { - log_print("Length mismatch: %d %d", - (int)sysdep_sa_len((struct sockaddr *)sa), (int)salen); + if (SA_LEN(sa) != salen) { + log_print("Length mismatch: %lu %lu", (unsigned long)sa->sa_len, + (unsigned long)salen); return 1; } switch (sa->sa_family) { diff --git a/sbin/isakmpd/pf_key_v2.c b/sbin/isakmpd/pf_key_v2.c index a94b536be81..88e25af57af 100644 --- a/sbin/isakmpd/pf_key_v2.c +++ b/sbin/isakmpd/pf_key_v2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_key_v2.c,v 1.163 2005/04/08 19:40:03 deraadt Exp $ */ +/* $OpenBSD: pf_key_v2.c,v 1.164 2005/04/08 23:15:26 hshoexer Exp $ */ /* $EOM: pf_key_v2.c,v 1.79 2000/12/12 00:33:19 niklas Exp $ */ /* @@ -38,8 +38,6 @@ #include <sys/time.h> #include <sys/uio.h> -#include "sysdep.h" - #include <net/pfkeyv2.h> #include <netinet/in.h> #ifdef SADB_X_EXT_FLOW_TYPE @@ -157,11 +155,11 @@ pf_key_v2_register_sa_seq(u_int8_t *spi, size_t sz, u_int8_t proto, node->spi = malloc(sz); if (!node->spi) goto cleanup; - node->dst = malloc(sysdep_sa_len(dst)); + node->dst = malloc(SA_LEN(dst)); if (!node->dst) goto cleanup; - memcpy(node->dst, dst, sysdep_sa_len(dst)); - node->dstlen = sysdep_sa_len(dst); + memcpy(node->dst, dst, SA_LEN(dst)); + node->dstlen = SA_LEN(dst); memcpy(node->spi, spi, sz); node->sz = sz; node->proto = proto; @@ -188,8 +186,8 @@ pf_key_v2_seq_by_sa(u_int8_t *spi, size_t sz, u_int8_t proto, node = TAILQ_NEXT(node, link)) if (node->proto == proto && node->sz == sz && memcmp(node->spi, spi, sz) == 0 && - node->dstlen == sysdep_sa_len(dst) && - memcmp(node->dst, dst, sysdep_sa_len(dst)) == 0) + node->dstlen == SA_LEN(dst) && + memcmp(node->dst, dst, SA_LEN(dst)) == 0) return node->seq; return 0; } @@ -653,7 +651,7 @@ pf_key_v2_get_spi(size_t *sz, u_int8_t proto, struct sockaddr *src, /* Setup the ADDRESS extensions. */ len = - sizeof(struct sadb_address) + PF_KEY_V2_ROUND(sysdep_sa_len(src)); + sizeof(struct sadb_address) + PF_KEY_V2_ROUND(SA_LEN(src)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -664,7 +662,7 @@ pf_key_v2_get_spi(size_t *sz, u_int8_t proto, struct sockaddr *src, addr->sadb_address_prefixlen = 0; #endif addr->sadb_address_reserved = 0; - memcpy(addr + 1, src, sysdep_sa_len(src)); + memcpy(addr + 1, src, SA_LEN(src)); switch (((struct sockaddr *) (addr + 1))->sa_family) { case AF_INET: ((struct sockaddr_in *) (addr + 1))->sin_port = 0; @@ -679,7 +677,7 @@ pf_key_v2_get_spi(size_t *sz, u_int8_t proto, struct sockaddr *src, addr = 0; len = - sizeof(struct sadb_address) + PF_KEY_V2_ROUND(sysdep_sa_len(dst)); + sizeof(struct sadb_address) + PF_KEY_V2_ROUND(SA_LEN(dst)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -690,7 +688,7 @@ pf_key_v2_get_spi(size_t *sz, u_int8_t proto, struct sockaddr *src, addr->sadb_address_prefixlen = 0; #endif addr->sadb_address_reserved = 0; - memcpy(addr + 1, dst, sysdep_sa_len(dst)); + memcpy(addr + 1, dst, SA_LEN(dst)); switch (((struct sockaddr *) (addr + 1))->sa_family) { case AF_INET: ((struct sockaddr_in *) (addr + 1))->sin_port = 0; @@ -749,8 +747,7 @@ pf_key_v2_get_spi(size_t *sz, u_int8_t proto, struct sockaddr *src, memcpy(spi, &sa->sadb_sa_spi, *sz); #ifdef KAME - if (!pf_key_v2_register_sa_seq(spi, *sz, proto, dst, - sysdep_sa_len(dst), + if (!pf_key_v2_register_sa_seq(spi, *sz, proto, dst, SA_LEN(dst), ((struct sadb_msg *) (TAILQ_FIRST(ret)->seg))->sadb_msg_seq)) goto cleanup; #endif @@ -835,7 +832,7 @@ pf_key_v2_get_kernel_sa(u_int8_t *spi, size_t spi_sz, u_int8_t proto, /* Address */ len = - sizeof(struct sadb_address) + PF_KEY_V2_ROUND(sysdep_sa_len(dst)); + sizeof(struct sadb_address) + PF_KEY_V2_ROUND(SA_LEN(dst)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -846,7 +843,7 @@ pf_key_v2_get_kernel_sa(u_int8_t *spi, size_t spi_sz, u_int8_t proto, addr->sadb_address_prefixlen = 0; #endif addr->sadb_address_reserved = 0; - memcpy(addr + 1, dst, sysdep_sa_len(dst)); + memcpy(addr + 1, dst, SA_LEN(dst)); switch (((struct sockaddr *) (addr + 1))->sa_family) { case AF_INET: ((struct sockaddr_in *) (addr + 1))->sin_port = 0; @@ -1266,7 +1263,7 @@ pf_key_v2_set_spi(struct sa *sa, struct proto *proto, int incoming, #ifdef KAME msg.sadb_msg_seq = (incoming ? pf_key_v2_seq_by_sa(proto->spi[incoming], sizeof ssa.sadb_sa_spi, - proto->proto, dst, sysdep_sa_len(dst)) : 0); + proto->proto, dst, SA_LEN(dst)) : 0); #else msg.sadb_msg_seq = sa->seq; #endif @@ -1376,7 +1373,7 @@ pf_key_v2_set_spi(struct sa *sa, struct proto *proto, int incoming, sa->transport->vtbl->get_dst(sa->transport, &src); else sa->transport->vtbl->get_src(sa->transport, &src); - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(src)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(src)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -1387,7 +1384,7 @@ pf_key_v2_set_spi(struct sa *sa, struct proto *proto, int incoming, addr->sadb_address_prefixlen = 0; #endif addr->sadb_address_reserved = 0; - memcpy(addr + 1, src, sysdep_sa_len(src)); + memcpy(addr + 1, src, SA_LEN(src)); switch (((struct sockaddr *) (addr + 1))->sa_family) { case AF_INET: ((struct sockaddr_in *) (addr + 1))->sin_port = 0; @@ -1401,7 +1398,7 @@ pf_key_v2_set_spi(struct sa *sa, struct proto *proto, int incoming, goto cleanup; addr = 0; - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(dst)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(dst)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -1412,7 +1409,7 @@ pf_key_v2_set_spi(struct sa *sa, struct proto *proto, int incoming, addr->sadb_address_prefixlen = 0; #endif addr->sadb_address_reserved = 0; - memcpy(addr + 1, dst, sysdep_sa_len(dst)); + memcpy(addr + 1, dst, SA_LEN(dst)); switch (((struct sockaddr *) (addr + 1))->sa_family) { case AF_INET: ((struct sockaddr_in *) (addr + 1))->sin_port = 0; @@ -1429,7 +1426,7 @@ pf_key_v2_set_spi(struct sa *sa, struct proto *proto, int incoming, #if 0 /* XXX I am not sure about what to do here just yet. */ if (iproto->encap_mode == IPSEC_ENCAP_TUNNEL) { - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(dst)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(dst)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -1440,7 +1437,7 @@ pf_key_v2_set_spi(struct sa *sa, struct proto *proto, int incoming, addr->sadb_address_prefixlen = 0; #endif addr->sadb_address_reserved = 0; - memcpy(addr + 1, dst, sysdep_sa_len(dst)); + memcpy(addr + 1, dst, SA_LEN(dst)); switch (((struct sockaddr *) (addr + 1))->sa_family) { case AF_INET: ((struct sockaddr_in *) (addr + 1))->sin_port = 0; @@ -1723,7 +1720,7 @@ doneauth: 0) == -1) goto cleanup; - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(isa->src_net)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(isa->src_net)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -1860,7 +1857,6 @@ pf_key_v2_mask6_to_bits(u_int8_t *mask) /* * Enable/disable a flow. * XXX Assumes OpenBSD {ADD,DEL}FLOW extensions. - * Should probably be moved to sysdep.c */ static int pf_key_v2_flow(struct sockaddr *laddr, struct sockaddr *lmask, @@ -1995,7 +1991,7 @@ pf_key_v2_flow(struct sockaddr *laddr, struct sockaddr *lmask, /* * Setup the ADDRESS extensions. */ - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(src)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(src)); #if !defined (SADB_X_EXT_FLOW_TYPE) if (!delete || ingress) #else @@ -2018,7 +2014,7 @@ pf_key_v2_flow(struct sockaddr *laddr, struct sockaddr *lmask, goto cleanup; addr = 0; } - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(laddr)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(laddr)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -2167,7 +2163,7 @@ cleanup: /* * Setup the ADDRESS extensions. */ - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(src)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(src)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -2193,7 +2189,7 @@ cleanup: goto cleanup; addr = 0; - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(raddr)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(raddr)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -2221,7 +2217,7 @@ cleanup: /* Setup the POLICY extension. */ len = sizeof *policy + sizeof *ipsecrequest + - 2 * PF_KEY_V2_ROUND(sysdep_sa_len(src)); + 2 * PF_KEY_V2_ROUND(SA_LEN(src)); policy_buf = (u_int8_t *) calloc(1, len); if (!policy_buf) { log_error("pf_key_v2_flow: calloc %lu failed", @@ -2790,7 +2786,7 @@ pf_key_v2_delete_spi(struct sa *sa, struct proto *proto, int incoming) sa->transport->vtbl->get_dst(sa->transport, &saddr); else sa->transport->vtbl->get_src(sa->transport, &saddr); - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(saddr)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(saddr)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -2801,7 +2797,7 @@ pf_key_v2_delete_spi(struct sa *sa, struct proto *proto, int incoming) addr->sadb_address_prefixlen = 0; #endif addr->sadb_address_reserved = 0; - memcpy(addr + 1, saddr, sysdep_sa_len(saddr)); + memcpy(addr + 1, saddr, SA_LEN(saddr)); switch (saddr->sa_family) { case AF_INET: ((struct sockaddr_in *) (addr + 1))->sin_port = 0; @@ -2819,7 +2815,7 @@ pf_key_v2_delete_spi(struct sa *sa, struct proto *proto, int incoming) sa->transport->vtbl->get_src(sa->transport, &saddr); else sa->transport->vtbl->get_dst(sa->transport, &saddr); - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(saddr)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(saddr)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -2830,7 +2826,7 @@ pf_key_v2_delete_spi(struct sa *sa, struct proto *proto, int incoming) addr->sadb_address_prefixlen = 0; #endif addr->sadb_address_reserved = 0; - memcpy(addr + 1, saddr, sysdep_sa_len(saddr)); + memcpy(addr + 1, saddr, SA_LEN(saddr)); switch (saddr->sa_family) { case AF_INET: ((struct sockaddr_in *) (addr + 1))->sin_port = 0; @@ -4149,7 +4145,7 @@ pf_key_v2_handler(int fd) /* * Group 2 IPsec SAs given by the PROTO1 and PROTO2 protocols of the SA IKE * security association in a chain. - * XXX Assumes OpenBSD GRPSPIS extension. Should probably be moved to sysdep.c + * XXX Assumes OpenBSD GRPSPIS extension. */ int pf_key_v2_group_spis(struct sa *sa, struct proto *proto1, @@ -4232,7 +4228,7 @@ pf_key_v2_group_spis(struct sa *sa, struct proto *proto1, sa->transport->vtbl->get_src(sa->transport, &saddr); else sa->transport->vtbl->get_dst(sa->transport, &saddr); - len = sizeof *addr + PF_KEY_V2_ROUND(sysdep_sa_len(saddr)); + len = sizeof *addr + PF_KEY_V2_ROUND(SA_LEN(saddr)); addr = calloc(1, len); if (!addr) goto cleanup; @@ -4243,7 +4239,7 @@ pf_key_v2_group_spis(struct sa *sa, struct proto *proto1, addr->sadb_address_prefixlen = 0; #endif addr->sadb_address_reserved = 0; - memcpy(addr + 1, saddr, sysdep_sa_len(saddr)); + memcpy(addr + 1, saddr, SA_LEN(saddr)); ((struct sockaddr_in *) (addr + 1))->sin_port = 0; if (pf_key_v2_msg_add(grpspis, (struct sadb_ext *) addr, PF_KEY_V2_NODE_MALLOCED) == -1) @@ -4260,7 +4256,7 @@ pf_key_v2_group_spis(struct sa *sa, struct proto *proto1, addr->sadb_address_prefixlen = 0; #endif addr->sadb_address_reserved = 0; - memcpy(addr + 1, saddr, sysdep_sa_len(saddr)); + memcpy(addr + 1, saddr, SA_LEN(saddr)); ((struct sockaddr_in *) (addr + 1))->sin_port = 0; if (pf_key_v2_msg_add(grpspis, (struct sadb_ext *) addr, PF_KEY_V2_NODE_MALLOCED) == -1) diff --git a/sbin/isakmpd/sa.c b/sbin/isakmpd/sa.c index ae6323b0206..88c09370ae6 100644 --- a/sbin/isakmpd/sa.c +++ b/sbin/isakmpd/sa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sa.c,v 1.97 2005/04/08 22:32:10 cloder Exp $ */ +/* $OpenBSD: sa.c,v 1.98 2005/04/08 23:15:26 hshoexer Exp $ */ /* $EOM: sa.c,v 1.112 2000/12/12 00:22:52 niklas Exp $ */ /* @@ -198,8 +198,8 @@ sa_check_peer(struct sa *sa, void *v_addr) return 0; sa->transport->vtbl->get_dst(sa->transport, &dst); - return sysdep_sa_len(dst) == addr->len && - memcmp(dst, addr->addr, sysdep_sa_len(dst)) == 0; + return SA_LEN(dst) == addr->len && + memcmp(dst, addr->addr, SA_LEN(dst)) == 0; } struct dst_isakmpspi_arg { @@ -223,8 +223,8 @@ isakmp_sa_check(struct sa *sa, void *v_arg) /* verify address is either src or dst for this sa */ sa->transport->vtbl->get_dst(sa->transport, &dst); sa->transport->vtbl->get_src(sa->transport, &src); - if (memcmp(src, arg->dst, sysdep_sa_len(src)) && - memcmp(dst, arg->dst, sysdep_sa_len(dst))) + if (memcmp(src, arg->dst, SA_LEN(src)) && + memcmp(dst, arg->dst, SA_LEN(dst))) return 0; /* match icookie+rcookie against spi */ diff --git a/sbin/isakmpd/sysdep.h b/sbin/isakmpd/sysdep.h index 7b09b0adc9c..d1e1fb83e82 100644 --- a/sbin/isakmpd/sysdep.h +++ b/sbin/isakmpd/sysdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysdep.h,v 1.23 2005/04/08 22:32:10 cloder Exp $ */ +/* $OpenBSD: sysdep.h,v 1.24 2005/04/08 23:15:26 hshoexer Exp $ */ /* $EOM: sysdep.h,v 1.17 2000/12/04 04:46:35 angelos Exp $ */ /* @@ -55,7 +55,6 @@ extern int sysdep_ipsec_group_spis(struct sa *, struct proto *, struct proto *, int); extern int sysdep_ipsec_set_spi(struct sa *, struct proto *, int, struct sa *); -extern u_int8_t sysdep_sa_len(struct sockaddr *); #if defined (USE_BOEHM_GC) /* diff --git a/sbin/isakmpd/sysdep/openbsd/sysdep.c b/sbin/isakmpd/sysdep/openbsd/sysdep.c index d9f5264c20b..5168fcdd330 100644 --- a/sbin/isakmpd/sysdep/openbsd/sysdep.c +++ b/sbin/isakmpd/sysdep/openbsd/sysdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysdep.c,v 1.32 2005/04/08 22:32:10 cloder Exp $ */ +/* $OpenBSD: sysdep.c,v 1.33 2005/04/08 23:15:26 hshoexer Exp $ */ /* $EOM: sysdep.c,v 1.9 2000/12/04 04:46:35 angelos Exp $ */ /* @@ -51,13 +51,6 @@ #include "log.h" -/* Return the length of the sockaddr struct. */ -u_int8_t -sysdep_sa_len(struct sockaddr *sa) -{ - return sa->sa_len; -} - /* * When select(2) has noticed our application needs attendance, this is what * gets called. FD is the file descriptor causing the alarm. diff --git a/sbin/isakmpd/transport.c b/sbin/isakmpd/transport.c index 96188986f30..8fce5a73c7e 100644 --- a/sbin/isakmpd/transport.c +++ b/sbin/isakmpd/transport.c @@ -1,4 +1,4 @@ -/* $OpenBSD: transport.c,v 1.32 2005/04/08 16:32:11 hshoexer Exp $ */ +/* $OpenBSD: transport.c,v 1.33 2005/04/08 23:15:26 hshoexer Exp $ */ /* $EOM: transport.c,v 1.43 2000/10/10 12:36:39 provos Exp $ */ /* @@ -35,8 +35,6 @@ #include <netdb.h> #include <string.h> -#include "sysdep.h" - #include "conf.h" #include "exchange.h" #include "log.h" @@ -326,8 +324,8 @@ transport_send_messages(fd_set * fds) if (msg->xmits > conf_get_num("General", "retransmits", RETRANSMIT_DEFAULT)) { t->virtual->vtbl->get_dst(t->virtual, &dst); - if (getnameinfo(dst, sysdep_sa_len(dst), - peer, sizeof peer, peersv, sizeof peersv, + if (getnameinfo(dst, SA_LEN(dst), peer, + sizeof peer, peersv, sizeof peersv, NI_NUMERICHOST | NI_NUMERICSERV)) { strlcpy(peer, "<unknown>", sizeof peer); strlcpy(peersv, "<?>", sizeof peersv); diff --git a/sbin/isakmpd/udp.c b/sbin/isakmpd/udp.c index dfd0ea42cf1..8f144df105a 100644 --- a/sbin/isakmpd/udp.c +++ b/sbin/isakmpd/udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp.c,v 1.87 2005/04/08 22:32:10 cloder Exp $ */ +/* $OpenBSD: udp.c,v 1.88 2005/04/08 23:15:26 hshoexer Exp $ */ /* $EOM: udp.c,v 1.57 2001/01/26 10:09:57 niklas Exp $ */ /* @@ -51,7 +51,6 @@ #include "log.h" #include "message.h" #include "monitor.h" -#include "sysdep.h" #include "transport.h" #include "udp.h" #include "util.h" @@ -161,7 +160,7 @@ udp_make(struct sockaddr *laddr) goto err; } t->transport.vtbl = &udp_transport_vtbl; - if (monitor_bind(s, t->src, sysdep_sa_len(t->src))) { + if (monitor_bind(s, t->src, SA_LEN(t->src))) { if (sockaddr2text(t->src, &tstr, 0)) log_error("udp_make: bind (%d, %p, %lu)", s, &t->src, (unsigned long)sizeof t->src); @@ -216,24 +215,24 @@ udp_clone(struct transport *ut, struct sockaddr *raddr) memcpy(u2, u, sizeof *u); - u2->src = malloc(sysdep_sa_len(u->src)); + u2->src = malloc(SA_LEN(u->src)); if (!u2->src) { - log_error("udp_clone: malloc (%d) failed", - sysdep_sa_len(u->src)); + log_error("udp_clone: malloc (%lu) failed", + (unsigned long)SA_LEN(u->src)); free(t); return 0; } - memcpy(u2->src, u->src, sysdep_sa_len(u->src)); + memcpy(u2->src, u->src, SA_LEN(u->src)); - u2->dst = malloc(sysdep_sa_len(raddr)); + u2->dst = malloc(SA_LEN(raddr)); if (!u2->dst) { - log_error("udp_clone: malloc (%d) failed", - sysdep_sa_len(raddr)); + log_error("udp_clone: malloc (%lu) failed", + (unsigned long)SA_LEN(raddr)); free(u2->src); free(t); return 0; } - memcpy(u2->dst, raddr, sysdep_sa_len(raddr)); + memcpy(u2->dst, raddr, SA_LEN(raddr)); t->flags &= ~TRANSPORT_LISTEN; transport_setup(t, 0); @@ -251,11 +250,11 @@ udp_bind(const struct sockaddr *addr) { struct sockaddr *src; - src = malloc(sysdep_sa_len((struct sockaddr *)addr)); + src = malloc(SA_LEN(addr)); if (!src) return 0; - memcpy(src, addr, sysdep_sa_len((struct sockaddr *)addr)); + memcpy(src, addr, SA_LEN(addr)); return udp_make(src); } @@ -451,7 +450,7 @@ udp_send_message(struct message *msg, struct transport *t) * given, or else EISCONN will occur. */ m.msg_name = (caddr_t) u->dst; - m.msg_namelen = sysdep_sa_len(u->dst); + m.msg_namelen = SA_LEN(u->dst); m.msg_iov = msg->iov; m.msg_iovlen = msg->iovlen; m.msg_control = 0; @@ -517,12 +516,12 @@ udp_decode_ids(struct transport *t) t->vtbl->get_src(t, &src); t->vtbl->get_dst(t, &dst); - if (getnameinfo(src, sysdep_sa_len(src), idsrc, sizeof idsrc, NULL, 0, + if (getnameinfo(src, SA_LEN(src), idsrc, sizeof idsrc, NULL, 0, NI_NUMERICHOST) != 0) { log_print("udp_decode_ids: getnameinfo () failed for 'src'"); strlcpy(idsrc, "<error>", 256); } - if (getnameinfo(dst, sysdep_sa_len(dst), iddst, sizeof iddst, NULL, 0, + if (getnameinfo(dst, SA_LEN(dst), iddst, sizeof iddst, NULL, 0, NI_NUMERICHOST) != 0) { log_print("udp_decode_ids: getnameinfo () failed for 'dst'"); strlcpy(iddst, "<error>", 256); diff --git a/sbin/isakmpd/udp_encap.c b/sbin/isakmpd/udp_encap.c index fa81d7e2f8d..9836eceb727 100644 --- a/sbin/isakmpd/udp_encap.c +++ b/sbin/isakmpd/udp_encap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_encap.c,v 1.14 2005/04/08 16:07:22 cloder Exp $ */ +/* $OpenBSD: udp_encap.c,v 1.15 2005/04/08 23:15:26 hshoexer Exp $ */ /* * Copyright (c) 1998, 1999, 2001 Niklas Hallqvist. All rights reserved. @@ -49,7 +49,6 @@ #include "log.h" #include "message.h" #include "monitor.h" -#include "sysdep.h" #include "transport.h" #include "udp.h" #include "udp_encap.h" @@ -164,7 +163,7 @@ udp_encap_make(struct sockaddr *laddr) } t->transport.vtbl = &udp_encap_transport_vtbl; - if (monitor_bind(s, t->src, sysdep_sa_len (t->src))) { + if (monitor_bind(s, t->src, SA_LEN(t->src))) { if (sockaddr2text(t->src, &tstr, 0)) log_error("udp_encap_make: bind (%d, %p, %lu)", s, &t->src, (unsigned long)sizeof t->src); @@ -213,11 +212,11 @@ udp_encap_bind(const struct sockaddr *addr) { struct sockaddr *src; - src = malloc(sysdep_sa_len((struct sockaddr *)addr)); + src = malloc(SA_LEN(addr)); if (!src) return 0; - memcpy(src, addr, sysdep_sa_len((struct sockaddr *)addr)); + memcpy(src, addr, SA_LEN(addr)); return udp_encap_make(src); } @@ -435,7 +434,7 @@ udp_encap_send_message(struct message *msg, struct transport *t) * given, or else EISCONN will occur. */ m.msg_name = (caddr_t)u->dst; - m.msg_namelen = sysdep_sa_len (u->dst); + m.msg_namelen = SA_LEN(u->dst); m.msg_iov = msg ? new_iov : &keepalive; m.msg_iovlen = msg ? msg->iovlen + 1 : 1; m.msg_control = 0; diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c index 7582396072d..e03d59710a4 100644 --- a/sbin/isakmpd/util.c +++ b/sbin/isakmpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.56 2005/04/08 22:32:10 cloder Exp $ */ +/* $OpenBSD: util.c,v 1.57 2005/04/08 23:15:26 hshoexer Exp $ */ /* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */ /* @@ -379,25 +379,25 @@ text2sockaddr(char *address, char *port, struct sockaddr **sa, sa_family_t af, if (ifa) { if (netmask) memcpy(&tmp_sas, ifa->ifa_netmask, - sysdep_sa_len(ifa->ifa_netmask)); + SA_LEN(ifa->ifa_netmask)); else memcpy(&tmp_sas, ifa->ifa_addr, - sysdep_sa_len(ifa->ifa_addr)); + SA_LEN(ifa->ifa_addr)); freeifaddrs(ifap); } else { freeifaddrs(ifap); return -1; } } else { - memcpy(&tmp_sas, ai->ai_addr, sysdep_sa_len(ai->ai_addr)); + memcpy(&tmp_sas, ai->ai_addr, SA_LEN(ai->ai_addr)); freeaddrinfo(ai); } - *sa = malloc(sysdep_sa_len((struct sockaddr *)&tmp_sas)); + *sa = malloc(SA_LEN((struct sockaddr *)&tmp_sas)); if (!*sa) return -1; - memcpy(*sa, &tmp_sas, sysdep_sa_len((struct sockaddr *)&tmp_sas)); + memcpy(*sa, &tmp_sas, SA_LEN((struct sockaddr *)&tmp_sas)); return 0; } @@ -412,7 +412,7 @@ sockaddr2text(struct sockaddr *sa, char **address, int zflag) int addrlen, i, j; long val; - if (getnameinfo(sa, sysdep_sa_len(sa), buf, sizeof buf, 0, 0, + if (getnameinfo(sa, SA_LEN(sa), buf, sizeof buf, 0, 0, allow_name_lookups ? 0 : NI_NUMERICHOST)) return -1; diff --git a/sbin/isakmpd/virtual.c b/sbin/isakmpd/virtual.c index 1a9847af92f..0471620c5e6 100644 --- a/sbin/isakmpd/virtual.c +++ b/sbin/isakmpd/virtual.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtual.c,v 1.20 2005/04/08 19:40:03 deraadt Exp $ */ +/* $OpenBSD: virtual.c,v 1.21 2005/04/08 23:15:26 hshoexer Exp $ */ /* * Copyright (c) 2004 Håkan Olsson. All rights reserved. @@ -236,7 +236,7 @@ virtual_bind(const struct sockaddr *addr) v->transport.vtbl = &virtual_transport_vtbl; - memcpy(&tmp_sa, addr, sysdep_sa_len((struct sockaddr *)addr)); + memcpy(&tmp_sa, addr, SA_LEN(addr)); /* Get port. */ stport = udp_default_port ? udp_default_port : UDP_DEFAULT_PORT_STR; @@ -256,7 +256,7 @@ virtual_bind(const struct sockaddr *addr) v->main->virtual = (struct transport *)v; if (!disable_nat_t) { - memcpy(&tmp_sa, addr, sysdep_sa_len((struct sockaddr *)addr)); + memcpy(&tmp_sa, addr, SA_LEN(addr)); /* Get port. */ stport = udp_encap_default_port @@ -348,9 +348,9 @@ virtual_bind_if(char *ifname, struct sockaddr *if_addr, void *arg) * Drop non-Internet stuff. */ if ((if_addr->sa_family != AF_INET || - sysdep_sa_len(if_addr) != sizeof (struct sockaddr_in)) && + SA_LEN(if_addr) != sizeof (struct sockaddr_in)) && (if_addr->sa_family != AF_INET6 || - sysdep_sa_len(if_addr) != sizeof (struct sockaddr_in6))) + SA_LEN(if_addr) != sizeof (struct sockaddr_in6))) return 0; /* @@ -444,8 +444,7 @@ virtual_bind_if(char *ifname, struct sockaddr *if_addr, void *arg) } /* If found, take the easy way out. */ - if (memcmp(addr, if_addr, - sysdep_sa_len(addr)) == 0) { + if (memcmp(addr, if_addr, SA_LEN(addr)) == 0) { free(addr); break; } |