Module Name: src
Committed By: maxv
Date: Sun Oct 14 08:27:39 UTC 2018
Modified Files:
src/crypto/dist/ipsec-tools/src/setkey: Makefile.am extern.h parse.y
setkey.c token.l
Removed Files:
src/crypto/dist/ipsec-tools/src/setkey: scriptdump.pl test-pfkey.c
Log Message:
Clean up setkey: remove dead wood, KNF, localify, and slightly improve.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/crypto/dist/ipsec-tools/src/setkey/Makefile.am
cvs rdiff -u -r1.6 -r1.7 src/crypto/dist/ipsec-tools/src/setkey/extern.h
cvs rdiff -u -r1.21 -r1.22 src/crypto/dist/ipsec-tools/src/setkey/parse.y \
src/crypto/dist/ipsec-tools/src/setkey/token.l
cvs rdiff -u -r1.1.1.1 -r0 \
src/crypto/dist/ipsec-tools/src/setkey/scriptdump.pl
cvs rdiff -u -r1.18 -r1.19 src/crypto/dist/ipsec-tools/src/setkey/setkey.c
cvs rdiff -u -r1.7 -r0 src/crypto/dist/ipsec-tools/src/setkey/test-pfkey.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/crypto/dist/ipsec-tools/src/setkey/Makefile.am
diff -u src/crypto/dist/ipsec-tools/src/setkey/Makefile.am:1.2 src/crypto/dist/ipsec-tools/src/setkey/Makefile.am:1.3
--- src/crypto/dist/ipsec-tools/src/setkey/Makefile.am:1.2 Wed Jul 23 09:06:51 2008
+++ src/crypto/dist/ipsec-tools/src/setkey/Makefile.am Sun Oct 14 08:27:39 2018
@@ -18,5 +18,4 @@ setkey_LDADD = $(LEXLIB)
noinst_HEADERS = vchar.h extern.h
man8_MANS = setkey.8
-EXTRA_DIST = ${man8_MANS} sample-policy01.cf sample-policy02.cf sample.cf \
- scriptdump.pl test-pfkey.c
+EXTRA_DIST = ${man8_MANS} sample-policy01.cf sample-policy02.cf sample.cf
Index: src/crypto/dist/ipsec-tools/src/setkey/extern.h
diff -u src/crypto/dist/ipsec-tools/src/setkey/extern.h:1.6 src/crypto/dist/ipsec-tools/src/setkey/extern.h:1.7
--- src/crypto/dist/ipsec-tools/src/setkey/extern.h:1.6 Mon May 28 20:34:45 2018
+++ src/crypto/dist/ipsec-tools/src/setkey/extern.h Sun Oct 14 08:27:39 2018
@@ -1,33 +1,54 @@
-/* $NetBSD: extern.h,v 1.6 2018/05/28 20:34:45 maxv Exp $ */
-
+/* $NetBSD: extern.h,v 1.7 2018/10/14 08:27:39 maxv Exp $ */
+/*
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/* parse.y */
void parse_init(void);
+
+/* token.l */
int parse(FILE **);
int parse_string(char *);
-int setkeymsg(char *, size_t *);
+/* setkey.c */
int sendkeymsg(char *, size_t);
+uint32_t *sendkeymsg_spigrep(unsigned int, struct addrinfo *,
+ struct addrinfo *, int *);
int yylex(void);
int yyparse(void);
void yyfatal(const char *);
void yyerror(const char *);
-u_int32_t *sendkeymsg_spigrep(unsigned int, struct addrinfo *,
- struct addrinfo *, int *);
-
+#ifdef HAVE_POLICY_FWD
extern int f_rfcmode;
+#endif
extern int lineno;
-extern int last_msg_type;
-extern u_int32_t last_priority;
extern int exit_now;
-
-extern u_char m_buf[BUFSIZ];
-extern u_int m_len;
-extern int f_debug;
-
#ifdef HAVE_PFKEY_POLICY_PRIORITY
extern int last_msg_type;
-extern u_int32_t last_priority;
+extern uint32_t last_priority;
#endif
Index: src/crypto/dist/ipsec-tools/src/setkey/parse.y
diff -u src/crypto/dist/ipsec-tools/src/setkey/parse.y:1.21 src/crypto/dist/ipsec-tools/src/setkey/parse.y:1.22
--- src/crypto/dist/ipsec-tools/src/setkey/parse.y:1.21 Mon May 28 20:34:45 2018
+++ src/crypto/dist/ipsec-tools/src/setkey/parse.y Sun Oct 14 08:27:39 2018
@@ -1,5 +1,4 @@
-/* $NetBSD: parse.y,v 1.21 2018/05/28 20:34:45 maxv Exp $ */
-
+/* $NetBSD: parse.y,v 1.22 2018/10/14 08:27:39 maxv Exp $ */
/* $KAME: parse.y,v 1.81 2003/07/01 04:01:48 itojun Exp $ */
/*
@@ -92,7 +91,7 @@ static int p_aiflags = 0, p_aifamily = P
static struct addrinfo *parse_addr(char *, char *);
static int fix_portstr(int, vchar_t *, vchar_t *, vchar_t *);
-static int setvarbuf(char *, int *, struct sadb_ext *, int,
+static int setvarbuf(char *, int *, struct sadb_ext *, int,
const void *, int);
void parse_init(void);
void free_buffer(void);
@@ -488,14 +487,14 @@ auth_alg
p_key_auth = $2.buf;
#ifdef SADB_X_AALG_TCP_MD5
if (p_alg_auth == SADB_X_AALG_TCP_MD5) {
- if ((p_key_auth_len < 1) ||
+ if ((p_key_auth_len < 1) ||
(p_key_auth_len > 80))
return -1;
- } else
+ } else
#endif
{
if (ipsec_check_keylen(SADB_EXT_SUPPORTED_AUTH,
- p_alg_auth,
+ p_alg_auth,
PFKEY_UNUNIT64(p_key_auth_len)) < 0) {
yyerror(ipsec_strerror());
return -1;
@@ -849,8 +848,8 @@ portstr_notempty
upper_spec
: DECSTRING { $$ = $1; }
| ANY { $$ = IPSEC_ULPROTO_ANY; }
- | PR_TCP {
- $$ = IPPROTO_TCP;
+ | PR_TCP {
+ $$ = IPPROTO_TCP;
}
| STRING
{
@@ -1047,13 +1046,13 @@ setkeymsg_spdaddr(unsigned int type, uns
m_sec_ctx.sadb_x_sec_len =
PFKEY_UNIT64(slen + PFKEY_ALIGN8(sec_ctx.len));
- m_sec_ctx.sadb_x_sec_exttype =
+ m_sec_ctx.sadb_x_sec_exttype =
SADB_X_EXT_SEC_CTX;
m_sec_ctx.sadb_x_ctx_len = sec_ctx.len;/*bytes*/
m_sec_ctx.sadb_x_ctx_doi = sec_ctx.doi;
m_sec_ctx.sadb_x_ctx_alg = sec_ctx.alg;
- setvarbuf(buf, &l,
- (struct sadb_ext *)&m_sec_ctx, slen,
+ setvarbuf(buf, &l,
+ (struct sadb_ext *)&m_sec_ctx, slen,
(caddr_t)sec_ctx.buf, sec_ctx.len);
}
#endif
@@ -1386,7 +1385,7 @@ setkeymsg_add(unsigned int type, unsigne
m_sec_ctx.sadb_x_ctx_doi = sec_ctx.doi;
m_sec_ctx.sadb_x_ctx_alg = sec_ctx.alg;
setvarbuf(buf, &l, (struct sadb_ext *)&m_sec_ctx, slen,
- (caddr_t)sec_ctx.buf, sec_ctx.len);
+ (caddr_t)sec_ctx.buf, sec_ctx.len);
}
#endif
Index: src/crypto/dist/ipsec-tools/src/setkey/token.l
diff -u src/crypto/dist/ipsec-tools/src/setkey/token.l:1.21 src/crypto/dist/ipsec-tools/src/setkey/token.l:1.22
--- src/crypto/dist/ipsec-tools/src/setkey/token.l:1.21 Mon May 28 19:52:18 2018
+++ src/crypto/dist/ipsec-tools/src/setkey/token.l Sun Oct 14 08:27:39 2018
@@ -1,5 +1,4 @@
-/* $NetBSD: token.l,v 1.21 2018/05/28 19:52:18 maxv Exp $ */
-
+/* $NetBSD: token.l,v 1.22 2018/10/14 08:27:39 maxv Exp $ */
/* $KAME: token.l,v 1.44 2003/10/21 07:20:58 itojun Exp $ */
/*
@@ -170,8 +169,8 @@ ah-old { yylval.num = 1; return(PR_AH);
esp-old { yylval.num = 1; return(PR_ESP); }
esp-udp { yylval.num = 0; return(PR_ESPUDP); }
ipcomp { yylval.num = 0; return(PR_IPCOMP); }
-tcp {
- yylval.num = 0; return(PR_TCP);
+tcp {
+ yylval.num = 0; return(PR_TCP);
}
/* authentication alogorithm */
@@ -188,11 +187,11 @@ tcp {
<S_AUTHALG>hmac-sha512 { yylval.num = SADB_X_AALG_SHA2_512; BEGIN INITIAL; return(ALG_AUTH); }
<S_AUTHALG>hmac-ripemd160 { yylval.num = SADB_X_AALG_RIPEMD160HMAC; BEGIN INITIAL; return(ALG_AUTH); }
<S_AUTHALG>aes-xcbc-mac { yylval.num = SADB_X_AALG_AES_XCBC_MAC; BEGIN INITIAL; return(ALG_AUTH); }
-<S_AUTHALG>tcp-md5 {
+<S_AUTHALG>tcp-md5 {
#ifdef SADB_X_AALG_TCP_MD5
- yylval.num = SADB_X_AALG_TCP_MD5;
- BEGIN INITIAL;
- return(ALG_AUTH);
+ yylval.num = SADB_X_AALG_TCP_MD5;
+ BEGIN INITIAL;
+ return(ALG_AUTH);
#endif
}
<S_AUTHALG>null { yylval.num = SADB_X_AALG_NULL; BEGIN INITIAL; return(ALG_AUTH_NOKEY); }
@@ -208,20 +207,20 @@ tcp {
<S_ENCALG>des-deriv { yylval.num = SADB_EALG_DESCBC; BEGIN INITIAL; return(ALG_ENC_DESDERIV); }
<S_ENCALG>des-32iv { yylval.num = SADB_EALG_DESCBC; BEGIN INITIAL; return(ALG_ENC_DES32IV); }
<S_ENCALG>twofish-cbc { yylval.num = SADB_X_EALG_TWOFISHCBC; BEGIN INITIAL; return(ALG_ENC); }
-<S_ENCALG>aes-cbc {
+<S_ENCALG>aes-cbc {
#ifdef SADB_X_EALG_AESCBC
- yylval.num = SADB_X_EALG_AESCBC; BEGIN INITIAL; return(ALG_ENC);
+ yylval.num = SADB_X_EALG_AESCBC; BEGIN INITIAL; return(ALG_ENC);
#endif
}
-<S_ENCALG>rijndael-cbc {
+<S_ENCALG>rijndael-cbc {
#ifdef SADB_X_EALG_AESCBC
- yylval.num = SADB_X_EALG_AESCBC; BEGIN INITIAL; return(ALG_ENC);
+ yylval.num = SADB_X_EALG_AESCBC; BEGIN INITIAL; return(ALG_ENC);
#endif
}
<S_ENCALG>aes-ctr { yylval.num = SADB_X_EALG_AESCTR; BEGIN INITIAL; return(ALG_ENC); }
-<S_ENCALG>camellia-cbc {
+<S_ENCALG>camellia-cbc {
#ifdef SADB_X_EALG_CAMELLIACBC
- yylval.num = SADB_X_EALG_CAMELLIACBC; BEGIN INITIAL; return(ALG_ENC);
+ yylval.num = SADB_X_EALG_CAMELLIACBC; BEGIN INITIAL; return(ALG_ENC);
#endif
}
<S_ENCALG>aes-gcm-16 {
@@ -355,7 +354,7 @@ parse(FILE **fp)
}
int
-parse_string (char *src)
+parse_string(char *src)
{
int result;
YY_BUFFER_STATE buf_state;
Index: src/crypto/dist/ipsec-tools/src/setkey/setkey.c
diff -u src/crypto/dist/ipsec-tools/src/setkey/setkey.c:1.18 src/crypto/dist/ipsec-tools/src/setkey/setkey.c:1.19
--- src/crypto/dist/ipsec-tools/src/setkey/setkey.c:1.18 Mon May 28 20:34:45 2018
+++ src/crypto/dist/ipsec-tools/src/setkey/setkey.c Sun Oct 14 08:27:39 2018
@@ -1,8 +1,33 @@
-/* $NetBSD: setkey.c,v 1.18 2018/05/28 20:34:45 maxv Exp $ */
-
+/* $NetBSD: setkey.c,v 1.19 2018/10/14 08:27:39 maxv Exp $ */
/* $KAME: setkey.c,v 1.36 2003/09/24 23:52:51 itojun Exp $ */
/*
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
* All rights reserved.
*
@@ -66,25 +91,24 @@
#include "config.h"
#include "libpfkey.h"
#include "package_version.h"
-#define extern /* so that variables in extern.h are not extern... */
#include "extern.h"
#define strlcpy(d,s,l) (strncpy(d,s,l), (d)[(l)-1] = '\0')
-void usage(int);
-int main(int, char **);
-int get_supported(void);
-void sendkeyshort(u_int);
-void promisc(void);
-int postproc(struct sadb_msg *, int);
-int verifypriority(struct sadb_msg *m);
-int fileproc(const char *);
-const char *numstr(int);
-void shortdump_hdr(void);
-void shortdump(struct sadb_msg *);
+static int get_supported(void);
+static void sendkeyshort(u_int);
+static void promisc(void);
+static int postproc(struct sadb_msg *, int);
+#ifdef HAVE_PFKEY_POLICY_PRIORITY
+static int verifypriority(struct sadb_msg *);
+#endif
+static int fileproc(const char *);
+static const char *numstr(int);
+static void shortdump_hdr(void);
+static void shortdump(struct sadb_msg *);
static void printdate(void);
static int32_t gmt2local(time_t);
-void stdin_loop(void);
+static void stdin_loop(void);
#define MODE_SCRIPT 1
#define MODE_CMDDUMP 2
@@ -104,13 +128,16 @@ int f_hexdump = 0;
int f_tflag = 0;
int f_notreally = 0;
int f_withports = 0;
+#ifdef HAVE_PFKEY_POLICY_PRIORITY
+int last_msg_type;
+uint32_t last_priority;
+#endif
#ifdef HAVE_POLICY_FWD
int f_rfcmode = 1;
#define RK_OPTS "rk"
#else
-int f_rkwarn = 0;
+static int f_rkwarn = 0;
#define RK_OPTS ""
-static void rkwarn(void);
static void
rkwarn(void)
{
@@ -119,15 +146,17 @@ rkwarn(void)
printf("warning: -r and -k options are not supported in this environment\n");
}
}
-
#endif
+
+int lineno;
+int exit_now;
static time_t thiszone;
-void
+static void
usage(int only_version)
{
- printf("setkey @(#) %s (%s)\n", TOP_PACKAGE_STRING, TOP_PACKAGE_URL);
- if (! only_version) {
+ printf("setkey @(#) %s (%s)\n", TOP_PACKAGE_STRING, TOP_PACKAGE_URL);
+ if (!only_version) {
printf("usage: setkey [-v" RK_OPTS "] file ...\n");
printf(" setkey [-nv" RK_OPTS "] -c\n");
printf(" setkey [-nv" RK_OPTS "] -f filename\n");
@@ -147,7 +176,6 @@ main(int argc, char **argv)
if (argc == 1) {
usage(0);
- /* NOTREACHED */
}
thiszone = gmt2local(0);
@@ -163,11 +191,10 @@ main(int argc, char **argv)
break;
case 'f':
f_mode = MODE_SCRIPT;
- if (strcmp(optarg, "-") == 0)
+ if (strcmp(optarg, "-") == 0) {
fp = stdin;
- else if ((fp = fopen(optarg, "r")) == NULL) {
+ } else if ((fp = fopen(optarg, "r")) == NULL) {
err(1, "Can't open `%s'", optarg);
- /*NOTREACHED*/
}
break;
case 'D':
@@ -221,14 +248,12 @@ main(int argc, char **argv)
case 'V':
usage(1);
break;
- /*NOTREACHED*/
#ifndef __NetBSD__
case 'h':
#endif
case '?':
default:
usage(0);
- /*NOTREACHED*/
}
}
@@ -236,11 +261,11 @@ main(int argc, char **argv)
argv += optind;
if (argc > 0) {
- while (argc--)
+ while (argc--) {
if (fileproc(*argv++) < 0) {
err(1, "%s", argv[-1]);
- /*NOTREACHED*/
}
+ }
exit(0);
}
@@ -260,30 +285,27 @@ main(int argc, char **argv)
case MODE_SCRIPT:
if (get_supported() < 0) {
errx(1, "%s", ipsec_strerror());
- /*NOTREACHED*/
}
if (parse(&fp))
- exit (1);
+ exit(1);
break;
case MODE_STDIN:
if (get_supported() < 0) {
errx(1, "%s", ipsec_strerror());
- /*NOTREACHED*/
}
stdin_loop();
break;
case MODE_PROMISC:
promisc();
- /*NOTREACHED*/
+ /* NOTREACHED */
default:
usage(0);
- /*NOTREACHED*/
}
exit(0);
}
-int
+static int
get_supported(void)
{
@@ -293,23 +315,23 @@ get_supported(void)
if (pfkey_recv_register(so) < 0)
return -1;
- return (0);
+ return 0;
}
-void
+static void
stdin_loop(void)
{
char line[1024], *semicolon, *comment;
size_t linelen = 0;
-
- memset (line, 0, sizeof(line));
+
+ memset(line, 0, sizeof(line));
parse_init();
while (1) {
#ifdef HAVE_READLINE
char *rbuf;
- rbuf = readline ("");
- if (! rbuf)
+ rbuf = readline("");
+ if (!rbuf)
break;
#else
char rbuf[1024];
@@ -326,31 +348,30 @@ stdin_loop(void)
if (!rbuf[0])
continue;
- linelen += snprintf (&line[linelen], sizeof(line) - linelen,
- "%s%s", linelen > 0 ? " " : "", rbuf);
+ linelen += snprintf(&line[linelen], sizeof(line) - linelen,
+ "%s%s", linelen > 0 ? " " : "", rbuf);
semicolon = strchr(line, ';');
while (semicolon) {
char saved_char = *++semicolon;
*semicolon = '\0';
#ifdef HAVE_READLINE
- add_history (line);
+ add_history(line);
#endif
#ifdef HAVE_PFKEY_POLICY_PRIORITY
last_msg_type = -1; /* invalid message type */
#endif
- parse_string (line);
+ parse_string(line);
if (exit_now)
return;
if (saved_char) {
*semicolon = saved_char;
- linelen = strlen (semicolon);
- memmove (line, semicolon, linelen + 1);
+ linelen = strlen(semicolon);
+ memmove(line, semicolon, linelen + 1);
semicolon = strchr(line, ';');
- }
- else {
+ } else {
semicolon = NULL;
linelen = 0;
}
@@ -358,7 +379,7 @@ stdin_loop(void)
}
}
-void
+static void
sendkeyshort(u_int type)
{
struct sadb_msg msg;
@@ -373,11 +394,9 @@ sendkeyshort(u_int type)
msg.sadb_msg_pid = getpid();
sendkeymsg((char *)&msg, sizeof(msg));
-
- return;
}
-void
+static void
promisc(void)
{
struct sadb_msg msg;
@@ -395,7 +414,6 @@ promisc(void)
if ((l = send(so, &msg, sizeof(msg), 0)) < 0) {
err(1, "send");
- /*NOTREACHED*/
}
while (1) {
@@ -403,7 +421,6 @@ promisc(void)
if ((l = recv(so, rbuf, sizeof(*base), MSG_PEEK)) < 0) {
err(1, "recv");
- /*NOTREACHED*/
}
if (l != sizeof(*base))
@@ -413,7 +430,6 @@ promisc(void)
if ((l = recv(so, rbuf, PFKEY_UNUNIT64(base->sadb_msg_len),
0)) < 0) {
err(1, "recv");
- /*NOTREACHED*/
}
printdate();
if (f_hexdump) {
@@ -443,12 +459,13 @@ promisc(void)
}
}
-/* Generate 'spi' array with SPIs matching 'satype', 'srcs', and 'dsts'
+/*
+ * Generate 'spi' array with SPIs matching 'satype', 'srcs', and 'dsts'.
* Return value is dynamically generated array of SPIs, also number of
* SPIs through num_spi pointer.
* On any error, set *num_spi to 0 and return NULL.
*/
-u_int32_t *
+uint32_t *
sendkeymsg_spigrep(unsigned int satype, struct addrinfo *srcs,
struct addrinfo *dsts, int *num_spi)
{
@@ -462,7 +479,7 @@ sendkeymsg_spigrep(unsigned int satype,
struct sockaddr *s;
struct addrinfo *a;
struct sadb_sa *sa;
- u_int32_t *spi = NULL;
+ uint32_t *spi = NULL;
int max_spi = 0, fail = 0;
*num_spi = 0;
@@ -576,12 +593,12 @@ sendkeymsg_spigrep(unsigned int satype,
if (*num_spi >= max_spi) {
max_spi += 512;
- spi = realloc(spi, max_spi * sizeof(u_int32_t));
+ spi = realloc(spi, max_spi * sizeof(uint32_t));
}
sa = (struct sadb_sa *)mhp[SADB_EXT_SA];
if (sa != NULL)
- spi[(*num_spi)++] = (u_int32_t)ntohl(sa->sadb_sa_spi);
+ spi[(*num_spi)++] = (uint32_t)ntohl(sa->sadb_sa_spi);
m = (struct sadb_msg *)((caddr_t)m + PFKEY_UNUNIT64(m->sadb_msg_len));
@@ -674,10 +691,10 @@ again:
}
end:
- return (0);
+ return 0;
}
-int
+static int
postproc(struct sadb_msg *msg, int len)
{
#ifdef HAVE_PFKEY_POLICY_PRIORITY
@@ -689,7 +706,8 @@ postproc(struct sadb_msg *msg, int len)
const char *errmsg = NULL;
if (f_mode == MODE_SCRIPT)
- snprintf(inf, sizeof(inf), "The result of line %d: ", lineno);
+ snprintf(inf, sizeof(inf), "The result of line %d: ",
+ lineno);
else
inf[0] = '\0';
@@ -713,7 +731,7 @@ postproc(struct sadb_msg *msg, int len)
errmsg = strerror(msg->sadb_msg_errno);
}
printf("%s%s.\n", inf, errmsg);
- return (-1);
+ return -1;
}
switch (msg->sadb_msg_type) {
@@ -748,35 +766,35 @@ postproc(struct sadb_msg *msg, int len)
break;
case SADB_X_SPDGET:
- if (f_withports)
+ if (f_withports)
pfkey_spdump_withports(msg);
else
pfkey_spdump(msg);
break;
case SADB_X_SPDDUMP:
- if (f_withports)
+ if (f_withports)
pfkey_spdump_withports(msg);
else
pfkey_spdump(msg);
break;
#ifdef HAVE_PFKEY_POLICY_PRIORITY
case SADB_X_SPDADD:
- if (last_msg_type == SADB_X_SPDADD && last_priority != 0 &&
+ if (last_msg_type == SADB_X_SPDADD && last_priority != 0 &&
msg->sadb_msg_pid == getpid() && !priority_support_check) {
- priority_support_check = 1;
+ priority_support_check = 1;
if (!verifypriority(msg))
- printf ("WARNING: Kernel does not support policy priorities\n");
+ printf("WARNING: Kernel does not support policy priorities\n");
}
break;
#endif
}
- return (0);
+ return 0;
}
#ifdef HAVE_PFKEY_POLICY_PRIORITY
-int
+static int
verifypriority(struct sadb_msg *m)
{
caddr_t mhp[SADB_EXT_MAX + 1];
@@ -803,11 +821,11 @@ verifypriority(struct sadb_msg *m)
if (last_priority != xpl->sadb_x_policy_priority)
return 0;
- return 1;
+ return 1;
}
#endif
-int
+static int
fileproc(const char *filename)
{
int fd;
@@ -852,11 +870,11 @@ fileproc(const char *filename)
p += len;
}
- return (0);
+ return 0;
}
+/* -------------------------------------------------------------------------- */
-/*------------------------------------------------------------*/
static const char *satype[] = {
NULL, NULL, "ah", "esp"
};
@@ -882,7 +900,7 @@ static const char *ipproto[] = {
#define STR_OR_ID(x, tab) \
(((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x))
-const char *
+static const char *
numstr(int x)
{
static char buf[20];
@@ -890,14 +908,14 @@ numstr(int x)
return buf;
}
-void
+static void
shortdump_hdr(void)
{
printf("%-4s %-3s %-1s %-8s %-7s %s -> %s\n",
- "time", "p", "s", "spi", "ltime", "src", "dst");
+ "time", "p", "s", "spi", "ltime", "src", "dst");
}
-void
+static void
shortdump(struct sadb_msg *msg)
{
caddr_t mhp[SADB_EXT_MAX + 1];
@@ -918,7 +936,7 @@ shortdump(struct sadb_msg *msg)
if ((sa = (struct sadb_sa *)mhp[SADB_EXT_SA]) != NULL) {
printf(" %-1s", STR_OR_ID(sa->sadb_sa_state, sastate));
- printf(" %08x", (u_int32_t)ntohl(sa->sadb_sa_spi));
+ printf(" %08x", (uint32_t)ntohl(sa->sadb_sa_spi));
} else
printf("%-1s %-8s", "?", "?");
@@ -996,13 +1014,12 @@ printdate(void)
if (f_tflag == 1) {
/* Default */
- s = (tp.tv_sec + thiszone ) % 86400;
- (void)printf("%02d:%02d:%02d.%06u ",
- s / 3600, (s % 3600) / 60, s % 60, (u_int32_t)tp.tv_usec);
+ s = (tp.tv_sec + thiszone) % 86400;
+ printf("%02d:%02d:%02d.%06u ",
+ s / 3600, (s % 3600) / 60, s % 60, (uint32_t)tp.tv_usec);
} else if (f_tflag > 1) {
/* Unix timeval style */
- (void)printf("%u.%06u ",
- (u_int32_t)tp.tv_sec, (u_int32_t)tp.tv_usec);
+ printf("%u.%06u ", (uint32_t)tp.tv_sec, (uint32_t)tp.tv_usec);
}
printf("\n");
@@ -1037,5 +1054,5 @@ gmt2local(time_t t)
dir = loc->tm_yday - gmt->tm_yday;
dt += dir * 24 * 60 * 60;
- return (dt);
+ return dt;
}