Skip to content

Commit

Permalink
Make it possible to use IP_TTL and IP_TOS setsockopt(2) options
Browse files Browse the repository at this point in the history
on certain types of SOCK_RAW sockets.  Also, use the ip.ttl MIB
variable instead of MAXTTL constant as the default time-to-live
value for outgoing IP packets all over the place, as we already
do this for TCP and UDP.

Reviewed by:	wollman
  • Loading branch information
ru authored and ru committed Mar 9, 2001
1 parent a64bcb9 commit 5639e86
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions share/man/man4/ip.4
Expand Up @@ -32,9 +32,9 @@
.\" @(#)ip.4 8.2 (Berkeley) 11/30/93
.\" $FreeBSD$
.\"
.Dd November 30, 1993
.Dd March 3, 2001
.Dt IP 4
.Os BSD 4.2
.Os
.Sh NAME
.Nm ip
.Nd Internet Protocol
Expand Down Expand Up @@ -100,9 +100,9 @@ may be used to set the type-of-service and time-to-live
fields in the
.Tn IP
header for
.Dv SOCK_STREAM
and
.Dv SOCK_DGRAM
.Dv SOCK_STREAM , SOCK_DGRAM ,
and certain types of
.Dv SOCK_RAW
sockets.
For example,
.Bd -literal
Expand Down Expand Up @@ -355,7 +355,7 @@ setsockopt(s, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof(hincl));
.Ed
.Pp
Unlike previous
.Tn BSD
.Bx
releases, the program must set all
the fields of the IP header, including the following:
.Bd -literal
Expand Down
2 changes: 1 addition & 1 deletion sys/netinet/ip_icmp.c
Expand Up @@ -638,7 +638,7 @@ icmp_reflect(m)
ia = TAILQ_FIRST(&in_ifaddrhead);
t = IA_SIN(ia)->sin_addr;
ip->ip_src = t;
ip->ip_ttl = MAXTTL;
ip->ip_ttl = ip_defttl;

if (optlen > 0) {
register u_char *cp;
Expand Down
5 changes: 3 additions & 2 deletions sys/netinet/raw_ip.c
Expand Up @@ -197,13 +197,13 @@ rip_output(m, so, dst)
}
M_PREPEND(m, sizeof(struct ip), M_TRYWAIT);
ip = mtod(m, struct ip *);
ip->ip_tos = 0;
ip->ip_tos = inp->inp_ip_tos;
ip->ip_off = 0;
ip->ip_p = inp->inp_ip_p;
ip->ip_len = m->m_pkthdr.len;
ip->ip_src = inp->inp_laddr;
ip->ip_dst.s_addr = dst;
ip->ip_ttl = MAXTTL;
ip->ip_ttl = inp->inp_ip_ttl;
} else {
if (m->m_pkthdr.len > IP_MAXPACKET) {
m_freem(m);
Expand Down Expand Up @@ -458,6 +458,7 @@ rip_attach(struct socket *so, int proto, struct proc *p)
inp = (struct inpcb *)so->so_pcb;
inp->inp_vflag |= INP_IPV4;
inp->inp_ip_p = proto;
inp->inp_ip_ttl = ip_defttl;
#ifdef IPSEC
error = ipsec_init_policy(so, &inp->inp_sp);
if (error != 0) {
Expand Down

0 comments on commit 5639e86

Please sign in to comment.