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.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 |
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; |
366 struct sockaddr *addr; 367 struct mbuf *control; |
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); |
449 inp->inp_laddr = laddr; /* XXX rehash? */ |
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 |
507udp_bind(struct socket *so, struct sockaddr *nam, struct proc *p) |
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 |
522udp_connect(struct socket *so, struct sockaddr *nam, struct proc *p) |
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 |
576udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, |
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 --- |