/* raw_cb.c 4.2 82/02/01 */
#include "../h/socketvar.h"
#include "../net/in_systm.h"
#include "../net/raw_cb.h"
#include "/usr/include/errno.h"
* Routines to manage the raw protocol control blocks.
* hash lookups by protocol family/protocol + address family
* take care of unique address problems per AF
* Allocate a control block and a nominal amount
* of buffer space for the socket.
register struct socket
*so
;
register struct rawcb
*rp
;
struct ifnet
*ifp
= ifnet
;
* Should we verify address not already in use?
* Some say yes, others no.
if (addr
) switch (addr
->sa_family
) {
register struct sockaddr_in
*sin
= (struct sockaddr_in
*)addr
;
if (ifnet
&& sin
->sin_addr
.s_addr
== 0)
sin
->sin_addr
= ifnet
->if_addr
;
ifp
= if_ifwithaddr(sin
->sin_addr
);
m
= m_getclr(M_DONTWAIT
);
if (sbreserve(&so
->so_snd
, RAWSNDQ
) == 0)
if (sbreserve(&so
->so_rcv
, RAWRCVQ
) == 0)
rp
= mtod(m
, struct rawcb
*);
so
->so_pcb
= (caddr_t
)rp
;
bcopy(addr
, &so
->so_addr
, sizeof(*addr
));
* Detach the raw connection block and discard
register struct rawcb
*rp
;
struct socket
*so
= rp
->rcb_socket
;
(void) m_freem(dtom(rp
));
* Disconnect and possibly release resources.
rp
->rcb_flags
&= ~RAW_ADDR
;
if (rp
->rcb_socket
->so_state
& SS_USERGONE
)
* Associate a peer's address with a
bcopy(addr
, &rp
->rcb_addr
, sizeof(struct sockaddr
));
rp
->rcb_flags
|= RAW_ADDR
;