Deleted Added
full compact
1c1
< /* $FreeBSD: stable/11/contrib/ipfilter/ipsend/sock.c 344833 2019-03-06 02:37:25Z cy $ */
---
> /* $FreeBSD: stable/11/contrib/ipfilter/ipsend/sock.c 363769 2020-08-02 04:25:36Z cy $ */
24d23
< #ifndef ultrix
26,27d24
< #endif
< #if (__FreeBSD_version >= 300000)
29,31d25
< #else
< # include <sys/dir.h>
< #endif
41,44d34
< # ifdef ultrix
< # undef LOCORE
< # include <sys/smp_lock.h>
< # endif
57d46
< #if !defined(ultrix) && !defined(hpux) && !defined(__osf__)
59d47
< #endif
64d51
< #if BSD >= 199103
68d54
< #endif
144,146d129
< #ifdef ultrix
< { "_u" },
< #else
148d130
< #endif
152,265d133
< #if BSD < 199103
< static struct proc *getproc()
< {
< struct proc *p;
< pid_t pid = getpid();
< int siz, n;
<
< n = nlist(KERNEL, names);
< if (n != 0)
< {
< fprintf(stderr, "nlist(%#x) == %d\n", names, n);
< return NULL;
< }
< if (KMCPY(&nproc, names[1].n_value, sizeof(nproc)) == -1)
< {
< fprintf(stderr, "read nproc (%#x)\n", names[1].n_value);
< return NULL;
< }
< siz = nproc * sizeof(struct proc);
< if (KMCPY(&p, names[0].n_value, sizeof(p)) == -1)
< {
< fprintf(stderr, "read(%#x,%#x,%d) proc\n",
< names[0].n_value, &p, sizeof(p));
< return NULL;
< }
< proc = (struct proc *)malloc(siz);
< if (KMCPY(proc, p, siz) == -1)
< {
< fprintf(stderr, "read(%#x,%#x,%d) proc\n",
< p, proc, siz);
< return NULL;
< }
<
< p = proc;
<
< for (n = nproc; n; n--, p++)
< if (p->p_pid == pid)
< break;
< if (!n)
< return NULL;
<
< return p;
< }
<
<
< struct tcpcb *find_tcp(fd, ti)
< int fd;
< struct tcpiphdr *ti;
< {
< struct tcpcb *t;
< struct inpcb *i;
< struct socket *s;
< struct user *up;
< struct proc *p;
< struct file *f, **o;
<
< if (!(p = getproc()))
< return NULL;
< 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(up->u_lastfile + 1, sizeof(*o));
< 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, 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[fd], f, sizeof(*f));
< return NULL;
< }
<
< s = (struct socket *)calloc(1, sizeof(*s));
< if (KMCPY(s, f->f_data, sizeof(*s)) == -1)
< {
< fprintf(stderr, "read(%#x,%#x,%d) - f_data - failed\n",
< o[fd], s, sizeof(*s));
< return NULL;
< }
<
< i = (struct inpcb *)calloc(1, sizeof(*i));
< if (KMCPY(i, s->so_pcb, sizeof(*i)) == -1)
< {
< fprintf(stderr, "kvm_read(%#x,%#x,%d) - so_pcb - failed\n",
< s->so_pcb, i, sizeof(*i));
< return NULL;
< }
<
< t = (struct tcpcb *)calloc(1, sizeof(*t));
< if (KMCPY(t, i->inp_ppcb, sizeof(*t)) == -1)
< {
< fprintf(stderr, "read(%#x,%#x,%d) - inp_ppcb - failed\n",
< i->inp_ppcb, t, sizeof(*t));
< return NULL;
< }
< return (struct tcpcb *)i->inp_ppcb;
< }
< #else
305c173
< #if defined( __FreeBSD_version) && __FreeBSD_version >= 500013
---
> #if defined( __FreeBSD_version)
382d249
< #endif /* BSD < 199301 */