From 983e538712449c9c50a119ea4f2cefba6be3798b Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 26 Jun 2005 23:49:31 +0000 Subject: [PATCH] Collect externs into one file instead of duplicating them everywhere. --- crypto/dist/ipsec-tools/src/setkey/extern.h | 27 +++++++++++++++++++++ crypto/dist/ipsec-tools/src/setkey/parse.y | 21 +++------------- crypto/dist/ipsec-tools/src/setkey/setkey.c | 23 +++--------------- crypto/dist/ipsec-tools/src/setkey/token.l | 17 +++---------- 4 files changed, 37 insertions(+), 51 deletions(-) create mode 100644 crypto/dist/ipsec-tools/src/setkey/extern.h diff --git a/crypto/dist/ipsec-tools/src/setkey/extern.h b/crypto/dist/ipsec-tools/src/setkey/extern.h new file mode 100644 index 000000000000..e98eab3c78f8 --- /dev/null +++ b/crypto/dist/ipsec-tools/src/setkey/extern.h @@ -0,0 +1,27 @@ + +void parse_init __P((void)); +int parse __P((FILE **)); +int parse_string __P((char *)); + +int setkeymsg __P((char *, size_t *)); +int sendkeymsg __P((char *, size_t)); + +int yylex __P((void)); +int yyparse __P((void)); +void yyfatal __P((const char *)); +void yyerror __P((const char *)); + +extern int f_rfcmode; +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; +#endif diff --git a/crypto/dist/ipsec-tools/src/setkey/parse.y b/crypto/dist/ipsec-tools/src/setkey/parse.y index 96aa029566a3..765aab23e6c5 100644 --- a/crypto/dist/ipsec-tools/src/setkey/parse.y +++ b/crypto/dist/ipsec-tools/src/setkey/parse.y @@ -1,4 +1,4 @@ -/* $NetBSD: parse.y,v 1.2 2005/04/10 21:20:55 manu Exp $ */ +/* $NetBSD: parse.y,v 1.3 2005/06/26 23:49:31 christos Exp $ */ /* $KAME: parse.y,v 1.81 2003/07/01 04:01:48 itojun Exp $ */ @@ -59,6 +59,7 @@ #include "libpfkey.h" #include "vchar.h" +#include "extern.h" #define DEFAULT_NATT_PORT 4500 @@ -78,13 +79,6 @@ caddr_t p_key_enc, p_key_auth; time_t p_lt_hard, p_lt_soft; size_t p_lb_hard, p_lb_soft; -#ifdef HAVE_PFKEY_POLICY_PRIORITY -extern int last_msg_type; -extern u_int32_t last_priority; -#endif - -extern int exit_now; - static u_int p_natt_type; static struct addrinfo * p_natt_oa = NULL; @@ -93,7 +87,6 @@ static int p_aiflags = 0, p_aifamily = PF_UNSPEC; static struct addrinfo *parse_addr __P((char *, char *)); static int fix_portstr __P((vchar_t *, vchar_t *, vchar_t *)); static int setvarbuf __P((char *, int *, struct sadb_ext *, int, caddr_t, int)); -void parse_init __P((void)); void free_buffer __P((void)); int setkeymsg0 __P((struct sadb_msg *, unsigned int, unsigned int, size_t)); @@ -104,13 +97,7 @@ static int setkeymsg_addr __P((unsigned int, unsigned int, struct addrinfo *, struct addrinfo *, int)); static int setkeymsg_add __P((unsigned int, unsigned int, struct addrinfo *, struct addrinfo *)); -extern int setkeymsg __P((char *, size_t *)); -extern int sendkeymsg __P((char *, size_t)); -extern int yylex __P((void)); -extern void yyfatal __P((const char *)); -extern void yyerror __P((const char *)); -extern int f_rfcmode; %} %union { @@ -1168,8 +1155,8 @@ static u_int16_t get_port (struct addrinfo *addr) switch (s->sa_family) { case AF_INET: { - struct sockaddr_in *sin = (struct sockaddr_in *)s; - port = ntohs(sin->sin_port); + struct sockaddr_in *sin4 = (struct sockaddr_in *)s; + port = ntohs(sin4->sin_port); break; } case AF_INET6: diff --git a/crypto/dist/ipsec-tools/src/setkey/setkey.c b/crypto/dist/ipsec-tools/src/setkey/setkey.c index 6fe271f7b515..a8cf75ec3bf0 100644 --- a/crypto/dist/ipsec-tools/src/setkey/setkey.c +++ b/crypto/dist/ipsec-tools/src/setkey/setkey.c @@ -1,4 +1,4 @@ -/* $NetBSD: setkey.c,v 1.5 2005/06/26 23:34:26 christos Exp $ */ +/* $NetBSD: setkey.c,v 1.6 2005/06/26 23:49:31 christos Exp $ */ /* KAME: setkey.c,v 1.36 2003/09/24 23:52:51 itojun Exp */ @@ -70,6 +70,8 @@ #include "config.h" #include "libpfkey.h" #include "package_version.h" +#define extern +#include "extern.h" #define strlcpy(d,s,l) (strncpy(d,s,l), (d)[(l)-1] = '\0') @@ -78,7 +80,6 @@ int main __P((int, char **)); int get_supported __P((void)); void sendkeyshort __P((u_int)); void promisc __P((void)); -int sendkeymsg __P((char *, size_t)); int postproc __P((struct sadb_msg *, int)); int verifypriority __P((struct sadb_msg *m)); int fileproc __P((const char *)); @@ -89,8 +90,6 @@ static void printdate __P((void)); static int32_t gmt2local __P((time_t)); void stdin_loop __P((void)); -extern void parse_init __P((void)); - #define MODE_SCRIPT 1 #define MODE_CMDDUMP 2 #define MODE_CMDFLUSH 3 @@ -128,22 +127,6 @@ rkwarn(void) #endif static time_t thiszone; -extern int lineno; - -#ifdef HAVE_PFKEY_POLICY_PRIORITY -extern int last_msg_type; -int last_msg_type = -1; - -extern u_int32_t last_priority; -u_int32_t last_priority = 0; -#endif - -extern int exit_now; -int exit_now = 0; - -extern int parse __P((FILE **)); -extern int parse_string __P((char *)); - void usage(int only_version) { diff --git a/crypto/dist/ipsec-tools/src/setkey/token.l b/crypto/dist/ipsec-tools/src/setkey/token.l index 5f3d037a23d8..8a0c47dff9cb 100644 --- a/crypto/dist/ipsec-tools/src/setkey/token.l +++ b/crypto/dist/ipsec-tools/src/setkey/token.l @@ -1,4 +1,4 @@ -/* $NetBSD: token.l,v 1.3 2005/05/08 08:57:26 manu Exp $ */ +/* $NetBSD: token.l,v 1.4 2005/06/26 23:49:31 christos Exp $ */ /* $KAME: token.l,v 1.44 2003/10/21 07:20:58 itojun Exp $ */ @@ -61,19 +61,7 @@ #else #include "y.tab.h" #endif - -int lineno = 1; - -extern u_char m_buf[BUFSIZ]; -extern u_int m_len; -extern int f_debug; - -int yylex __P((void)); -void yyfatal __P((const char *s)); -void yyerror __P((const char *s)); -extern void parse_init __P((void)); -int parse __P((FILE **)); -int yyparse __P((void)); +#include "extern.h" /* make the code compile on *BSD-current */ #ifndef SADB_X_AALG_SHA2_256 @@ -335,6 +323,7 @@ parse(fp) { yyin = *fp; + lineno = 1; parse_init(); if (yyparse()) {