Deleted Added
full compact
udp_usrreq.c (25201) udp_usrreq.c (28270)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
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 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
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 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
34 * $Id: udp_usrreq.c,v 1.37 1997/04/03 05:14:45 davidg Exp $
34 * $Id: udp_usrreq.c,v 1.38 1997/04/27 20:01:16 wollman Exp $
35 */
36
37#include <sys/param.h>
38#include <sys/queue.h>
39#include <sys/systm.h>
40#include <sys/errno.h>
41#include <sys/kernel.h>
42#include <sys/malloc.h>

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

85#endif
86
87static struct udpstat udpstat; /* from udp_var.h */
88SYSCTL_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RD,
89 &udpstat, udpstat, "");
90
91static struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET };
92
35 */
36
37#include <sys/param.h>
38#include <sys/queue.h>
39#include <sys/systm.h>
40#include <sys/errno.h>
41#include <sys/kernel.h>
42#include <sys/malloc.h>

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

85#endif
86
87static struct udpstat udpstat; /* from udp_var.h */
88SYSCTL_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RD,
89 &udpstat, udpstat, "");
90
91static struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET };
92
93static int udp_output __P((struct inpcb *, struct mbuf *, struct mbuf *,
93static int udp_output __P((struct inpcb *, struct mbuf *, struct sockaddr *,
94 struct mbuf *, struct proc *));
95static void udp_notify __P((struct inpcb *, int));
96
97void
98udp_init()
99{
100 LIST_INIT(&udb);
101 udbinfo.listhead = &udb;

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

358 } else
359 in_pcbnotify(&udb, sa, 0, zeroin_addr, 0, cmd, udp_notify);
360}
361
362static int
363udp_output(inp, m, addr, control, p)
364 register struct inpcb *inp;
365 register struct mbuf *m;
94 struct mbuf *, struct proc *));
95static void udp_notify __P((struct inpcb *, int));
96
97void
98udp_init()
99{
100 LIST_INIT(&udb);
101 udbinfo.listhead = &udb;

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

358 } else
359 in_pcbnotify(&udb, sa, 0, zeroin_addr, 0, cmd, udp_notify);
360}
361
362static int
363udp_output(inp, m, addr, control, p)
364 register struct inpcb *inp;
365 register struct mbuf *m;
366 struct mbuf *addr, *control;
366 struct sockaddr *addr;
367 struct mbuf *control;
367 struct proc *p;
368{
369 register struct udpiphdr *ui;
370 register int len = m->m_pkthdr.len;
371 struct in_addr laddr;
372 int s = 0, error = 0;
373
374 if (control)

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

440 ((struct ip *)ui)->ip_tos = inp->inp_ip_tos; /* XXX */
441 udpstat.udps_opackets++;
442 error = ip_output(m, inp->inp_options, &inp->inp_route,
443 inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST),
444 inp->inp_moptions);
445
446 if (addr) {
447 in_pcbdisconnect(inp);
368 struct proc *p;
369{
370 register struct udpiphdr *ui;
371 register int len = m->m_pkthdr.len;
372 struct in_addr laddr;
373 int s = 0, error = 0;
374
375 if (control)

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

441 ((struct ip *)ui)->ip_tos = inp->inp_ip_tos; /* XXX */
442 udpstat.udps_opackets++;
443 error = ip_output(m, inp->inp_options, &inp->inp_route,
444 inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST),
445 inp->inp_moptions);
446
447 if (addr) {
448 in_pcbdisconnect(inp);
448 inp->inp_laddr = laddr;
449 inp->inp_laddr = laddr; /* XXX rehash? */
449 splx(s);
450 }
451 return (error);
452
453release:
454 m_freem(m);
455 return (error);
456}

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

498 error = soreserve(so, udp_sendspace, udp_recvspace);
499 if (error)
500 return error;
501 ((struct inpcb *) so->so_pcb)->inp_ip_ttl = ip_defttl;
502 return 0;
503}
504
505static int
450 splx(s);
451 }
452 return (error);
453
454release:
455 m_freem(m);
456 return (error);
457}

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

499 error = soreserve(so, udp_sendspace, udp_recvspace);
500 if (error)
501 return error;
502 ((struct inpcb *) so->so_pcb)->inp_ip_ttl = ip_defttl;
503 return 0;
504}
505
506static int
506udp_bind(struct socket *so, struct mbuf *nam, struct proc *p)
507udp_bind(struct socket *so, struct sockaddr *nam, struct proc *p)
507{
508 struct inpcb *inp;
509 int s, error;
510
511 inp = sotoinpcb(so);
512 if (inp == 0)
513 return EINVAL;
514 s = splnet();
515 error = in_pcbbind(inp, nam, p);
516 splx(s);
517 return error;
518}
519
520static int
508{
509 struct inpcb *inp;
510 int s, error;
511
512 inp = sotoinpcb(so);
513 if (inp == 0)
514 return EINVAL;
515 s = splnet();
516 error = in_pcbbind(inp, nam, p);
517 splx(s);
518 return error;
519}
520
521static int
521udp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
522udp_connect(struct socket *so, struct sockaddr *nam, struct proc *p)
522{
523 struct inpcb *inp;
524 int s, error;
525
526 inp = sotoinpcb(so);
527 if (inp == 0)
528 return EINVAL;
529 if (inp->inp_faddr.s_addr != INADDR_ANY)

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

567 in_pcbdisconnect(inp);
568 inp->inp_laddr.s_addr = INADDR_ANY;
569 splx(s);
570 so->so_state &= ~SS_ISCONNECTED; /* XXX */
571 return 0;
572}
573
574static int
523{
524 struct inpcb *inp;
525 int s, error;
526
527 inp = sotoinpcb(so);
528 if (inp == 0)
529 return EINVAL;
530 if (inp->inp_faddr.s_addr != INADDR_ANY)

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

568 in_pcbdisconnect(inp);
569 inp->inp_laddr.s_addr = INADDR_ANY;
570 splx(s);
571 so->so_state &= ~SS_ISCONNECTED; /* XXX */
572 return 0;
573}
574
575static int
575udp_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr,
576udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
576 struct mbuf *control, struct proc *p)
577{
578 struct inpcb *inp;
579
580 inp = sotoinpcb(so);
581 if (inp == 0) {
582 m_freem(m);
583 return EINVAL;

--- 23 unchanged lines hidden ---
577 struct mbuf *control, struct proc *p)
578{
579 struct inpcb *inp;
580
581 inp = sotoinpcb(so);
582 if (inp == 0) {
583 m_freem(m);
584 return EINVAL;

--- 23 unchanged lines hidden ---