Deleted Added
sdiff udiff text old ( 344833 ) new ( 363769 )
full compact
1/* $FreeBSD: stable/11/contrib/ipfilter/ipsend/sock.c 363769 2020-08-02 04:25:36Z cy $ */
2/*
3 * sock.c (C) 1995-1998 Darren Reed
4 *
5 * See the IPFILTER.LICENCE file for details on licencing.
6 *
7 */
8#if !defined(lint)
9static const char sccsid[] = "@(#)sock.c 1.2 1/11/96 (C)1995 Darren Reed";

--- 6 unchanged lines hidden (view full) ---

16#if defined(__NetBSD__) && defined(__vax__)
17/*
18 * XXX need to declare boolean_t for _KERNEL <sys/files.h>
19 * which ends up including <sys/device.h> for vax. See PR#32907
20 * for further details.
21 */
22typedef int boolean_t;
23#endif
24#include <fcntl.h>
25# include <sys/dirent.h>
26# ifdef __NetBSD__
27# include <machine/lock.h>
28# endif
29# ifdef __FreeBSD__
30# define _WANT_FILE
31# else
32# define _KERNEL
33# define KERNEL
34# endif
35# include <sys/file.h>
36# ifdef __FreeBSD__
37# undef _WANT_FILE
38# else
39# undef _KERNEL
40# undef KERNEL
41# endif
42#include <nlist.h>
43#include <sys/user.h>
44#include <sys/socket.h>
45#include <sys/socketvar.h>
46#include <sys/proc.h>
47# include <kvm.h>
48#ifdef sun
49#include <sys/systm.h>
50#include <sys/session.h>
51#endif
52#include <sys/sysctl.h>
53#include <sys/filedesc.h>
54#include <paths.h>
55#include <math.h>
56#include <netinet/in.h>
57#include <netinet/in_systm.h>
58#include <netinet/ip.h>
59#include <netinet/tcp.h>
60#include <net/if.h>
61# include <net/route.h>
62#include <netinet/ip_var.h>

--- 59 unchanged lines hidden (view full) ---

122 return -1;
123 }
124 return n;
125}
126
127struct nlist names[4] = {
128 { "_proc" },
129 { "_nproc" },
130 { NULL },
131 { NULL }
132 };
133
134static struct kinfo_proc *getproc()
135{
136 static struct kinfo_proc kp;
137 pid_t pid = getpid();
138 int mib[4];
139 size_t n;
140
141 mib[0] = CTL_KERN;

--- 23 unchanged lines hidden (view full) ---

165 struct file *f, **o;
166
167 if (!(p = getproc()))
168 return NULL;
169
170 fd = (struct filedesc *)malloc(sizeof(*fd));
171 if (fd == NULL)
172 return NULL;
173#if defined( __FreeBSD_version)
174 if (KMCPY(fd, p->ki_fd, sizeof(*fd)) == -1)
175 {
176 fprintf(stderr, "read(%#lx,%#lx) failed\n",
177 (u_long)p, (u_long)p->ki_fd);
178 free(fd);
179 return NULL;
180 }
181#else

--- 60 unchanged lines hidden (view full) ---

242 if (s != NULL)
243 free(s);
244 if (i != NULL)
245 free(i);
246 if (t != NULL)
247 free(t);
248 return NULL;
249}
250
251int do_socket(dev, mtu, ti, gwip)
252 char *dev;
253 int mtu;
254 struct tcpiphdr *ti;
255 struct in_addr gwip;
256{
257 struct sockaddr_in rsin, lsin;

--- 63 unchanged lines hidden ---