aboutsummaryrefslogtreecommitdiff
path: root/contrib/ipfilter/ipsend/sock.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1997-11-16 04:52:19 +0000
committerPeter Wemm <peter@FreeBSD.org>1997-11-16 04:52:19 +0000
commitaf5dd3181a44c8c60d82fe2f4f8ff9ff81d98e26 (patch)
tree1abde20e1d717a2bf3509de2189cbe7fa3c9f91e /contrib/ipfilter/ipsend/sock.c
parentacdb2ce24a62f8b955af761b992ae020cc2303ef (diff)
downloadsrc-af5dd3181a44c8c60d82fe2f4f8ff9ff81d98e26.tar.gz
src-af5dd3181a44c8c60d82fe2f4f8ff9ff81d98e26.zip
Import ipfilter 3.2.1 (update from 3.1.8)
Notes
Notes: svn path=/vendor/ipfilter/dist/; revision=31183
Diffstat (limited to 'contrib/ipfilter/ipsend/sock.c')
-rw-r--r--contrib/ipfilter/ipsend/sock.c73
1 files changed, 48 insertions, 25 deletions
diff --git a/contrib/ipfilter/ipsend/sock.c b/contrib/ipfilter/ipsend/sock.c
index b75342691440..92e4a24b8bfa 100644
--- a/contrib/ipfilter/ipsend/sock.c
+++ b/contrib/ipfilter/ipsend/sock.c
@@ -1,14 +1,13 @@
/*
- * sock.c (C) 1995 Darren Reed
+ * sock.c (C) 1995-1997 Darren Reed
*
- * The author provides this program as-is, with no gaurantee for its
- * suitability for any specific purpose. The author takes no responsibility
- * for the misuse/abuse of this program and provides it for the sole purpose
- * of testing packet filter policies. This file maybe distributed freely
- * providing it is not modified and that this notice remains in tact.
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and due credit is given
+ * to the original author and the contributors.
*/
-#if !defined(lint) && defined(LIBC_SCCS)
-static char sccsid[] = "@(#)sock.c 1.2 1/11/96 (C)1995 Darren Reed";
+#if !defined(lint)
+static const char sccsid[] = "@(#)sock.c 1.2 1/11/96 (C)1995 Darren Reed";
+static const char rcsid[] = "@(#)$Id: sock.c,v 2.0.2.9 1997/09/28 07:13:37 darrenr Exp $";
#endif
#include <stdio.h>
#include <unistd.h>
@@ -20,10 +19,16 @@ static char sccsid[] = "@(#)sock.c 1.2 1/11/96 (C)1995 Darren Reed";
#include <sys/time.h>
#include <sys/param.h>
#include <sys/stat.h>
+#ifndef ultrix
#include <fcntl.h>
+#endif
#include <sys/dir.h>
#define _KERNEL
#define KERNEL
+#ifdef ultrix
+# undef LOCORE
+# include <sys/smp_lock.h>
+#endif
#include <sys/file.h>
#undef _KERNEL
#undef KERNEL
@@ -32,7 +37,9 @@ static char sccsid[] = "@(#)sock.c 1.2 1/11/96 (C)1995 Darren Reed";
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/proc.h>
-#include <kvm.h>
+#if !defined(ultrix) && !defined(hpux)
+# include <kvm.h>
+#endif
#ifdef sun
#include <sys/systm.h>
#include <sys/session.h>
@@ -89,11 +96,12 @@ void *pos;
int n;
{
static int kfd = -1;
+ off_t offset = (u_long)pos;
if (kfd == -1)
kfd = open(KMEM, O_RDONLY);
- if (lseek(kfd, (off_t)pos, SEEK_SET) == -1)
+ if (lseek(kfd, offset, SEEK_SET) == -1)
{
perror("lseek");
return -1;
@@ -106,9 +114,14 @@ int n;
return n;
}
-struct nlist names[3] = {
+struct nlist names[4] = {
{ "_proc" },
{ "_nproc" },
+#ifdef ultrix
+ { "_u" },
+#else
+ { NULL },
+#endif
{ NULL }
};
@@ -170,26 +183,35 @@ struct tcpiphdr *ti;
if (!(p = getproc()))
return NULL;
-
+printf("fl %x ty %x cn %d mc %d\n",
+f->f_flag, f->f_type, f->f_count, f->f_msgcount);
up = (struct user *)malloc(sizeof(*up));
+#ifndef ultrix
if (KMCPY(up, p->p_uarea, sizeof(*up)) == -1)
{
fprintf(stderr, "read(%#x,%#x) failed\n", p, p->p_uarea);
return NULL;
}
+#else
+ if (KMCPY(up, names[2].n_value, sizeof(*up)) == -1)
+ {
+ fprintf(stderr, "read(%#x,%#x) failed\n", p, names[2].n_value);
+ return NULL;
+ }
+#endif
o = (struct file **)calloc(1, sizeof(*o) * (up->u_lastfile + 1));
if (KMCPY(o, up->u_ofile, (up->u_lastfile + 1) * sizeof(*o)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) - u_ofile - failed\n",
- up->u_ofile_arr, o, sizeof(*o));
+ up->u_ofile, o, sizeof(*o));
return NULL;
}
f = (struct file *)calloc(1, sizeof(*f));
if (KMCPY(f, o[fd], sizeof(*f)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) - o[fd] - failed\n",
- up->u_ofile_arr[fd], f, sizeof(*f));
+ up->u_ofile[fd], f, sizeof(*f));
return NULL;
}
@@ -223,7 +245,8 @@ static struct kinfo_proc *getproc()
{
static struct kinfo_proc kp;
pid_t pid = getpid();
- int n, mib[4];
+ int mib[4];
+ size_t n;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
@@ -265,39 +288,39 @@ struct tcpiphdr *ti;
o = (struct file **)calloc(1, sizeof(*o) * (fd->fd_lastfile + 1));
if (KMCPY(o, fd->fd_ofiles, (fd->fd_lastfile + 1) * sizeof(*o)) == -1)
{
- fprintf(stderr, "read(%#lx,%#lx,%d) - u_ofile - failed\n",
- (u_long)fd->fd_ofiles, (u_long)o, sizeof(*o));
+ fprintf(stderr, "read(%#lx,%#lx,%lu) - u_ofile - failed\n",
+ (u_long)fd->fd_ofiles, (u_long)o, (u_long)sizeof(*o));
return NULL;
}
f = (struct file *)calloc(1, sizeof(*f));
if (KMCPY(f, o[tfd], sizeof(*f)) == -1)
{
- fprintf(stderr, "read(%#lx,%#lx,%d) - o[tfd] - failed\n",
- (u_long)o[tfd], (u_long)f, sizeof(*f));
+ fprintf(stderr, "read(%#lx,%#lx,%lu) - o[tfd] - failed\n",
+ (u_long)o[tfd], (u_long)f, (u_long)sizeof(*f));
return NULL;
}
s = (struct socket *)calloc(1, sizeof(*s));
if (KMCPY(s, f->f_data, sizeof(*s)) == -1)
{
- fprintf(stderr, "read(%#lx,%#lx,%d) - f_data - failed\n",
- (u_long)f->f_data, (u_long)s, sizeof(*s));
+ fprintf(stderr, "read(%#lx,%#lx,%lu) - f_data - failed\n",
+ (u_long)f->f_data, (u_long)s, (u_long)sizeof(*s));
return NULL;
}
i = (struct inpcb *)calloc(1, sizeof(*i));
if (KMCPY(i, s->so_pcb, sizeof(*i)) == -1)
{
- fprintf(stderr, "kvm_read(%#lx,%#lx,%d) - so_pcb - failed\n",
- (u_long)s->so_pcb, (u_long)i, sizeof(*i));
+ fprintf(stderr, "kvm_read(%#lx,%#lx,%lu) - so_pcb - failed\n",
+ (u_long)s->so_pcb, (u_long)i, (u_long)sizeof(*i));
return NULL;
}
t = (struct tcpcb *)calloc(1, sizeof(*t));
if (KMCPY(t, i->inp_ppcb, sizeof(*t)) == -1)
{
- fprintf(stderr, "read(%#lx,%#lx,%d) - inp_ppcb - failed\n",
- (u_long)i->inp_ppcb, (u_long)t, sizeof(*t));
+ fprintf(stderr, "read(%#lx,%#lx,%lu) - inp_ppcb - failed\n",
+ (u_long)i->inp_ppcb, (u_long)t, (u_long)sizeof(*t));
return NULL;
}
return (struct tcpcb *)i->inp_ppcb;