Deleted Added
full compact
udp_usrreq.c (119132) udp_usrreq.c (119178)
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 * $FreeBSD: head/sys/netinet/udp_usrreq.c 119132 2003-08-19 17:11:46Z sam $
34 * $FreeBSD: head/sys/netinet/udp_usrreq.c 119178 2003-08-20 14:46:40Z bms $
35 */
36
37#include "opt_ipsec.h"
38#include "opt_inet6.h"
39#include "opt_mac.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>

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

688 struct thread *td;
689{
690 register struct udpiphdr *ui;
691 register int len = m->m_pkthdr.len;
692 struct in_addr faddr, laddr;
693 struct cmsghdr *cm;
694 struct sockaddr_in *sin, src;
695 int error = 0;
35 */
36
37#include "opt_ipsec.h"
38#include "opt_inet6.h"
39#include "opt_mac.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>

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

688 struct thread *td;
689{
690 register struct udpiphdr *ui;
691 register int len = m->m_pkthdr.len;
692 struct in_addr faddr, laddr;
693 struct cmsghdr *cm;
694 struct sockaddr_in *sin, src;
695 int error = 0;
696 int ipflags;
696 u_short fport, lport;
697
698#ifdef MAC
699 mac_create_mbuf_from_socket(inp->inp_socket, m);
700#endif
701
702 if (len + sizeof(struct udpiphdr) > IP_MAXPACKET) {
703 error = EMSGSIZE;

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

816 bzero(ui->ui_x1, sizeof(ui->ui_x1)); /* XXX still needed? */
817 ui->ui_pr = IPPROTO_UDP;
818 ui->ui_src = laddr;
819 ui->ui_dst = faddr;
820 ui->ui_sport = lport;
821 ui->ui_dport = fport;
822 ui->ui_ulen = htons((u_short)len + sizeof(struct udphdr));
823
697 u_short fport, lport;
698
699#ifdef MAC
700 mac_create_mbuf_from_socket(inp->inp_socket, m);
701#endif
702
703 if (len + sizeof(struct udpiphdr) > IP_MAXPACKET) {
704 error = EMSGSIZE;

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

817 bzero(ui->ui_x1, sizeof(ui->ui_x1)); /* XXX still needed? */
818 ui->ui_pr = IPPROTO_UDP;
819 ui->ui_src = laddr;
820 ui->ui_dst = faddr;
821 ui->ui_sport = lport;
822 ui->ui_dport = fport;
823 ui->ui_ulen = htons((u_short)len + sizeof(struct udphdr));
824
825 ipflags = inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST);
826 if (inp->inp_flags & INP_ONESBCAST)
827 ipflags |= IP_SENDONES;
828
824 /*
825 * Set up checksum and output datagram.
826 */
827 if (udpcksum) {
828 ui->ui_sum = in_pseudo(ui->ui_src.s_addr, ui->ui_dst.s_addr,
829 htons((u_short)len + sizeof(struct udphdr) + IPPROTO_UDP));
830 m->m_pkthdr.csum_flags = CSUM_UDP;
831 m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
832 } else {
833 ui->ui_sum = 0;
834 }
835 ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
836 ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
837 ((struct ip *)ui)->ip_tos = inp->inp_ip_tos; /* XXX */
838 udpstat.udps_opackets++;
839
829 /*
830 * Set up checksum and output datagram.
831 */
832 if (udpcksum) {
833 ui->ui_sum = in_pseudo(ui->ui_src.s_addr, ui->ui_dst.s_addr,
834 htons((u_short)len + sizeof(struct udphdr) + IPPROTO_UDP));
835 m->m_pkthdr.csum_flags = CSUM_UDP;
836 m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
837 } else {
838 ui->ui_sum = 0;
839 }
840 ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
841 ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
842 ((struct ip *)ui)->ip_tos = inp->inp_ip_tos; /* XXX */
843 udpstat.udps_opackets++;
844
840 error = ip_output(m, inp->inp_options, &inp->inp_route,
841 (inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST)),
845 error = ip_output(m, inp->inp_options, &inp->inp_route, ipflags,
842 inp->inp_moptions, inp);
843 return (error);
844
845release:
846 m_freem(m);
847 return (error);
848}
849

--- 239 unchanged lines hidden ---
846 inp->inp_moptions, inp);
847 return (error);
848
849release:
850 m_freem(m);
851 return (error);
852}
853

--- 239 unchanged lines hidden ---