static int ddp_shutdown(struct socket *so) { KASSERT(sotoddpcb(so) != NULL, ("ddp_shutdown: ddp == NULL")); socantsendmore(so); return (0); }
static int ddp_shutdown(struct socket *so) { struct ddpcb *ddp; ddp = sotoddpcb( so ); if ( ddp == NULL ) { return( EINVAL); } socantsendmore( so ); return(0); }
static int at_setsockaddr(struct socket *so, struct sockaddr **nam) { struct ddpcb *ddp; ddp = sotoddpcb( so ); if ( ddp == NULL ) { return( EINVAL); } at_sockaddr( ddp, nam ); return(0); }
static void ddp_close(struct socket *so) { struct ddpcb *ddp; ddp = sotoddpcb(so); KASSERT(ddp != NULL, ("ddp_close: ddp == NULL")); DDP_LOCK(ddp); at_pcbdisconnect(ddp); DDP_UNLOCK(ddp); soisdisconnected(so); }
static int at_getsockaddr(struct socket *so, struct sockaddr **nam) { struct ddpcb *ddp; ddp = sotoddpcb(so); KASSERT(ddp != NULL, ("at_getsockaddr: ddp == NULL")); DDP_LOCK(ddp); at_sockaddr(ddp, nam); DDP_UNLOCK(ddp); return (0); }
static void ddp_detach(struct socket *so) { struct ddpcb *ddp; ddp = sotoddpcb(so); KASSERT(ddp != NULL, ("ddp_detach: ddp == NULL")); DDP_LIST_XLOCK(); DDP_LOCK(ddp); at_pcbdetach(so, ddp); DDP_LIST_XUNLOCK(); }
static int ddp_detach(struct socket *so) { struct ddpcb *ddp; int s; ddp = sotoddpcb( so ); if ( ddp == NULL ) { return( EINVAL); } s = splnet(); at_pcbdetach( so, ddp ); splx(s); return(0); }
static int ddp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct ddpcb *ddp; int error = 0; ddp = sotoddpcb(so); KASSERT(ddp != NULL, ("ddp_bind: ddp == NULL")); DDP_LIST_XLOCK(); DDP_LOCK(ddp); error = at_pcbsetaddr(ddp, nam, td); DDP_UNLOCK(ddp); DDP_LIST_XUNLOCK(); return (error); }
static int ddp_bind(struct socket *so, struct sockaddr *nam, struct proc *p) { struct ddpcb *ddp; int error = 0; int s; ddp = sotoddpcb( so ); if ( ddp == NULL ) { return( EINVAL); } s = splnet(); error = at_pcbsetaddr(ddp, nam, p); splx(s); return (error); }
int ddp_output( struct mbuf *m, struct socket *so) { struct ddpehdr *deh; struct ddpcb *ddp = sotoddpcb( so ); #ifdef MAC mac_create_mbuf_from_socket(so, m); #endif M_PREPEND( m, sizeof( struct ddpehdr ), M_TRYWAIT ); deh = mtod( m, struct ddpehdr *); deh->deh_pad = 0; deh->deh_hops = 0; deh->deh_len = m->m_pkthdr.len; deh->deh_dnet = ddp->ddp_fsat.sat_addr.s_net; deh->deh_dnode = ddp->ddp_fsat.sat_addr.s_node; deh->deh_dport = ddp->ddp_fsat.sat_port; deh->deh_snet = ddp->ddp_lsat.sat_addr.s_net; deh->deh_snode = ddp->ddp_lsat.sat_addr.s_node; deh->deh_sport = ddp->ddp_lsat.sat_port; /* * The checksum calculation is done after all of the other bytes have * been filled in. */ if ( ddp_cksum ) { deh->deh_sum = at_cksum( m, sizeof( int )); } else { deh->deh_sum = 0; } deh->deh_bytes = htonl( deh->deh_bytes ); #ifdef NETATALK_DEBUG printf ("ddp_output: from %d.%d:%d to %d.%d:%d\n", ntohs(deh->deh_snet), deh->deh_snode, deh->deh_sport, ntohs(deh->deh_dnet), deh->deh_dnode, deh->deh_dport); #endif return( ddp_route( m, &ddp->ddp_route )); }
static int ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct proc *p) { struct ddpcb *ddp; int error = 0; int s; ddp = sotoddpcb( so ); if ( ddp == NULL ) { return(EINVAL); } if ( control && control->m_len ) { return(EINVAL); } if ( addr ) { if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) { return(EISCONN); } s = splnet(); error = at_pcbconnect(ddp, addr, p); splx( s ); if ( error ) { return(error); } } else { if ( ddp->ddp_fsat.sat_port == ATADDR_ANYPORT ) { return(ENOTCONN); } } s = splnet(); error = ddp_output( m, so ); if ( addr ) { at_pcbdisconnect( ddp ); } splx(s); return(error); }
static int ddp_disconnect(struct socket *so) { struct ddpcb *ddp; ddp = sotoddpcb(so); KASSERT(ddp != NULL, ("ddp_disconnect: ddp == NULL")); DDP_LOCK(ddp); if (ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE) { DDP_UNLOCK(ddp); return (ENOTCONN); } at_pcbdisconnect(ddp); ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE; DDP_UNLOCK(ddp); soisdisconnected(so); return (0); }
static int ddp_attach(struct socket *so, int proto, struct thread *td) { int error = 0; KASSERT(sotoddpcb(so) == NULL, ("ddp_attach: ddp != NULL")); /* * Allocate socket buffer space first so that it's present * before first use. */ error = soreserve(so, ddp_sendspace, ddp_recvspace); if (error) return (error); DDP_LIST_XLOCK(); error = at_pcballoc(so); DDP_LIST_XUNLOCK(); return (error); }
static int ddp_attach(struct socket *so, int proto, struct proc *p) { struct ddpcb *ddp; int error = 0; int s; ddp = sotoddpcb( so ); if ( ddp != NULL ) { return( EINVAL); } s = splnet(); error = at_pcballoc( so ); splx(s); if (error) { return (error); } return (soreserve( so, ddp_sendspace, ddp_recvspace )); }
static int ddp_disconnect(struct socket *so) { struct ddpcb *ddp; int s; ddp = sotoddpcb( so ); if ( ddp == NULL ) { return( EINVAL); } if ( ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE ) { return(ENOTCONN); } s = splnet(); at_pcbdisconnect( ddp ); ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE; splx(s); soisdisconnected( so ); return(0); }
static int ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td) { struct ddpcb *ddp; int error = 0; ddp = sotoddpcb(so); KASSERT(ddp != NULL, ("ddp_send: ddp == NULL")); if (control && control->m_len) return (EINVAL); if (addr != NULL) { DDP_LIST_XLOCK(); DDP_LOCK(ddp); if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT) { error = EISCONN; goto out; } error = at_pcbconnect(ddp, addr, td); if (error == 0) { error = ddp_output(m, so); at_pcbdisconnect(ddp); } out: DDP_UNLOCK(ddp); DDP_LIST_XUNLOCK(); } else { DDP_LOCK(ddp); if (ddp->ddp_fsat.sat_port == ATADDR_ANYPORT) error = ENOTCONN; else error = ddp_output(m, so); DDP_UNLOCK(ddp); } return (error); }
static int ddp_connect(struct socket *so, struct sockaddr *nam, struct proc *p) { struct ddpcb *ddp; int error = 0; int s; ddp = sotoddpcb( so ); if ( ddp == NULL ) { return( EINVAL); } if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) { return(EISCONN); } s = splnet(); error = at_pcbconnect( ddp, nam, p ); splx(s); if ( error == 0 ) soisconnected( so ); return(error); }
static int ddp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { struct ddpcb *ddp; int error = 0; ddp = sotoddpcb(so); KASSERT(ddp != NULL, ("ddp_connect: ddp == NULL")); DDP_LIST_XLOCK(); DDP_LOCK(ddp); if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT) { DDP_UNLOCK(ddp); DDP_LIST_XUNLOCK(); return (EISCONN); } error = at_pcbconnect( ddp, nam, td ); DDP_UNLOCK(ddp); DDP_LIST_XUNLOCK(); if (error == 0) soisconnected(so); return (error); }