[lib] mes_lookup string lookup table argument should be marked const

2008-08-14 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* lib/log.{c,h}: struct message argument should point to const
	* */*.c: adjust to suit,

Signed-off-by: Paul Jakma <paul@quagga.net>
This commit is contained in:
Stephen Hemminger 2008-08-14 17:59:25 +01:00 committed by Paul Jakma
parent 89d9fa301e
commit 1423c809cc
11 changed files with 41 additions and 19 deletions

View File

@ -314,6 +314,11 @@ bgp_connect (struct peer *peer)
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);
@ -402,6 +407,11 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address)
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");
@ -454,6 +464,10 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address)
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;

View File

@ -740,9 +740,9 @@ zlog_rotate (struct zlog *zl)
/* 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)

View File

@ -144,7 +144,7 @@ extern int zlog_rotate (struct zlog *);
/* 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);

View File

@ -33,7 +33,7 @@ static void alloc_inc (int);
static void alloc_dec (int);
static void log_memstats(int log_priority);
static struct message mstr [] =
static const struct message mstr [] =
{
{ MTYPE_THREAD, "thread" },
{ MTYPE_THREAD_MASTER, "thread_master" },

View File

@ -342,6 +342,19 @@ setsockopt_ipv4_ifindex (int sock, int val)
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)
{

View File

@ -89,6 +89,7 @@ extern int setsockopt_multicast_ipv4(int sock, int optname,
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);

View File

@ -165,11 +165,7 @@ 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",
@ -201,10 +197,7 @@ ospf_sock_init (void)
#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;

View File

@ -76,7 +76,7 @@ enum
};
/* RIP command strings. */
struct message rip_msg[] =
static const struct message rip_msg[] =
{
{RIP_REQUEST, "REQUEST"},
{RIP_RESPONSE, "RESPONSE"},
@ -84,6 +84,7 @@ struct message rip_msg[] =
{RIP_TRACEOFF, "TRACEOFF"},
{RIP_POLL, "POLL"},
{RIP_POLL_ENTRY, "POLL ENTRY"},
{0, NULL},
};
/* Utility function to set boradcast option to the socket. */
@ -3508,7 +3509,7 @@ DEFUN (show_ip_rip_status,
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;

View File

@ -126,7 +126,7 @@ extern struct zebra_t zebrad;
(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"},

View File

@ -28,6 +28,6 @@ extern int ifam_read (struct ifa_msghdr *);
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 */

View File

@ -52,7 +52,7 @@ struct nlsock
} 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"},
@ -805,7 +805,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h)
return 0;
}
struct message rtproto_str[] = {
static const struct message rtproto_str[] = {
{RTPROT_REDIRECT, "redirect"},
{RTPROT_KERNEL, "kernel"},
{RTPROT_BOOT, "boot"},