sockopt_reuseaddr (peer->fd);
sockopt_reuseport (peer->fd);
+#ifdef IPTOS_PREC_INTERNETCONTROL
+ if (sockunion_family (&peer->su) == AF_INET)
+ setsockopt_ipv4_tos (peer->fd, IPTOS_PREC_INTERNETCONTROL);
+#endif
+
if (peer->password)
bgp_md5_set_connect (peer->fd, &peer->su, peer->password);
sockopt_reuseaddr (sock);
sockopt_reuseport (sock);
+#ifdef IPTOS_PREC_INTERNETCONTROL
+ if (ainfo->ai_family == AF_INET)
+ setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
+#endif
+
if (bgpd_privs.change (ZPRIVS_RAISE) )
zlog_err ("bgp_socket: could not raise privs");
sockopt_reuseaddr (sock);
sockopt_reuseport (sock);
+#ifdef IPTOS_PREC_INTERNETCONTROL
+ setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
+#endif
+
memset (&sin, 0, sizeof (struct sockaddr_in));
sin.sin_family = AF_INET;
\f
/* Message lookup function. */
const char *
-lookup (struct message *mes, int key)
+lookup (const struct message *mes, int key)
{
- struct message *pnt;
+ const struct message *pnt;
for (pnt = mes; pnt->key != 0; pnt++)
if (pnt->key == key)
/* For hackey massage lookup and check */
#define LOOKUP(x, y) mes_lookup(x, x ## _max, y, "(no item found)")
-extern const char *lookup (struct message *, int);
+extern const char *lookup (const struct message *, int);
extern const char *mes_lookup (struct message *meslist,
int max, int index,
const char *no_item);
static void alloc_dec (int);
static void log_memstats(int log_priority);
\f
-static struct message mstr [] =
+static const struct message mstr [] =
{
{ MTYPE_THREAD, "thread" },
{ MTYPE_THREAD_MASTER, "thread_master" },
return ret;
}
+int
+setsockopt_ipv4_tos(int sock, int tos)
+{
+ int ret;
+
+ ret = setsockopt (sock, IPPROTO_IP, IP_TOS, &tos, sizeof (tos));
+ if (ret < 0)
+ zlog_warn ("Can't set IP_TOS option for fd %d to %#x: %s",
+ sock, tos, safe_strerror(errno));
+ return ret;
+}
+
+
int
setsockopt_ifindex (int af, int sock, int val)
{
unsigned int ifindex
/* optional: if non-zero, may be used
instead of if_addr */);
+extern int setsockopt_ipv4_tos(int sock, int tos);
/* Ask for, and get, ifindex, by whatever method is supported. */
extern int setsockopt_ifindex (int, int, int);
ospf_sock_init (void)
{
int ospf_sock;
- /*
- * XXX warning: unused variable `tos'
- * tos should be ifdefed similarly to usage
- */
- int ret, tos, hincl = 1;
+ int ret, hincl = 1;
if ( ospfd_privs.change (ZPRIVS_RAISE) )
zlog_err ("ospf_sock_init: could not raise privs, %s",
#elif defined (IPTOS_PREC_INTERNETCONTROL)
#warning "IP_HDRINCL not available on this system"
#warning "using IPTOS_PREC_INTERNETCONTROL"
- /* Set precedence field. */
- tos = IPTOS_PREC_INTERNETCONTROL;
- ret = setsockopt (ospf_sock, IPPROTO_IP, IP_TOS,
- (char *) &tos, sizeof (int));
+ ret = setsockopt_ipv4_tos(ospf_sock, IPTOS_PREC_INTERNETCONTROL);
if (ret < 0)
{
int save_errno = errno;
};
\f
/* RIP command strings. */
-struct message rip_msg[] =
+static const struct message rip_msg[] =
{
{RIP_REQUEST, "REQUEST"},
{RIP_RESPONSE, "RESPONSE"},
{RIP_TRACEOFF, "TRACEOFF"},
{RIP_POLL, "POLL"},
{RIP_POLL_ENTRY, "POLL ENTRY"},
+ {0, NULL},
};
\f
/* Utility function to set boradcast option to the socket. */
struct listnode *node;
struct interface *ifp;
struct rip_interface *ri;
- extern struct message ri_version_msg[];
+ extern const struct message ri_version_msg[];
const char *send_version;
const char *receive_version;
(LEN) = 0; \
}
/* Routing socket message types. */
-struct message rtm_type_str[] =
+const struct message rtm_type_str[] =
{
{RTM_ADD, "RTM_ADD"},
{RTM_DELETE, "RTM_DELETE"},
extern int ifm_read (struct if_msghdr *);
extern int rtm_write (int, union sockunion *, union sockunion *,
union sockunion *, unsigned int, int, int);
-extern struct message rtm_type_str[];
+extern const struct message rtm_type_str[];
#endif /* __ZEBRA_KERNEL_SOCKET_H */
} netlink = { -1, 0, {0}, "netlink-listen"}, /* kernel messages */
netlink_cmd = { -1, 0, {0}, "netlink-cmd"}; /* command channel */
-static struct message nlmsg_str[] = {
+static const struct message nlmsg_str[] = {
{RTM_NEWROUTE, "RTM_NEWROUTE"},
{RTM_DELROUTE, "RTM_DELROUTE"},
{RTM_GETROUTE, "RTM_GETROUTE"},
return 0;
}
-struct message rtproto_str[] = {
+static const struct message rtproto_str[] = {
{RTPROT_REDIRECT, "redirect"},
{RTPROT_KERNEL, "kernel"},
{RTPROT_BOOT, "boot"},