2004-10-11 Paul Jakma <paul@dishone.st>
* (global) Const char update and signed/unsigned fixes.
* (various headers) size defines should be unsigned.
* ospf_interface.h: remove duplicated defines, include the
authoritative header - though, these defines should probably
be moved to a dedicated header, or ospfd.h.
* ospf_lsa.h: (struct lsa) ls_seqnum should be unsigned.
* ospf_packet.c: (ospf_write) cast result of shift to unsigned.
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index 34bf640..75e3b4d 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -10,6 +10,13 @@
(ospf_recv_packet) ip_len is needed for old OpenBSD fixup.
(ospf_read) sockopt_iphdrincl_swab_systoh ip header as soon as
we have it.
+ * (global) Const char update and signed/unsigned fixes.
+ * (various headers) size defines should be unsigned.
+ * ospf_interface.h: remove duplicated defines, include the
+ authoritative header - though, these defines should probably
+ be moved to a dedicated header, or ospfd.h.
+ * ospf_lsa.h: (struct lsa) ls_seqnum should be unsigned.
+ * ospf_packet.c: (ospf_write) cast result of shift to unsigned.
2004-10-08 Hasso Tepper <hasso at quagga.net>
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index e23ace2..51fb2d6 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -565,7 +565,7 @@
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_update_aggregate(): Start");
- if (range->cost_config != -1)
+ if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_abr_update_aggregate(): use configured cost %d",
diff --git a/ospfd/ospf_abr.h b/ospfd/ospf_abr.h
index 3b385c3..11c0d9b 100644
--- a/ospfd/ospf_abr.h
+++ b/ospfd/ospf_abr.h
@@ -52,7 +52,7 @@
/* Configured range cost. */
u_int32_t cost_config;
-#define OSPF_AREA_RANGE_COST_UNSPEC -1
+#define OSPF_AREA_RANGE_COST_UNSPEC -1U
};
/* Prototypes. */
@@ -75,10 +75,10 @@
struct ospf_area_range *ospf_area_range_match_any (struct ospf *,
struct prefix_ipv4 *);
int ospf_area_range_active (struct ospf_area_range *);
-int ospf_act_bb_connection ();
+int ospf_act_bb_connection (struct ospf *);
-void ospf_check_abr_status ();
-void ospf_abr_task ();
-void ospf_schedule_abr_task ();
+void ospf_check_abr_status (struct ospf *);
+void ospf_abr_task (struct ospf *);
+void ospf_schedule_abr_task (struct ospf *);
#endif /* _ZEBRA_OSPF_ABR_H */
diff --git a/ospfd/ospf_interface.h b/ospfd/ospf_interface.h
index 0f3cecd..ed6abed 100644
--- a/ospfd/ospf_interface.h
+++ b/ospfd/ospf_interface.h
@@ -23,8 +23,7 @@
#ifndef _ZEBRA_OSPF_INTERFACE_H
#define _ZEBRA_OSPF_INTERFACE_H
-#define OSPF_AUTH_SIMPLE_SIZE 8
-#define OSPF_AUTH_MD5_SIZE 16
+#include "ospfd/ospf_packet.h"
#define IF_OSPF_IF_INFO(I) ((struct ospf_if_info *)((I)->info))
#define IF_DEF_PARAMS(I) (IF_OSPF_IF_INFO (I)->def_params)
diff --git a/ospfd/ospf_lsa.h b/ospfd/ospf_lsa.h
index 6d60b57..6d10e64 100644
--- a/ospfd/ospf_lsa.h
+++ b/ospfd/ospf_lsa.h
@@ -45,8 +45,8 @@
#define OSPF_OPAQUE_AREA_LSA 10
#define OSPF_OPAQUE_AS_LSA 11
-#define OSPF_LSA_HEADER_SIZE 20
-#define OSPF_MAX_LSA_SIZE 1500
+#define OSPF_LSA_HEADER_SIZE 20U
+#define OSPF_MAX_LSA_SIZE 1500U
/* AS-external-LSA refresh method. */
#define LSA_REFRESH_IF_CHANGED 0
@@ -60,7 +60,7 @@
u_char type;
struct in_addr id;
struct in_addr adv_router;
- int ls_seqnum;
+ u_int32_t ls_seqnum;
u_int16_t checksum;
u_int16_t length;
};
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index d62a06e..dc1ee0b 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -241,7 +241,7 @@
return new;
}
-int
+unsigned int
ospf_packet_max (struct ospf_interface *oi)
{
int max;
@@ -261,7 +261,7 @@
ospf_check_md5_digest (struct ospf_interface *oi, struct stream *s,
u_int16_t length)
{
- void *ibuf;
+ unsigned char *ibuf;
struct md5_ctx ctx;
unsigned char digest[OSPF_AUTH_MD5_SIZE];
unsigned char *pdigest;
@@ -486,7 +486,8 @@
void
ospf_write_frags (int fd, struct ospf_packet *op, struct ip *iph,
struct msghdr *msg, struct iovec **iov,
- int maxdatasize, int mtu, int flags)
+ unsigned int maxdatasize,
+ unsigned int mtu, int flags)
{
#define OSPF_WRITE_FRAG_SHIFT 3
u_int16_t offset;
@@ -617,7 +618,8 @@
iph.ip_hl = sizeof (struct ip) >> OSPF_WRITE_IPHL_SHIFT;
/* it'd be very strange for header to not be 4byte-word aligned but.. */
- if ( sizeof (struct ip) > (iph.ip_hl << OSPF_WRITE_IPHL_SHIFT) )
+ if ( sizeof (struct ip)
+ > (unsigned int)(iph.ip_hl << OSPF_WRITE_IPHL_SHIFT) )
iph.ip_hl++; /* we presume sizeof struct ip cant overflow ip_hl.. */
iph.ip_v = IPVERSION;
@@ -1326,7 +1328,7 @@
struct in_addr adv_router;
struct ospf_lsa *find;
struct list *ls_upd;
- int length;
+ unsigned int length;
/* Increment statistics. */
oi->ls_req_in++;
diff --git a/ospfd/ospf_packet.h b/ospfd/ospf_packet.h
index 48f4e13..8de0bfb 100644
--- a/ospfd/ospf_packet.h
+++ b/ospfd/ospf_packet.h
@@ -23,16 +23,16 @@
#ifndef _ZEBRA_OSPF_PACKET_H
#define _ZEBRA_OSPF_PACKET_H
-#define OSPF_HEADER_SIZE 24
-#define OSPF_AUTH_SIMPLE_SIZE 8
-#define OSPF_AUTH_MD5_SIZE 16
+#define OSPF_HEADER_SIZE 24U
+#define OSPF_AUTH_SIMPLE_SIZE 8U
+#define OSPF_AUTH_MD5_SIZE 16U
-#define OSPF_MAX_PACKET_SIZE 65535 /* includes IP Header size. */
-#define OSPF_HELLO_MIN_SIZE 20 /* not including neighbors */
-#define OSPF_DB_DESC_MIN_SIZE 8
-#define OSPF_LS_REQ_MIN_SIZE 0
-#define OSPF_LS_UPD_MIN_SIZE 4
-#define OSPF_LS_ACK_MIN_SIZE 0
+#define OSPF_MAX_PACKET_SIZE 65535U /* includes IP Header size. */
+#define OSPF_HELLO_MIN_SIZE 20U /* not including neighbors */
+#define OSPF_DB_DESC_MIN_SIZE 8U
+#define OSPF_LS_REQ_MIN_SIZE 0U
+#define OSPF_LS_UPD_MIN_SIZE 4U
+#define OSPF_LS_ACK_MIN_SIZE 0U
#define OSPF_MSG_HELLO 1 /* OSPF Hello Message. */
#define OSPF_MSG_DB_DESC 2 /* OSPF Database Descriptoin Message. */
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index 52fa901..074a2de 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -41,7 +41,7 @@
/* Hook function for updating route_map assignment. */
void
-ospf_route_map_update (char *name)
+ospf_route_map_update (const char *name)
{
struct ospf *ospf;
int type;
@@ -74,7 +74,7 @@
}
void
-ospf_route_map_event (route_map_event_t event, char *name)
+ospf_route_map_event (route_map_event_t event, const char *name)
{
struct ospf *ospf;
int type;
@@ -98,7 +98,7 @@
/* Delete rip route map rule. */
int
ospf_route_match_delete (struct vty *vty, struct route_map_index *index,
- const char *command, char *arg)
+ const char *command, const char *arg)
{
int ret;
@@ -123,7 +123,7 @@
int
ospf_route_match_add (struct vty *vty, struct route_map_index *index,
- const char *command, char *arg)
+ const char *command, const char *arg)
{
int ret;
@@ -148,7 +148,7 @@
int
ospf_route_set_add (struct vty *vty, struct route_map_index *index,
- const char *command, char *arg)
+ const char *command, const char *arg)
{
int ret;
@@ -174,7 +174,7 @@
/* Delete rip route map rule. */
int
ospf_route_set_delete (struct vty *vty, struct route_map_index *index,
- const char *command, char *arg)
+ const char *command, const char *arg)
{
int ret;
@@ -226,7 +226,7 @@
/* Route map `ip next-hop' match statement. `arg' should be
access-list name. */
void *
-route_match_ip_nexthop_compile (char *arg)
+route_match_ip_nexthop_compile (const char *arg)
{
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
}
@@ -274,7 +274,7 @@
}
void *
-route_match_ip_next_hop_prefix_list_compile (char *arg)
+route_match_ip_next_hop_prefix_list_compile (const char *arg)
{
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
}
@@ -318,7 +318,7 @@
/* Route map `ip address' match statement. `arg' should be
access-list name. */
void *
-route_match_ip_address_compile (char *arg)
+route_match_ip_address_compile (const char *arg)
{
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
}
@@ -359,7 +359,7 @@
}
void *
-route_match_ip_address_prefix_list_compile (char *arg)
+route_match_ip_address_prefix_list_compile (const char *arg)
{
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
}
@@ -404,7 +404,7 @@
/* Route map `interface' match statement. `arg' should be
interface name. */
void *
-route_match_interface_compile (char *arg)
+route_match_interface_compile (const char *arg)
{
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
}
@@ -448,7 +448,7 @@
/* set metric compilation. */
void *
-route_set_metric_compile (char *arg)
+route_set_metric_compile (const char *arg)
{
u_int32_t *metric;
@@ -501,7 +501,7 @@
/* set metric-type compilation. */
void *
-route_set_metric_type_compile (char *arg)
+route_set_metric_type_compile (const char *arg)
{
u_int32_t *metric_type;
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index 3be3ce4..ccb6498 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -919,7 +919,7 @@
struct ospf *ospf;
struct ospf_area *area;
struct ospf_lsa *lsa;
- int len;
+ unsigned int len;
int type_next;
int ls_id_next;
int router_id_next;
@@ -1130,7 +1130,7 @@
{
oid *offset;
int offsetlen;
- int len;
+ unsigned int len;
struct ospf *ospf;
struct ospf_area *area;
struct ospf_area_range *range;
@@ -1566,7 +1566,7 @@
ospfIfLookup (struct variable *v, oid *name, size_t *length,
struct in_addr *ifaddr, unsigned int *ifindex, int exact)
{
- int len;
+ unsigned int len;
int ifaddr_next = 0;
int ifindex_next = 0;
struct interface *ifp;
@@ -1731,7 +1731,7 @@
ospfIfMetricLookup (struct variable *v, oid *name, size_t *length,
struct in_addr *ifaddr, unsigned int *ifindex, int exact)
{
- int len;
+ unsigned int len;
int ifaddr_next = 0;
int ifindex_next = 0;
struct interface *ifp;
@@ -1943,7 +1943,7 @@
struct in_addr *area_id, struct in_addr *neighbor, int exact)
{
int first;
- int len;
+ unsigned int len;
struct ospf_vl_data *vl_data;
if (exact)
@@ -2128,7 +2128,7 @@
ospfNbrLookup (struct variable *v, oid *name, size_t *length,
struct in_addr *nbr_addr, unsigned int *ifindex, int exact)
{
- int len;
+ unsigned int len;
int first;
struct ospf_neighbor *nbr;
struct ospf *ospf;
@@ -2300,7 +2300,7 @@
oid *offset;
int offsetlen;
u_char lsa_type;
- int len;
+ unsigned int len;
struct ospf_lsa *lsa;
struct ospf *ospf;
@@ -2477,8 +2477,6 @@
void
ospf_snmp_init ()
{
- struct ospf *ospf;
-
ospf_snmp_iflist = list_new ();
ospf_snmp_vl_table = route_table_init ();
smux_init (om->master, ospfd_oid, sizeof (ospfd_oid) / sizeof (oid));
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index a498003..f62f35c 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -267,7 +267,7 @@
{
struct listnode *node;
struct mpls_te_link *lp;
- int key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
+ unsigned int key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
LIST_LOOP (OspfMplsTE.iflist, lp, node)
if (lp->instance == key)
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index b74a304..0ecb6fb 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -63,7 +63,7 @@
/* Utility functions. */
int
-ospf_str2area_id (char *str, struct in_addr *area_id, int *format)
+ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
{
char *endptr = NULL;
unsigned long ret;
@@ -92,7 +92,7 @@
int
-str2distribute_source (char *str, int *source)
+str2distribute_source (const char *str, int *source)
{
/* Sanity check. */
if (str == NULL)
@@ -115,7 +115,7 @@
}
int
-str2metric (char *str, int *metric)
+str2metric (const char *str, int *metric)
{
/* Sanity check. */
if (str == NULL)
@@ -132,7 +132,7 @@
}
int
-str2metric_type (char *str, int *metric_type)
+str2metric_type (const char *str, int *metric_type)
{
/* Sanity check. */
if (str == NULL)
@@ -1471,7 +1471,8 @@
}
int
-ospf_area_nssa_cmd_handler (struct vty *vty, int argc, char **argv, int nosum)
+ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
+ int nosum)
{
struct ospf *ospf = vty->index;
struct in_addr area_id;
@@ -6965,7 +6966,7 @@
vty_out (vty, " area %s range %s/%d", buf,
inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
- if (range->cost_config != -1)
+ if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
vty_out (vty, " cost %d", range->cost_config);
if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 3172ebc..331c27c 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -756,7 +756,7 @@
/* OSPF route-map set for redistribution */
void
-ospf_routemap_set (struct ospf *ospf, int type, char *name)
+ospf_routemap_set (struct ospf *ospf, int type, const char *name)
{
if (ROUTEMAP_NAME (ospf, type))
free (ROUTEMAP_NAME (ospf, type));
@@ -883,7 +883,7 @@
int
-ospf_distribute_list_out_set (struct ospf *ospf, int type, char *name)
+ospf_distribute_list_out_set (struct ospf *ospf, int type, const char *name)
{
/* Lookup access-list for distribute-list. */
DISTRIBUTE_LIST (ospf, type) = access_list_lookup (AFI_IP, name);
@@ -903,7 +903,7 @@
}
int
-ospf_distribute_list_out_unset (struct ospf *ospf, int type, char *name)
+ospf_distribute_list_out_unset (struct ospf *ospf, int type, const char *name)
{
/* Schedule update timer. */
if (DISTRIBUTE_LIST (ospf, type))
@@ -1120,8 +1120,10 @@
}
int
-ospf_distance_set (struct vty *vty, struct ospf *ospf, char *distance_str,
- char *ip_str, char *access_list_str)
+ospf_distance_set (struct vty *vty, struct ospf *ospf,
+ const char *distance_str,
+ const char *ip_str,
+ const char *access_list_str)
{
int ret;
struct prefix_ipv4 p;
@@ -1167,8 +1169,10 @@
}
int
-ospf_distance_unset (struct vty *vty, struct ospf *ospf, char *distance_str,
- char *ip_str, char *access_list_str)
+ospf_distance_unset (struct vty *vty, struct ospf *ospf,
+ const char *distance_str,
+ const char *ip_str, char
+ const *access_list_str)
{
int ret;
struct prefix_ipv4 p;
diff --git a/ospfd/ospf_zebra.h b/ospfd/ospf_zebra.h
index 5dbf573..e8ad979 100644
--- a/ospfd/ospf_zebra.h
+++ b/ospfd/ospf_zebra.h
@@ -50,28 +50,26 @@
int ospf_default_originate_timer (struct thread *);
-int ospf_redistribute_check (struct external_info *, int *);
-int ospf_distribute_check_connected (struct external_info *);
-void ospf_distribute_list_update (int);
+int ospf_redistribute_check (struct ospf *, struct external_info *, int *);
+int ospf_distribute_check_connected (struct ospf *, struct external_info *);
+void ospf_distribute_list_update (struct ospf *, int);
int ospf_is_type_redistributed (int);
-int ospf_redistribute_unset (int);
-
-void ospf_distance_reset ();
+void ospf_distance_reset (struct ospf *);
u_char ospf_distance_apply (struct prefix_ipv4 *, struct ospf_route *);
struct vty;
-int ospf_redistribute_set (int, int, int);
-int ospf_redistribute_unset (int);
-int ospf_redistribute_default_set (int, int, int);
-int ospf_redistribute_default_unset ();
-int ospf_distribute_list_out_set (int, char *);
-int ospf_distribute_list_out_unset (int, char *);
-void ospf_routemap_set (int, char *);
-void ospf_routemap_unset (int);
-int ospf_distance_set (struct vty *, char *, char *, char *);
-int ospf_distance_unset (struct vty *, char *, char *, char *);
+int ospf_redistribute_set (struct ospf *, int, int, int);
+int ospf_redistribute_unset (struct ospf *, int);
+int ospf_redistribute_default_set (struct ospf *, int, int, int);
+int ospf_redistribute_default_unset (struct ospf *);
+int ospf_distribute_list_out_set (struct ospf *, int, const char *);
+int ospf_distribute_list_out_unset (struct ospf *, int, const char *);
+void ospf_routemap_set (struct ospf *, int, const char *);
+void ospf_routemap_unset (struct ospf *, int);
+int ospf_distance_set (struct vty *, struct ospf *, const char *, const char *, const char *);
+int ospf_distance_unset (struct vty *, struct ospf *, const char *, const char *, const char *);
void ospf_zebra_init ();
#endif /* _ZEBRA_OSPF_ZEBRA_H */
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 6c6dd8d..0a988e0 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -1172,7 +1172,7 @@
int
ospf_area_export_list_set (struct ospf *ospf,
- struct ospf_area *area, char *list_name)
+ struct ospf_area *area, const char *list_name)
{
struct access_list *list;
list = access_list_lookup (AFI_IP, list_name);
@@ -1207,8 +1207,8 @@
}
int
-ospf_area_import_list_set (struct ospf *ospf,
- struct ospf_area *area, char *name)
+ospf_area_import_list_set (struct ospf *ospf, struct ospf_area *area,
+ const char *name)
{
struct access_list *list;
list = access_list_lookup (AFI_IP, name);
@@ -1565,7 +1565,7 @@
int
ospf_nbr_nbma_poll_interval_set (struct ospf *ospf, struct in_addr nbr_addr,
- int interval)
+ unsigned int interval)
{
struct ospf_nbr_nbma *nbr_nbma;
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index 6910d39..0f778e0 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -539,9 +539,9 @@
int ospf_area_nssa_set (struct ospf *, struct in_addr);
int ospf_area_nssa_unset (struct ospf *, struct in_addr);
int ospf_area_nssa_translator_role_set (struct ospf *, struct in_addr, int);
-int ospf_area_export_list_set (struct ospf *, struct ospf_area *, char *);
+int ospf_area_export_list_set (struct ospf *, struct ospf_area *, const char *);
int ospf_area_export_list_unset (struct ospf *, struct ospf_area *);
-int ospf_area_import_list_set (struct ospf *, struct ospf_area *, char *);
+int ospf_area_import_list_set (struct ospf *, struct ospf_area *, const char *);
int ospf_area_import_list_unset (struct ospf *, struct ospf_area *);
int ospf_area_shortcut_set (struct ospf *, struct ospf_area *, int);
int ospf_area_shortcut_unset (struct ospf *, struct ospf_area *);
@@ -553,7 +553,7 @@
int ospf_nbr_nbma_unset (struct ospf *, struct in_addr);
int ospf_nbr_nbma_priority_set (struct ospf *, struct in_addr, u_char);
int ospf_nbr_nbma_priority_unset (struct ospf *, struct in_addr);
-int ospf_nbr_nbma_poll_interval_set (struct ospf *, struct in_addr, int);
+int ospf_nbr_nbma_poll_interval_set (struct ospf *, struct in_addr, unsigned int);
int ospf_nbr_nbma_poll_interval_unset (struct ospf *, struct in_addr);
void ospf_prefix_list_update (struct prefix_list *);
void ospf_init ();