Deleted Added
full compact
uipc_socket.c (72471) uipc_socket.c (72521)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94
34 * $FreeBSD: head/sys/kern/uipc_socket.c 72471 2001-02-14 02:09:11Z jlemon $
34 * $FreeBSD: head/sys/kern/uipc_socket.c 72521 2001-02-15 16:34:11Z jlemon $
35 */
36
37#include "opt_inet.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/fcntl.h>
42#include <sys/malloc.h>

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

59#include <vm/vm_zone.h>
60
61#include <machine/limits.h>
62
63#ifdef INET
64static int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt);
65#endif
66
35 */
36
37#include "opt_inet.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/fcntl.h>
42#include <sys/malloc.h>

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

59#include <vm/vm_zone.h>
60
61#include <machine/limits.h>
62
63#ifdef INET
64static int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt);
65#endif
66
67static int filt_sorattach(struct knote *kn);
68static void filt_sordetach(struct knote *kn);
69static int filt_soread(struct knote *kn, long hint);
67static void filt_sordetach(struct knote *kn);
68static int filt_soread(struct knote *kn, long hint);
70static int filt_sowattach(struct knote *kn);
71static void filt_sowdetach(struct knote *kn);
72static int filt_sowrite(struct knote *kn, long hint);
73static int filt_solisten(struct knote *kn, long hint);
74
75static struct filterops solisten_filtops =
69static void filt_sowdetach(struct knote *kn);
70static int filt_sowrite(struct knote *kn, long hint);
71static int filt_solisten(struct knote *kn, long hint);
72
73static struct filterops solisten_filtops =
76 { 1, filt_sorattach, filt_sordetach, filt_solisten };
74 { 1, NULL, filt_sordetach, filt_solisten };
75static struct filterops soread_filtops =
76 { 1, NULL, filt_sordetach, filt_soread };
77static struct filterops sowrite_filtops =
78 { 1, NULL, filt_sowdetach, filt_sowrite };
77
79
78struct filterops so_rwfiltops[] = {
79 { 1, filt_sorattach, filt_sordetach, filt_soread },
80 { 1, filt_sowattach, filt_sowdetach, filt_sowrite },
81};
82
83struct vm_zone *socket_zone;
84so_gen_t so_gencnt; /* generation count for sockets */
85
86MALLOC_DEFINE(M_SONAME, "soname", "socket name");
87MALLOC_DEFINE(M_PCB, "pcb", "protocol control block");
88
89SYSCTL_DECL(_kern_ipc);
90

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

1529 so->so_snd.sb_flags |= SB_SEL;
1530 }
1531 }
1532
1533 splx(s);
1534 return (revents);
1535}
1536
80struct vm_zone *socket_zone;
81so_gen_t so_gencnt; /* generation count for sockets */
82
83MALLOC_DEFINE(M_SONAME, "soname", "socket name");
84MALLOC_DEFINE(M_PCB, "pcb", "protocol control block");
85
86SYSCTL_DECL(_kern_ipc);
87

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

1526 so->so_snd.sb_flags |= SB_SEL;
1527 }
1528 }
1529
1530 splx(s);
1531 return (revents);
1532}
1533
1537static int
1538filt_sorattach(struct knote *kn)
1534int
1535sokqfilter(struct file *fp, struct knote *kn)
1539{
1540 struct socket *so = (struct socket *)kn->kn_fp->f_data;
1536{
1537 struct socket *so = (struct socket *)kn->kn_fp->f_data;
1541 int s = splnet();
1538 struct sockbuf *sb;
1539 int s;
1542
1540
1543 if (so->so_options & SO_ACCEPTCONN)
1544 kn->kn_fop = &solisten_filtops;
1545 SLIST_INSERT_HEAD(&so->so_rcv.sb_sel.si_note, kn, kn_selnext);
1546 so->so_rcv.sb_flags |= SB_KNOTE;
1541 switch (kn->kn_filter) {
1542 case EVFILT_READ:
1543 if (so->so_options & SO_ACCEPTCONN)
1544 kn->kn_fop = &solisten_filtops;
1545 else
1546 kn->kn_fop = &soread_filtops;
1547 sb = &so->so_rcv;
1548 break;
1549 case EVFILT_WRITE:
1550 kn->kn_fop = &sowrite_filtops;
1551 sb = &so->so_snd;
1552 break;
1553 default:
1554 return (1);
1555 }
1556
1557 s = splnet();
1558 SLIST_INSERT_HEAD(&sb->sb_sel.si_note, kn, kn_selnext);
1559 sb->sb_flags |= SB_KNOTE;
1547 splx(s);
1548 return (0);
1549}
1550
1551static void
1552filt_sordetach(struct knote *kn)
1553{
1554 struct socket *so = (struct socket *)kn->kn_fp->f_data;

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

1571 kn->kn_flags |= EV_EOF;
1572 return (1);
1573 }
1574 if (so->so_error) /* temporary udp error */
1575 return (1);
1576 return (kn->kn_data >= so->so_rcv.sb_lowat);
1577}
1578
1560 splx(s);
1561 return (0);
1562}
1563
1564static void
1565filt_sordetach(struct knote *kn)
1566{
1567 struct socket *so = (struct socket *)kn->kn_fp->f_data;

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

1584 kn->kn_flags |= EV_EOF;
1585 return (1);
1586 }
1587 if (so->so_error) /* temporary udp error */
1588 return (1);
1589 return (kn->kn_data >= so->so_rcv.sb_lowat);
1590}
1591
1579static int
1580filt_sowattach(struct knote *kn)
1581{
1582 struct socket *so = (struct socket *)kn->kn_fp->f_data;
1583 int s = splnet();
1584
1585 SLIST_INSERT_HEAD(&so->so_snd.sb_sel.si_note, kn, kn_selnext);
1586 so->so_snd.sb_flags |= SB_KNOTE;
1587 splx(s);
1588 return (0);
1589}
1590
1591static void
1592filt_sowdetach(struct knote *kn)
1593{
1594 struct socket *so = (struct socket *)kn->kn_fp->f_data;
1595 int s = splnet();
1596
1597 SLIST_REMOVE(&so->so_snd.sb_sel.si_note, kn, knote, kn_selnext);
1598 if (SLIST_EMPTY(&so->so_snd.sb_sel.si_note))

--- 32 unchanged lines hidden ---
1592static void
1593filt_sowdetach(struct knote *kn)
1594{
1595 struct socket *so = (struct socket *)kn->kn_fp->f_data;
1596 int s = splnet();
1597
1598 SLIST_REMOVE(&so->so_snd.sb_sel.si_note, kn, knote, kn_selnext);
1599 if (SLIST_EMPTY(&so->so_snd.sb_sel.si_note))

--- 32 unchanged lines hidden ---