Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/crypto/dist/ipsec-tools/src/racoon Style, a lit...
details: https://anonhg.NetBSD.org/src/rev/7c7e06faf32a
branches: trunk
changeset: 319182:7c7e06faf32a
user: maxv <maxv%NetBSD.org@localhost>
date: Sat May 19 18:51:59 2018 +0000
description:
Style, a little...
diffstat:
crypto/dist/ipsec-tools/src/racoon/main.c | 21 +-
crypto/dist/ipsec-tools/src/racoon/nattraversal.c | 177 ++++++++++-----------
crypto/dist/ipsec-tools/src/racoon/nattraversal.h | 65 +++----
3 files changed, 128 insertions(+), 135 deletions(-)
diffs (truncated from 395 to 300 lines):
diff -r 4d822d864434 -r 7c7e06faf32a crypto/dist/ipsec-tools/src/racoon/main.c
--- a/crypto/dist/ipsec-tools/src/racoon/main.c Sat May 19 18:19:37 2018 +0000
+++ b/crypto/dist/ipsec-tools/src/racoon/main.c Sat May 19 18:51:59 2018 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: main.c,v 1.13 2013/07/12 13:11:50 tteras Exp $ */
+/* $NetBSD: main.c,v 1.14 2018/05/19 18:51:59 maxv Exp $ */
/* Id: main.c,v 1.25 2006/06/20 20:31:34 manubsd Exp */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -17,7 +17,7 @@
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -85,9 +85,9 @@
#ifdef TOP_PACKAGE
static char version[] = "@(#)" TOP_PACKAGE_STRING " (" TOP_PACKAGE_URL ")";
-#else /* TOP_PACKAGE */
+#else
static char version[] = "@(#) racoon / IPsec-tools";
-#endif /* TOP_PACKAGE */
+#endif
static void
print_version()
@@ -162,9 +162,7 @@
}
static void
-parse(ac, av)
- int ac;
- char **av;
+parse(int ac, char **av)
{
extern char *optarg;
extern int optind;
@@ -264,9 +262,7 @@
}
int
-main(ac, av)
- int ac;
- char **av;
+main(int ac, char **av)
{
int error;
@@ -308,7 +304,7 @@
plog(LLV_INFO, LOCATION, NULL, "@(#)"
"This product linked %s (http://www.openssl.org/)"
"\n", eay_version());
- plog(LLV_INFO, LOCATION, NULL, "Reading configuration from \"%s\"\n",
+ plog(LLV_INFO, LOCATION, NULL, "Reading configuration from \"%s\"\n",
lcconf->racoon_conf);
/*
@@ -346,4 +342,3 @@
return 0;
}
-
diff -r 4d822d864434 -r 7c7e06faf32a crypto/dist/ipsec-tools/src/racoon/nattraversal.c
--- a/crypto/dist/ipsec-tools/src/racoon/nattraversal.c Sat May 19 18:19:37 2018 +0000
+++ b/crypto/dist/ipsec-tools/src/racoon/nattraversal.c Sat May 19 18:51:59 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nattraversal.c,v 1.14 2011/03/14 17:18:13 tteras Exp $ */
+/* $NetBSD: nattraversal.c,v 1.15 2018/05/19 18:51:59 maxv Exp $ */
/*
* Copyright (C) 2004 SuSE Linux AG, Nuernberg, Germany.
@@ -230,118 +230,117 @@
}
int
-natt_fill_options (struct ph1natt_options *opts, int version)
+natt_fill_options(struct ph1natt_options *opts, int version)
{
- if (! opts)
- return -1;
-
- opts->version = version;
+ if (!opts)
+ return -1;
- switch (version) {
- case VENDORID_NATT_00:
- case VENDORID_NATT_01:
- opts->float_port = 0; /* No port floating for those drafts */
- opts->payload_nat_d = ISAKMP_NPTYPE_NATD_DRAFT;
- opts->payload_nat_oa = ISAKMP_NPTYPE_NATOA_DRAFT;
- opts->mode_udp_tunnel = IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT;
- opts->mode_udp_transport = IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT;
- opts->encaps_type = UDP_ENCAP_ESPINUDP_NON_IKE;
- break;
+ opts->version = version;
- case VENDORID_NATT_02:
- case VENDORID_NATT_02_N:
- case VENDORID_NATT_03:
- opts->float_port = lcconf->port_isakmp_natt;
- opts->payload_nat_d = ISAKMP_NPTYPE_NATD_DRAFT;
- opts->payload_nat_oa = ISAKMP_NPTYPE_NATOA_DRAFT;
- opts->mode_udp_tunnel = IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT;
- opts->mode_udp_transport = IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT;
- opts->encaps_type = UDP_ENCAP_ESPINUDP;
- break;
- case VENDORID_NATT_04:
- case VENDORID_NATT_05:
- case VENDORID_NATT_06:
- case VENDORID_NATT_07:
- case VENDORID_NATT_08:
- opts->float_port = lcconf->port_isakmp_natt;
- opts->payload_nat_d = ISAKMP_NPTYPE_NATD_BADDRAFT;
- opts->payload_nat_oa = ISAKMP_NPTYPE_NATOA_BADDRAFT;
- opts->mode_udp_tunnel = IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC;
- opts->mode_udp_transport = IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC;
- opts->encaps_type = UDP_ENCAP_ESPINUDP;
- break;
- case VENDORID_NATT_RFC:
- opts->float_port = lcconf->port_isakmp_natt;
- opts->payload_nat_d = ISAKMP_NPTYPE_NATD_RFC;
- opts->payload_nat_oa = ISAKMP_NPTYPE_NATOA_RFC;
- opts->mode_udp_tunnel = IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC;
- opts->mode_udp_transport = IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC;
- opts->encaps_type = UDP_ENCAP_ESPINUDP;
- break;
- default:
- plog(LLV_ERROR, LOCATION, NULL,
- "unsupported NAT-T version: %s\n",
- vid_string_by_id(version));
- return -1;
- }
-
- opts->mode_udp_diff = opts->mode_udp_tunnel - IPSECDOI_ATTR_ENC_MODE_TUNNEL;
+ switch (version) {
+ case VENDORID_NATT_00:
+ case VENDORID_NATT_01:
+ opts->float_port = 0; /* No port floating for those drafts */
+ opts->payload_nat_d = ISAKMP_NPTYPE_NATD_DRAFT;
+ opts->payload_nat_oa = ISAKMP_NPTYPE_NATOA_DRAFT;
+ opts->mode_udp_tunnel = IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT;
+ opts->mode_udp_transport = IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT;
+ opts->encaps_type = UDP_ENCAP_ESPINUDP_NON_IKE;
+ break;
+ case VENDORID_NATT_02:
+ case VENDORID_NATT_02_N:
+ case VENDORID_NATT_03:
+ opts->float_port = lcconf->port_isakmp_natt;
+ opts->payload_nat_d = ISAKMP_NPTYPE_NATD_DRAFT;
+ opts->payload_nat_oa = ISAKMP_NPTYPE_NATOA_DRAFT;
+ opts->mode_udp_tunnel = IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT;
+ opts->mode_udp_transport = IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT;
+ opts->encaps_type = UDP_ENCAP_ESPINUDP;
+ break;
+ case VENDORID_NATT_04:
+ case VENDORID_NATT_05:
+ case VENDORID_NATT_06:
+ case VENDORID_NATT_07:
+ case VENDORID_NATT_08:
+ opts->float_port = lcconf->port_isakmp_natt;
+ opts->payload_nat_d = ISAKMP_NPTYPE_NATD_BADDRAFT;
+ opts->payload_nat_oa = ISAKMP_NPTYPE_NATOA_BADDRAFT;
+ opts->mode_udp_tunnel = IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC;
+ opts->mode_udp_transport = IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC;
+ opts->encaps_type = UDP_ENCAP_ESPINUDP;
+ break;
+ case VENDORID_NATT_RFC:
+ opts->float_port = lcconf->port_isakmp_natt;
+ opts->payload_nat_d = ISAKMP_NPTYPE_NATD_RFC;
+ opts->payload_nat_oa = ISAKMP_NPTYPE_NATOA_RFC;
+ opts->mode_udp_tunnel = IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC;
+ opts->mode_udp_transport = IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC;
+ opts->encaps_type = UDP_ENCAP_ESPINUDP;
+ break;
+ default:
+ plog(LLV_ERROR, LOCATION, NULL,
+ "unsupported NAT-T version: %s\n",
+ vid_string_by_id(version));
+ return -1;
+ }
- return 0;
+ opts->mode_udp_diff = opts->mode_udp_tunnel - IPSECDOI_ATTR_ENC_MODE_TUNNEL;
+
+ return 0;
}
void
-natt_float_ports (struct ph1handle *iph1)
+natt_float_ports(struct ph1handle *iph1)
{
- if (! (iph1->natt_flags & NAT_DETECTED) )
+ if (!(iph1->natt_flags & NAT_DETECTED))
return;
- if (! iph1->natt_options->float_port){
+ if (!iph1->natt_options->float_port) {
/* Drafts 00 / 01, just schedule keepalive */
natt_keepalive_add_ph1 (iph1);
return;
}
-
- set_port (iph1->local, iph1->natt_options->float_port);
- set_port (iph1->remote, iph1->natt_options->float_port);
+
+ set_port(iph1->local, iph1->natt_options->float_port);
+ set_port(iph1->remote, iph1->natt_options->float_port);
iph1->natt_flags |= NAT_PORTS_CHANGED | NAT_ADD_NON_ESP_MARKER;
-
- natt_keepalive_add_ph1 (iph1);
+
+ natt_keepalive_add_ph1(iph1);
}
static int
-natt_is_enabled (struct remoteconf *rmconf, void *args)
+natt_is_enabled(struct remoteconf *rmconf, void *args)
{
- if (rmconf->nat_traversal)
- return 1;
- return 0;
+ if (rmconf->nat_traversal)
+ return 1;
+ return 0;
}
void
-natt_handle_vendorid (struct ph1handle *iph1, int vid_numeric)
+natt_handle_vendorid(struct ph1handle *iph1, int vid_numeric)
{
- if (iph1->rmconf == NULL) {
- /* Check if any candidate remote conf allows nat-t */
- struct rmconfselector rmconf;
- rmconf_selector_from_ph1(&rmconf, iph1);
- if (enumrmconf(&rmconf, natt_is_enabled, NULL) == 0)
- return;
- } else {
- if (!iph1->rmconf->nat_traversal)
- return;
- }
+ if (iph1->rmconf == NULL) {
+ /* Check if any candidate remote conf allows nat-t */
+ struct rmconfselector rmconf;
+ rmconf_selector_from_ph1(&rmconf, iph1);
+ if (enumrmconf(&rmconf, natt_is_enabled, NULL) == 0)
+ return;
+ } else {
+ if (!iph1->rmconf->nat_traversal)
+ return;
+ }
- if (! iph1->natt_options)
- iph1->natt_options = racoon_calloc (1, sizeof (*iph1->natt_options));
+ if (!iph1->natt_options)
+ iph1->natt_options = racoon_calloc(1, sizeof(*iph1->natt_options));
- if (! iph1->natt_options) {
- plog (LLV_ERROR, LOCATION, NULL,
- "Allocating memory for natt_options failed!\n");
- return;
- }
-
- if (iph1->natt_options->version < vid_numeric)
- if (natt_fill_options (iph1->natt_options, vid_numeric) == 0)
- iph1->natt_flags |= NAT_ANNOUNCED;
+ if (!iph1->natt_options) {
+ plog(LLV_ERROR, LOCATION, NULL,
+ "Allocating memory for natt_options failed!\n");
+ return;
+ }
+
+ if (iph1->natt_options->version < vid_numeric)
+ if (natt_fill_options(iph1->natt_options, vid_numeric) == 0)
+ iph1->natt_flags |= NAT_ANNOUNCED;
}
static void
diff -r 4d822d864434 -r 7c7e06faf32a crypto/dist/ipsec-tools/src/racoon/nattraversal.h
--- a/crypto/dist/ipsec-tools/src/racoon/nattraversal.h Sat May 19 18:19:37 2018 +0000
+++ b/crypto/dist/ipsec-tools/src/racoon/nattraversal.h Sat May 19 18:51:59 2018 +0000
@@ -1,10 +1,10 @@
-/* $NetBSD: nattraversal.h,v 1.7 2010/09/22 07:34:51 vanhu Exp $ */
+/* $NetBSD: nattraversal.h,v 1.8 2018/05/19 18:51:59 maxv Exp $ */
/*
* Copyright (C) 2004 SuSE Linux AG, Nuernberg, Germany.
* Contributed by: Michal Ludvig <mludvig%suse.cz@localhost>, SUSE Labs
* All rights reserved.
Home |
Main Index |
Thread Index |
Old Index