/* raw_ip.c 4.5 82/03/05 */
#include "../h/protosw.h"
#include "../h/socketvar.h"
#include "../net/in_systm.h"
#include "../net/ip_var.h"
#include "../net/raw_cb.h"
* Raw interface to IP protocol.
static struct sockaddr_in ripdst
= { PF_INET
};
static struct sockaddr_in ripsrc
= { PF_INET
};
static struct sockproto ripproto
= { AF_INET
};
* Setup generic address and protocol structures
* for raw_input routine, then pass them along with
register struct ip
*ip
= mtod(m
, struct ip
*);
ripproto
.sp_protocol
= ip
->ip_p
;
ripdst
.sin_addr
= ip
->ip_dst
;
ripsrc
.sin_addr
= ip
->ip_src
;
raw_input(m
, &ripproto
, &ripdst
, &ripsrc
);
* Generate IP header and pass packet to ip_output.
* Tack on options user may have setup with control call.
register struct rawcb
*rp
= sotorawcb(so
);
* Calculate data length and get an mbuf
for (m
= m0
; m
; m
= m
->m_next
)
* Fill in IP header as needed.
m
->m_off
= MMAXOFF
- sizeof(struct ip
);
m
->m_len
= sizeof(struct ip
);
ip
= mtod(m
, struct ip
*);
ip
->ip_p
= so
->so_proto
->pr_protocol
;
ip
->ip_len
= sizeof(struct ip
) + len
;
((struct sockaddr_in
*)&rp
->rcb_addr
)->sin_addr
;
((struct sockaddr_in
*)&so
->so_addr
)->sin_addr
;
return (ip_output(m
, 0));
* Intercept control operations related to
* handling of IP options. Otherwise,
* just pass things on to the raw_usrreq
* routine for setup and tear down of
* raw control block data structures.
rip_usrreq(so
, req
, m
, addr
)
register struct rawcb
*rp
= sotorawcb(so
);
if (rp
== 0 && req
!= PRU_ATTACH
)
* SHOULD HAVE CONTROL TO SET PROTOCOL NUMBER (e.g. GGP)
return (raw_usrreq(so
, req
, m
, addr
));