Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/ipf/dist - fix alignment issues in ipmon
details: https://anonhg.NetBSD.org/src/rev/51c7896a6b7c
branches: trunk
changeset: 782225:51c7896a6b7c
user: christos <christos%NetBSD.org@localhost>
date: Sun Oct 21 22:57:48 2012 +0000
description:
- fix alignment issues in ipmon
- protoize ipmon.c, use void *, size_t instead of char *, int.
diffstat:
external/bsd/ipf/dist/ipf.h | 4 +-
external/bsd/ipf/dist/ipmon.h | 6 +-
external/bsd/ipf/dist/tools/ipmon.c | 237 +++++++++++++++------------------
external/bsd/ipf/dist/tools/ipmon_y.y | 6 +-
4 files changed, 117 insertions(+), 136 deletions(-)
diffs (truncated from 584 to 300 lines):
diff -r 4ae36ae037e1 -r 51c7896a6b7c external/bsd/ipf/dist/ipf.h
--- a/external/bsd/ipf/dist/ipf.h Sun Oct 21 22:35:52 2012 +0000
+++ b/external/bsd/ipf/dist/ipf.h Sun Oct 21 22:57:48 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipf.h,v 1.2 2012/07/22 14:27:35 darrenr Exp $ */
+/* $NetBSD: ipf.h,v 1.3 2012/10/21 22:57:48 christos Exp $ */
/*
* Copyright (C) 2012 by Darren Reed.
@@ -373,7 +373,7 @@
extern u_char seclevel __P((char *));
extern void printfraginfo __P((char *, struct ipfr *));
extern void printifname __P((char *, char *, void *));
-extern char *hostname __P((int, void *));
+extern char *hostname __P((int, const void *));
extern struct ipstate *printstate __P((struct ipstate *, int, u_long));
extern void printsbuf __P((char *));
extern void printnat __P((struct ipnat *, int));
diff -r 4ae36ae037e1 -r 51c7896a6b7c external/bsd/ipf/dist/ipmon.h
--- a/external/bsd/ipf/dist/ipmon.h Sun Oct 21 22:35:52 2012 +0000
+++ b/external/bsd/ipf/dist/ipmon.h Sun Oct 21 22:57:48 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipmon.h,v 1.2 2012/07/22 14:27:35 darrenr Exp $ */
+/* $NetBSD: ipmon.h,v 1.3 2012/10/21 22:57:48 christos Exp $ */
/*
* Copyright (C) 2012 by Darren Reed.
@@ -135,8 +135,8 @@
extern void dump_config __P((void));
extern int load_config __P((char *));
extern void unload_config __P((void));
-extern void dumphex __P((FILE *, int, char *, int));
-extern int check_action __P((char *, char *, int, int));
+extern void dumphex __P((FILE *, int, const void *, size_t));
+extern int check_action __P((const char *, const char *, int, int));
extern char *getword __P((int));
extern void *add_doing __P((ipmon_saver_t *));
diff -r 4ae36ae037e1 -r 51c7896a6b7c external/bsd/ipf/dist/tools/ipmon.c
--- a/external/bsd/ipf/dist/tools/ipmon.c Sun Oct 21 22:35:52 2012 +0000
+++ b/external/bsd/ipf/dist/tools/ipmon.c Sun Oct 21 22:57:48 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipmon.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */
+/* $NetBSD: ipmon.c,v 1.4 2012/10/21 22:57:48 christos Exp $ */
/*
* Copyright (C) 2012 by Darren Reed.
@@ -13,6 +13,7 @@
#include <ctype.h>
#include <fcntl.h>
#include <signal.h>
+#include <err.h>
#if !defined(lint)
static const char sccsid[] = "@(#)ipmon.c 1.21 6/5/96 (C)1993-2000 Darren Reed";
@@ -91,7 +92,7 @@
{ 0, '\0' }
};
-char *reasons[] = {
+const char *reasons[] = {
"filter-rule",
"log-or-block_1",
"pps-rate",
@@ -125,41 +126,40 @@
static char line[2048];
static int donehup = 0;
-static void usage __P((char *));
-static void handlehup __P((int));
-static void flushlogs __P((char *, FILE *));
-static void print_log __P((config_t *, logsource_t *, char *, int));
-static void print_ipflog __P((config_t *, char *, int));
-static void print_natlog __P((config_t *, char *, int));
-static void print_statelog __P((config_t *, char *, int));
-static int read_log __P((int, int *, char *, int));
-static void write_pid __P((char *));
-static char *icmpname __P((u_int, u_int));
-static char *icmpname6 __P((u_int, u_int));
-static icmp_type_t *find_icmptype __P((int, icmp_type_t *, size_t));
-static icmp_subtype_t *find_icmpsubtype __P((int, icmp_subtype_t *, size_t));
+static void usage(const char *);
+static void handlehup(int);
+static void flushlogs(const char *, FILE *);
+static void print_log(config_t *, logsource_t *, const void *, size_t);
+static void print_ipflog(config_t *, const void *, size_t);
+static void print_natlog(config_t *, const void *, size_t);
+static void print_statelog(config_t *, const void *, size_t);
+static int read_log(int, size_t *, void *, size_t);
+static void write_pid(const char *);
+static char *icmpname(u_int, u_int);
+static char *icmpname6(u_int, u_int);
+static icmp_type_t *find_icmptype(int, icmp_type_t *, size_t);
+static icmp_subtype_t *find_icmpsubtype(int, icmp_subtype_t *, size_t);
#ifdef __hpux
-static struct tm *get_tm __P((u_32_t));
+static struct tm *get_tm(u_32_t);
#else
-static struct tm *get_tm __P((time_t));
+static struct tm *get_tm(time_t);
#endif
-char *portlocalname __P((int, char *, u_int));
-int main __P((int, char *[]));
+char *portlocalname(int, char *, u_int);
-static void logopts __P((int, char *));
-static void init_tabs __P((void));
-static char *getlocalproto __P((u_int));
-static void openlogs __P((config_t *conf));
-static int read_loginfo __P((config_t *conf));
-static void initconfig __P((config_t *conf));
+static void logopts(int, const char *);
+static void init_tabs(void);
+static char *getlocalproto(u_int);
+static void openlogs(config_t *);
+static int read_loginfo(config_t *);
+static void initconfig(config_t *);
static char **protocols = NULL;
static char **udp_ports = NULL;
static char **tcp_ports = NULL;
-#define HOSTNAMEV4(b) hostname(AF_INET, (u_32_t *)&(b))
+#define HOSTNAMEV4(b) hostname(AF_INET, (const void *)&(b))
#ifndef LOGFAC
#define LOGFAC LOG_LOCAL0
@@ -313,10 +313,8 @@
{ -2, NULL, 0, NULL }
};
-static icmp_subtype_t *find_icmpsubtype(type, table, tablesz)
- int type;
- icmp_subtype_t *table;
- size_t tablesz;
+static icmp_subtype_t *
+find_icmpsubtype(int type, icmp_subtype_t *table, size_t tablesz)
{
icmp_subtype_t *ist;
int i;
@@ -338,10 +336,8 @@
}
-static icmp_type_t *find_icmptype(type, table, tablesz)
- int type;
- icmp_type_t *table;
- size_t tablesz;
+static icmp_type_t *
+find_icmptype(int type, icmp_type_t *table, size_t tablesz)
{
icmp_type_t *it;
int i;
@@ -363,15 +359,16 @@
}
-static void handlehup(sig)
- int sig;
+static void
+handlehup(int sig)
{
signal(SIGHUP, handlehup);
donehup = 1;
}
-static void init_tabs()
+static void
+init_tabs(void)
{
struct protoent *p;
struct servent *s;
@@ -456,8 +453,8 @@
}
-static char *getlocalproto(p)
- u_int p;
+static char *
+getlocalproto(u_int p)
{
static char pnum[4];
char *s;
@@ -472,11 +469,10 @@
}
-static int read_log(fd, lenp, buf, bufsize)
- int fd, bufsize, *lenp;
- char *buf;
+static int
+read_log(int fd, size_t *lenp, void *buf, size_t bufsize)
{
- int nr;
+ ssize_t nr;
if (bufsize > IPFILTER_LOGSIZE)
bufsize = IPFILTER_LOGSIZE;
@@ -491,10 +487,8 @@
}
-char *portlocalname(res, proto, port)
- int res;
- char *proto;
- u_int port;
+char *
+portlocalname(int res, char *proto, u_int port)
{
static char pname[8];
char *s;
@@ -515,9 +509,8 @@
}
-static char *icmpname(type, code)
- u_int type;
- u_int code;
+static char *
+icmpname(u_int type, u_int code)
{
static char name[80];
icmp_subtype_t *ist;
@@ -546,9 +539,8 @@
return name;
}
-static char *icmpname6(type, code)
- u_int type;
- u_int code;
+static char *
+icmpname6(u_int type, u_int code)
{
static char name[80];
icmp_subtype_t *ist;
@@ -578,11 +570,8 @@
}
-void dumphex(log, dopts, buf, len)
- FILE *log;
- int dopts;
- char *buf;
- int len;
+void
+dumphex(FILE *log, int dopts, const void *buf, size_t len)
{
char hline[80];
int i, j, k;
@@ -642,12 +631,14 @@
}
-static struct tm *get_tm(sec)
+static struct tm *
+get_tm(
#ifdef __hpux
- u_32_t sec;
+ u_32_t sec
#else
- time_t sec;
+ time_t sec
#endif
+)
{
struct tm *tm;
time_t t;
@@ -657,23 +648,21 @@
return tm;
}
-static void print_natlog(conf, buf, blen)
- config_t *conf;
- char *buf;
- int blen;
+static void
+print_natlog(config_t *conf, const void *buf, size_t blen)
{
static u_32_t seqnum = 0;
int res, i, len, family;
- struct natlog *nl;
+ const struct natlog *nl;
struct tm *tm;
- iplog_t *ipl;
+ const iplog_t *ipl;
char *proto;
int simple;
char *t;
t = line;
simple = 0;
- ipl = (iplog_t *)buf;
+ ipl = (const iplog_t *)buf;
if (ipl->ipl_seqnum != seqnum) {
if ((ipmonopts & IPMON_SYSLOG) != 0) {
syslog(LOG_WARNING,
@@ -689,7 +678,7 @@
Home |
Main Index |
Thread Index |
Old Index