Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6-0]: src/dist/ipf Pull up following revision(s) (requested by na...
details: https://anonhg.NetBSD.org/src/rev/749f36b6f8fe
branches: netbsd-6-0
changeset: 774678:749f36b6f8fe
user: riz <riz%NetBSD.org@localhost>
date: Mon Nov 19 18:06:15 2012 +0000
description:
Pull up following revision(s) (requested by nakayama in ticket #651):
external/bsd/ipf/dist/lib/hostname.c: revision 1.3
external/bsd/ipf/dist/tools/ipmon_y.y: revision 1.2
external/bsd/ipf/dist/tools/ipmon.c: revision 1.4
external/bsd/ipf/dist/tools/ipmon.c: revision 1.5
external/bsd/ipf/dist/tools/ipmon.c: revision 1.6
external/bsd/ipf/dist/ipf.h: revision 1.3
external/bsd/ipf/dist/tools/ipmon.c: revision 1.7
external/bsd/ipf/dist/ipmon.h: revision 1.3
- fix alignment issues in ipmon
- protoize ipmon.c, use void *, size_t instead of char *, int.
missed a const commit
Don't play stupid pet tricks with alignments and simplify the code not
to allocate/copy.
copy structures for alignment purposes
Remove ipl overwrite. Which was missed in previous.
diffstat:
dist/ipf/ipmon.h | 8 +-
dist/ipf/tools/ipmon.c | 569 ++++++++++++++++++++++------------------------
dist/ipf/tools/ipmon_y.y | 4 +-
3 files changed, 275 insertions(+), 306 deletions(-)
diffs (truncated from 1119 to 300 lines):
diff -r 6210e13fc83e -r 749f36b6f8fe dist/ipf/ipmon.h
--- a/dist/ipf/ipmon.h Sun Nov 18 22:05:38 2012 +0000
+++ b/dist/ipf/ipmon.h Mon Nov 19 18:06:15 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipmon.h,v 1.2 2012/02/15 17:55:04 riz Exp $ */
+/* $NetBSD: ipmon.h,v 1.2.8.1 2012/11/19 18:06:15 riz Exp $ */
/*
* Copyright (C) 1993-2001 by Darren Reed.
@@ -84,14 +84,14 @@
#define OPT_PORTNUM 0x400
#define OPT_LOGALL (OPT_NAT|OPT_STATE|OPT_FILTER)
-#define HOSTNAME_V4(a,b) hostname((a), 4, (u_32_t *)&(b))
+#define HOSTNAME_V4(a,b) hostname((a), 4, (const void *)&(b))
#ifndef LOGFAC
#define LOGFAC LOG_LOCAL0
#endif
extern int load_config(char *);
-extern void dumphex(FILE *, int, char *, int);
-extern int check_action(char *, char *, int, int);
+extern void dumphex(FILE *, int, const void *, size_t);
+extern int check_action(const char *, const char *, int, int);
extern char *getword(int);
extern int fac_findname(char *);
diff -r 6210e13fc83e -r 749f36b6f8fe dist/ipf/tools/ipmon.c
--- a/dist/ipf/tools/ipmon.c Sun Nov 18 22:05:38 2012 +0000
+++ b/dist/ipf/tools/ipmon.c Mon Nov 19 18:06:15 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipmon.c,v 1.21 2012/02/15 17:55:11 riz Exp $ */
+/* $NetBSD: ipmon.c,v 1.21.8.1 2012/11/19 18:06:15 riz Exp $ */
/*
* Copyright (C) 2001-2006 by Darren Reed.
@@ -140,32 +140,31 @@
static FILE *binarylog = NULL;
static char *binarylogfile = NULL;
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((int, FILE *, char *, int));
-static void print_ipflog __P((FILE *, char *, int));
-static void print_natlog __P((FILE *, char *, int));
-static void print_statelog __P((FILE *, 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(int, FILE *, const void *, size_t);
+static void print_ipflog(FILE *, const iplog_t *, const void *, size_t);
+static void print_natlog(FILE *, const iplog_t *, const void *, size_t);
+static void print_statelog(FILE *, const iplog_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 *hostname __P((int, int, u_32_t *));
-char *portname __P((int, char *, u_int));
-int main __P((int, char *[]));
+char *hostname(int, int, const void *);
+char *portname(int, char *, u_int);
-static void logopts __P((int, char *));
-static void init_tabs __P((void));
-static char *getproto __P((u_int));
+static void logopts(int, const char *);
+static void init_tabs(void);
+static char *getproto(u_int);
static char **protocols = NULL;
static char **udp_ports = NULL;
@@ -186,7 +185,7 @@
#define OPT_LOGALL (OPT_NAT|OPT_STATE|OPT_FILTER)
#define OPT_LOGBODY 0x800
-#define HOSTNAME_V4(a,b) hostname((a), 4, (u_32_t *)&(b))
+#define HOSTNAME_V4(a,b) hostname((a), 4, (const void *)&(b))
#ifndef LOGFAC
#define LOGFAC LOG_LOCAL0
@@ -337,10 +336,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;
@@ -362,10 +359,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;
@@ -387,15 +382,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;
@@ -480,8 +476,8 @@
}
-static char *getproto(p)
-u_int p;
+static char *
+getproto(u_int p)
{
static char pnum[4];
char *s;
@@ -496,11 +492,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;
nr = read(fd, buf, bufsize);
if (!nr)
@@ -512,9 +507,8 @@
}
-char *hostname(res, v, ip)
-int res, v;
-u_32_t *ip;
+char *
+hostname(int res, int v, const void *ip)
{
# define MAX_INETA 16
static char hname[MAXHOSTNAMELEN + MAX_INETA + 3];
@@ -525,10 +519,10 @@
struct in_addr ipa;
if (v == 4) {
- ipa.s_addr = *ip;
+ ipa.s_addr = *(const u_32_t *)ip;
if (!res)
return inet_ntoa(ipa);
- hp = gethostbyaddr((char *)ip, sizeof(*ip), AF_INET);
+ hp = gethostbyaddr(ip, 4, AF_INET);
if (!hp)
return inet_ntoa(ipa);
sprintf(hname, "%.*s[%s]", MAXHOSTNAMELEN, hp->h_name,
@@ -545,10 +539,8 @@
}
-char *portname(res, proto, port)
-int res;
-char *proto;
-u_int port;
+char *
+portname(int res, char *proto, u_int port)
{
static char pname[8];
char *s;
@@ -569,9 +561,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;
@@ -600,9 +591,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;
@@ -632,11 +622,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;
@@ -696,12 +683,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;
@@ -711,19 +700,16 @@
return tm;
}
-static void print_natlog(log, buf, blen)
-FILE *log;
-char *buf;
-int blen;
+static void
+print_natlog(FILE *log, const iplog_t *ipl, const void *buf, size_t blen)
{
- struct natlog *nl;
- iplog_t *ipl = (iplog_t *)buf;
+ struct natlog nl;
char *t = line;
struct tm *tm;
int res, i, len;
char *proto;
- nl = (struct natlog *)((char *)ipl + sizeof(*ipl));
+ memcpy(&nl, (const char *)buf + sizeof(*ipl), sizeof(nl));
res = (opts & OPT_RESOLVE) ? 1 : 0;
tm = get_tm(ipl->ipl_sec);
len = sizeof(line);
@@ -736,52 +722,52 @@
(void) strftime(t, len, "%T", tm);
t += strlen(t);
(void) sprintf(t, ".%-.6ld @%hd ", (long)ipl->ipl_usec,
- nl->nl_rule + 1);
+ nl.nl_rule + 1);
t += strlen(t);
- if (nl->nl_type == NL_NEWMAP)
+ if (nl.nl_type == NL_NEWMAP)
strcpy(t, "NAT:MAP ");
- else if (nl->nl_type == NL_NEWRDR)
Home |
Main Index |
Thread Index |
Old Index