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.
This commit is contained in:
paul 2004-10-11 11:00:30 +00:00
parent 6b33361187
commit 6c83567192
15 changed files with 93 additions and 84 deletions

View File

@ -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>

View File

@ -565,7 +565,7 @@ ospf_abr_update_aggregate (struct ospf_area_range *range,
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",

View File

@ -52,7 +52,7 @@ struct ospf_area_range
/* 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 @@ int ospf_area_range_substitute_unset (struct ospf *, struct in_addr,
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 */

View File

@ -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)

View File

@ -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 @@ struct lsa_header
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;
};

View File

@ -241,7 +241,7 @@ ospf_packet_dup (struct ospf_packet *op)
return new;
}
int
unsigned int
ospf_packet_max (struct ospf_interface *oi)
{
int max;
@ -261,7 +261,7 @@ int
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 @@ ospf_ls_ack_timer (struct thread *thread)
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 @@ ospf_write (struct thread *thread)
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 @@ ospf_ls_req (struct ip *iph, struct ospf_header *ospfh,
struct in_addr adv_router;
struct ospf_lsa *find;
struct list *ls_upd;
int length;
unsigned int length;
/* Increment statistics. */
oi->ls_req_in++;

View File

@ -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. */

View File

@ -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 @@ ospf_route_map_update (char *name)
}
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 @@ ospf_route_map_event (route_map_event_t event, char *name)
/* 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 @@ ospf_route_match_delete (struct vty *vty, struct route_map_index *index,
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 @@ ospf_route_match_add (struct vty *vty, struct route_map_index *index,
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 @@ ospf_route_set_add (struct vty *vty, struct route_map_index *index,
/* 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_match_ip_nexthop (void *rule, struct prefix *prefix,
/* 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 @@ route_match_ip_next_hop_prefix_list (void *rule, struct prefix *prefix,
}
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_match_ip_address (void *rule, struct prefix *prefix,
/* 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 @@ route_match_ip_address_prefix_list (void *rule, struct prefix *prefix,
}
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_match_interface (void *rule, struct prefix *prefix,
/* 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 @@ route_set_metric (void *rule, struct prefix *prefix,
/* 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 @@ route_set_metric_type (void *rule, struct prefix *prefix,
/* 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;

View File

@ -919,7 +919,7 @@ ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
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 @@ ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
{
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 @@ struct interface *
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 @@ struct interface *
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 @@ ospfVirtIfLookup (struct variable *v, oid *name, size_t *length,
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 @@ struct ospf_neighbor *
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 @@ ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type,
oid *offset;
int offsetlen;
u_char lsa_type;
int len;
unsigned int len;
struct ospf_lsa *lsa;
struct ospf *ospf;
@ -2477,8 +2477,6 @@ ospfAreaAggregateEntry (struct variable *v, oid *name, size_t *length,
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));

View File

@ -267,7 +267,7 @@ lookup_linkparams_by_instance (struct ospf_lsa *lsa)
{
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)

View File

@ -63,7 +63,7 @@ const static char *ospf_network_type_str[] =
/* 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 @@ ospf_str2area_id (char *str, struct in_addr *area_id, int *format)
int
str2distribute_source (char *str, int *source)
str2distribute_source (const char *str, int *source)
{
/* Sanity check. */
if (str == NULL)
@ -115,7 +115,7 @@ str2distribute_source (char *str, int *source)
}
int
str2metric (char *str, int *metric)
str2metric (const char *str, int *metric)
{
/* Sanity check. */
if (str == NULL)
@ -132,7 +132,7 @@ str2metric (char *str, int *metric)
}
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 @@ DEFUN (no_ospf_area_stub_no_summary,
}
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 @@ config_write_ospf_area (struct vty *vty, struct ospf *ospf)
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))

View File

@ -756,7 +756,7 @@ ospf_redistribute_check (struct ospf *ospf,
/* 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 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
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 @@ ospf_distribute_list_out_set (struct ospf *ospf, int type, char *name)
}
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 @@ ospf_distance_free (struct ospf_distance *odistance)
}
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 @@ ospf_distance_set (struct vty *vty, struct ospf *ospf, char *distance_str,
}
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;

View File

@ -50,28 +50,26 @@ void ospf_zebra_delete_discard (struct prefix_ipv4 *);
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 */

View File

@ -1172,7 +1172,7 @@ ospf_area_nssa_translator_role_unset (struct ospf *ospf,
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 @@ ospf_area_export_list_unset (struct ospf *ospf, struct ospf_area * area)
}
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 @@ ospf_nbr_nbma_priority_unset (struct ospf *ospf, struct in_addr nbr_addr)
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;

View File

@ -539,9 +539,9 @@ int ospf_area_no_summary_unset (struct ospf *, struct in_addr);
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_set (struct ospf *, struct in_addr);
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 ();