X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/1c79356b52d46aa6b508fb032f5ae709b1f2897b..0c530ab8987f0ae6a1a3d9284f40182b88852816:/bsd/netat/ddp_usrreq.c diff --git a/bsd/netat/ddp_usrreq.c b/bsd/netat/ddp_usrreq.c index b46a541c7..49f9ae768 100644 --- a/bsd/netat/ddp_usrreq.c +++ b/bsd/netat/ddp_usrreq.c @@ -80,18 +80,19 @@ 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 s, error = 0; + int error = 0; at_ddp_t *ddp = NULL; struct atpcb *pcb = (struct atpcb *)((so)->so_pcb); - s = splnet(); + error = soreserve(so, ddp_sendspace, ddp_recvspace); + if (error != 0) + return error; + error = at_pcballoc(so, &ddp_head); - splx(s); if (error) return error; - error = soreserve(so, ddp_sendspace, ddp_recvspace); pcb = (struct atpcb *)((so)->so_pcb); - pcb->pid = current_proc()->p_pid; + pcb->pid = proc_selfpid(); pcb->ddptype = (u_char) proto; /* set in socreate() */ pcb->proto = ATPROTO_DDP; @@ -102,7 +103,7 @@ int ddp_pru_attach(struct socket *so, int proto, int ddp_pru_disconnect(struct socket *so) { - int s, error = 0; + int error = 0; at_ddp_t *ddp = NULL; struct atpcb *pcb = (struct atpcb *)((so)->so_pcb); @@ -113,9 +114,7 @@ int ddp_pru_disconnect(struct socket *so) return ENOTCONN; soisdisconnected(so); - s = splnet(); at_pcbdetach(pcb); - splx(s); return error; } @@ -123,31 +122,25 @@ 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; } @@ -184,7 +177,14 @@ int ddp_pru_send(struct socket *so, int flags, struct mbuf *m, if (pcb == NULL) return (EINVAL); - + + /* + * Set type to MSG_DATA. Otherwise looped back packet is not + * recognized by atp_input() and possibly other protocols. + */ + + MCHTYPE(m, MSG_DATA); + if (!(pcb->ddp_flags & DDPFLG_HDRINCL)) { /* prepend a DDP header */ M_PREPEND(m, DDP_X_HDR_SIZE, M_WAIT); @@ -213,8 +213,8 @@ int ddp_pru_send(struct socket *so, int flags, struct mbuf *m, } } if (ddp) { - ddp->length = m->m_pkthdr.len; - UAS_ASSIGN(ddp->checksum, + DDPLEN_ASSIGN(ddp, m->m_pkthdr.len); + UAS_ASSIGN_HTON(ddp->checksum, (pcb->ddp_flags & DDPFLG_CHKSUM)? 1: 0); ddp->type = (pcb->ddptype)? pcb->ddptype: DEFAULT_OT_DDPTYPE; #ifdef NOT_YET @@ -243,8 +243,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(ddp->checksum)) - UAS_ASSIGN(ddp->checksum, ddp_checksum(m, 4)); + if (UAS_VALUE_NTOH(ddp->checksum)) + UAS_ASSIGN_HTON(ddp->checksum, ddp_checksum(m, 4)); ddp_input(n, ifID); } } @@ -254,16 +254,15 @@ 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; MALLOC(sat, struct sockaddr_at *, sizeof *sat, M_SONAME, M_WAITOK); + if (sat == NULL) + return(ENOMEM); bzero((caddr_t)sat, sizeof(*sat)); - s = splnet(); if ((pcb = sotoatpcb(so)) == NULL) { - splx(s); FREE(sat, M_SONAME); return(EINVAL); } @@ -272,7 +271,6 @@ 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); @@ -282,16 +280,15 @@ 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; MALLOC(sat, struct sockaddr_at *, sizeof *sat, M_SONAME, M_WAITOK); + if (sat == NULL) + return (ENOMEM); bzero((caddr_t)sat, sizeof(*sat)); - s = splnet(); if ((pcb = sotoatpcb(so)) == NULL) { - splx(s); FREE(sat, M_SONAME); return(EINVAL); } @@ -300,7 +297,6 @@ 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);