summaryrefslogtreecommitdiff
path: root/ospfd
diff options
context:
space:
mode:
authorpaul <paul>2004-05-05 17:29:24 +0000
committerpaul <paul>2004-05-05 17:29:24 +0000
commit5bd4189c17bad7a9e115ef573c0324c4b969a641 (patch)
tree3597b84769bd28b2e9cc3791c3be14ff53dde406 /ospfd
parentcd59da682f2a68cc4b2d1ba272bf02bb4d9f60e2 (diff)
2004-05-05 Paul Jakma <paul@dishone.st>
* ospf_network.c: (ospf_sock_init) Check whether IP_HDRINCL is defined. Warn at compile and runtime. Use IPTOS_PREC_INTERNETCONTROL otherwise.
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ChangeLog3
-rw-r--r--ospfd/ospf_network.c30
2 files changed, 20 insertions, 13 deletions
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index 7bff0a36..ebeaa5bc 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,5 +1,8 @@
2004-05-05 Paul Jakma <paul@dishone.st>
+ * ospf_network.c: (ospf_sock_init) Check whether IP_HDRINCL is
+ defined. Warn at compile and runtime. Use
+ IPTOS_PREC_INTERNETCONTROL otherwise.
* ospf_packet.c: (ospf_associate_packet_vl) cleanup, move
some of the checks up to ospf_read, return either a
virtual link oi, or NULL.
diff --git a/ospfd/ospf_network.c b/ospfd/ospf_network.c
index 87dfb60a..2766abd5 100644
--- a/ospfd/ospf_network.c
+++ b/ospfd/ospf_network.c
@@ -170,9 +170,20 @@ ospf_sock_init (void)
exit(-1);
}
-
+#ifdef IP_HDRINCL
+ /* we will include IP header with packet */
+ ret = setsockopt (ospf_sock, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof (hincl));
+ if (ret < 0)
+ {
+ if ( ospfd_privs.change (ZPRIVS_LOWER) )
+ zlog_err ("ospf_sock_init: could not lower privs, %s",
+ strerror (errno) );
+ zlog_warn ("Can't set IP_HDRINCL option");
+ }
+#elif defined (IPTOS_PREC_INTERNETCONTROL)
+#warning "IP_HDRINCL not available on this system"
+#warning "using IPTOS_PREC_INTERNETCONTROL"
/* Set precedence field. */
-#ifdef IPTOS_PREC_INTERNETCONTROL
tos = IPTOS_PREC_INTERNETCONTROL;
ret = setsockopt (ospf_sock, IPPROTO_IP, IP_TOS,
(char *) &tos, sizeof (int));
@@ -185,17 +196,10 @@ ospf_sock_init (void)
close (ospf_sock); /* Prevent sd leak. */
return ret;
}
-#endif /* IPTOS_PREC_INTERNETCONTROL */
-
- /* we will include IP header with packet */
- ret = setsockopt (ospf_sock, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof (hincl));
- if (ret < 0)
- {
- if ( ospfd_privs.change (ZPRIVS_LOWER) )
- zlog_err ("ospf_sock_init: could not lower privs, %s",
- strerror (errno) );
- zlog_warn ("Can't set IP_HDRINCL option");
- }
+#else /* !IPTOS_PREC_INTERNETCONTROL */
+#warning "IP_HDRINCL not available, nor is IPTOS_PREC_INTERNETCONTROL"
+ zlog_warn ("IP_HDRINCL option not available");
+#endif /* IP_HDRINCL */
#if defined (IP_PKTINFO)
ret = setsockopt (ospf_sock, IPPROTO_IP, IP_PKTINFO, &hincl, sizeof (hincl));