X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/4452a7af2eac33dbad800bcc91f2399d62c18f53..6601e61aa18bf4f09af135ff61fc7f4771d23b06:/bsd/netat/ddp_usrreq.c diff --git a/bsd/netat/ddp_usrreq.c b/bsd/netat/ddp_usrreq.c index 9ad2b99f2..9331419cb 100644 --- a/bsd/netat/ddp_usrreq.c +++ b/bsd/netat/ddp_usrreq.c @@ -1,29 +1,23 @@ /* * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * - * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * @APPLE_LICENSE_HEADER_START@ * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. The rights granted to you under the License - * may not be used to create, or enable the creation or redistribution of, - * unlawful or unlicensed copies of an Apple operating system, or to - * circumvent, violate, or enable the circumvention or violation of, any - * terms of an Apple operating system software license agreement. + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. * - * Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. * - * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + * @APPLE_LICENSE_HEADER_END@ */ /* * Copyright (c) 1998 Apple Computer, Inc. @@ -86,7 +80,7 @@ int ddp_pru_control(struct socket *so, u_long cmd, caddr_t data, int ddp_pru_attach(struct socket *so, int proto, struct proc *p) { - int error = 0; + int s, error = 0; at_ddp_t *ddp = NULL; struct atpcb *pcb = (struct atpcb *)((so)->so_pcb); @@ -94,7 +88,9 @@ int ddp_pru_attach(struct socket *so, int proto, if (error != 0) return error; + s = splnet(); error = at_pcballoc(so, &ddp_head); + splx(s); if (error) return error; pcb = (struct atpcb *)((so)->so_pcb); @@ -109,7 +105,7 @@ int ddp_pru_attach(struct socket *so, int proto, int ddp_pru_disconnect(struct socket *so) { - int error = 0; + int s, error = 0; at_ddp_t *ddp = NULL; struct atpcb *pcb = (struct atpcb *)((so)->so_pcb); @@ -120,7 +116,9 @@ int ddp_pru_disconnect(struct socket *so) return ENOTCONN; soisdisconnected(so); + s = splnet(); at_pcbdetach(pcb); + splx(s); return error; } @@ -128,25 +126,31 @@ int ddp_pru_disconnect(struct socket *so) int ddp_pru_abort(struct socket *so) { + int s; struct atpcb *pcb = (struct atpcb *)((so)->so_pcb); if (pcb == NULL) return (EINVAL); soisdisconnected(so); + s = splnet(); at_pcbdetach(pcb); + splx(s); return 0; } int ddp_pru_detach(struct socket *so) { + int s; struct atpcb *pcb = (struct atpcb *)((so)->so_pcb); if (pcb == NULL) return (EINVAL); + s = splnet(); at_pcbdetach(pcb); + splx(s); return 0; } @@ -219,8 +223,8 @@ int ddp_pru_send(struct socket *so, int flags, struct mbuf *m, } } if (ddp) { - DDPLEN_ASSIGN(ddp, m->m_pkthdr.len); - UAS_ASSIGN_HTON(ddp->checksum, + ddp->length = m->m_pkthdr.len; + UAS_ASSIGN(ddp->checksum, (pcb->ddp_flags & DDPFLG_CHKSUM)? 1: 0); ddp->type = (pcb->ddptype)? pcb->ddptype: DEFAULT_OT_DDPTYPE; #ifdef NOT_YET @@ -249,8 +253,8 @@ int ddp_pru_send(struct socket *so, int flags, struct mbuf *m, NET_ASSIGN(ddp->src_net, ifID->ifThisNode.s_net); ddp->src_node = ifID->ifThisNode.s_node; ddp->src_socket = pcb->lport; - if (UAS_VALUE_NTOH(ddp->checksum)) - UAS_ASSIGN_HTON(ddp->checksum, ddp_checksum(m, 4)); + if (UAS_VALUE(ddp->checksum)) + UAS_ASSIGN(ddp->checksum, ddp_checksum(m, 4)); ddp_input(n, ifID); } } @@ -260,6 +264,7 @@ int ddp_pru_send(struct socket *so, int flags, struct mbuf *m, int ddp_pru_sockaddr(struct socket *so, struct sockaddr **nam) { + int s; struct atpcb *pcb; struct sockaddr_at *sat; @@ -268,7 +273,9 @@ int ddp_pru_sockaddr(struct socket *so, return(ENOMEM); bzero((caddr_t)sat, sizeof(*sat)); + s = splnet(); if ((pcb = sotoatpcb(so)) == NULL) { + splx(s); FREE(sat, M_SONAME); return(EINVAL); } @@ -277,6 +284,7 @@ int ddp_pru_sockaddr(struct socket *so, sat->sat_len = sizeof(*sat); sat->sat_port = pcb->lport; sat->sat_addr = pcb->laddr; + splx(s); *nam = (struct sockaddr *)sat; return(0); @@ -286,6 +294,7 @@ int ddp_pru_sockaddr(struct socket *so, int ddp_pru_peeraddr(struct socket *so, struct sockaddr **nam) { + int s; struct atpcb *pcb; struct sockaddr_at *sat; @@ -294,7 +303,9 @@ int ddp_pru_peeraddr(struct socket *so, return (ENOMEM); bzero((caddr_t)sat, sizeof(*sat)); + s = splnet(); if ((pcb = sotoatpcb(so)) == NULL) { + splx(s); FREE(sat, M_SONAME); return(EINVAL); } @@ -303,6 +314,7 @@ int ddp_pru_peeraddr(struct socket *so, sat->sat_len = sizeof(*sat); sat->sat_port = pcb->rport; sat->sat_addr = pcb->raddr; + splx(s); *nam = (struct sockaddr *)sat; return(0);