2004-10-10 Paul Jakma <paul@dishone.st>

* version.h.in: (pid_output*) add const qualifier.
	* command.h: Change DEFUN func to take const char *[] rather
          than char **, to begin process of fixing compile warnings in lib/.
          Nearly all other changes in this commit follow from this change.
        * buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
          const void * and cast an automatic const char *p to it.
          (buffer_putstr) add const
        * command.c: (zencrypt) const qualifier
          (cmd_execute_command_real) ditto
          (cmd_execute_command_strict) ditto
          (config_log_file) ditto.
          Fix leak of getcwd() returned string.
        * memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
        * distribute.{c,h}: Update with const qualifier.
          (distribute_free) use MTYPE_DISTRIBUTE_IFNAME
          (distribute_lookup) Cast to char *, note that it's ok.
          (distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
          (distribute_get)  Cast to char *, note that it's ok.
        * filter.c: Update with const qualifier.
        * if.{c,h}: ditto.
        * if_rmap.{c,h}: ditto.
          (if_rmap_lookup) Cast to char *, note that it's ok.
          (if_rmap_get) ditto.
        * log.{c,h}: Update with const qualifier.
        * plist.{c,h}: ditto.
        * routemap.{c,h}: ditto.
        * smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
        * sockopt.c: (getsockopt_cmsg_data) add return for error case.
        * vty.c: Update with const qualifier.
This commit is contained in:
paul 2004-10-10 11:56:56 +00:00
parent ddd119fd3d
commit 9035efaa92
23 changed files with 163 additions and 100 deletions

View File

@ -1,7 +1,35 @@
2004-10-05 Paul Jakma <paul@dishone.st> 2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier. * version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-08 Hasso Tepper <hasso at quagga.net> 2004-10-08 Hasso Tepper <hasso at quagga.net>
* routemap.c, routemap.h: Make some string arguments const. * routemap.c, routemap.h: Make some string arguments const.

View File

@ -149,10 +149,10 @@ buffer_add (struct buffer *b)
/* Write data to buffer. */ /* Write data to buffer. */
int int
buffer_write (struct buffer *b, void *ptr, size_t size) buffer_write (struct buffer *b, const void *p, size_t size)
{ {
struct buffer_data *data; struct buffer_data *data;
const char *ptr = p;
data = b->tail; data = b->tail;
b->length += size; b->length += size;
@ -205,7 +205,7 @@ buffer_putw (struct buffer *b, u_short c)
/* Put string to the buffer. */ /* Put string to the buffer. */
int int
buffer_putstr (struct buffer *b, char *c) buffer_putstr (struct buffer *b, const char *c)
{ {
size_t size; size_t size;

View File

@ -63,11 +63,11 @@ struct buffer_data
/* Buffer prototypes. */ /* Buffer prototypes. */
struct buffer *buffer_new (size_t); struct buffer *buffer_new (size_t);
int buffer_write (struct buffer *, void *, size_t); int buffer_write (struct buffer *, const void *, size_t);
void buffer_free (struct buffer *); void buffer_free (struct buffer *);
char *buffer_getstr (struct buffer *); char *buffer_getstr (struct buffer *);
int buffer_putc (struct buffer *, u_char); int buffer_putc (struct buffer *, u_char);
int buffer_putstr (struct buffer *, char *); int buffer_putstr (struct buffer *, const char *);
void buffer_reset (struct buffer *); void buffer_reset (struct buffer *);
int buffer_flush_all (struct buffer *, int); int buffer_flush_all (struct buffer *, int);
int buffer_flush_vty_all (struct buffer *, int, int, int); int buffer_flush_vty_all (struct buffer *, int, int, int);

View File

@ -432,7 +432,7 @@ to64(char *s, long v, int n)
} }
} }
char *zencrypt (char *passwd) char *zencrypt (const char *passwd)
{ {
char salt[6]; char salt[6];
struct timeval tv; struct timeval tv;
@ -1932,7 +1932,7 @@ cmd_execute_command_real (vector vline, struct vty *vty, struct cmd_element **cm
struct cmd_element *matched_element; struct cmd_element *matched_element;
unsigned int matched_count, incomplete_count; unsigned int matched_count, incomplete_count;
int argc; int argc;
char *argv[CMD_ARGC_MAX]; const char *argv[CMD_ARGC_MAX];
enum match_type match = 0; enum match_type match = 0;
int varflag; int varflag;
char *command; char *command;
@ -2111,7 +2111,7 @@ cmd_execute_command_strict (vector vline, struct vty *vty,
struct cmd_element *matched_element; struct cmd_element *matched_element;
unsigned int matched_count, incomplete_count; unsigned int matched_count, incomplete_count;
int argc; int argc;
char *argv[CMD_ARGC_MAX]; const char *argv[CMD_ARGC_MAX];
int varflag; int varflag;
enum match_type match = 0; enum match_type match = 0;
char *command; char *command;
@ -2983,22 +2983,38 @@ DEFUN (config_log_file,
"Logging filename\n") "Logging filename\n")
{ {
int ret; int ret;
char *cwd; char *p = NULL;
char *fullpath; const char *fullpath;
/* Path detection. */ /* Path detection. */
if (! IS_DIRECTORY_SEP (*argv[0])) if (! IS_DIRECTORY_SEP (*argv[0]))
{ {
cwd = getcwd (NULL, MAXPATHLEN); char cwd[MAXPATHLEN+1];
fullpath = XMALLOC (MTYPE_TMP, cwd[MAXPATHLEN] = '\0';
strlen (cwd) + strlen (argv[0]) + 2);
sprintf (fullpath, "%s/%s", cwd, argv[0]); if (getcwd (cwd, MAXPATHLEN) == NULL)
{
zlog_err ("config_log_file: Unable to alloc mem!");
return CMD_WARNING;
}
if ( (p = XMALLOC (MTYPE_TMP, strlen (cwd) + strlen (argv[0]) + 2))
== NULL)
{
zlog_err ("config_log_file: Unable to alloc mem!");
return CMD_WARNING;
}
sprintf (p, "%s/%s", cwd, argv[0]);
fullpath = p;
} }
else else
fullpath = argv[0]; fullpath = argv[0];
ret = zlog_set_file (NULL, ZLOG_FILE, fullpath); ret = zlog_set_file (NULL, ZLOG_FILE, fullpath);
if (p)
XFREE (MTYPE_TMP, p);
if (!ret) if (!ret)
{ {
vty_out (vty, "can't open logfile %s\n", argv[0]); vty_out (vty, "can't open logfile %s\n", argv[0]);

View File

@ -129,7 +129,7 @@ struct cmd_node
struct cmd_element struct cmd_element
{ {
const char *string; /* Command specification by string. */ const char *string; /* Command specification by string. */
int (*func) (struct cmd_element *, struct vty *, int, char **); int (*func) (struct cmd_element *, struct vty *, int, const char *[]);
const char *doc; /* Documentation of this command. */ const char *doc; /* Documentation of this command. */
int daemon; /* Daemon to which this command belong. */ int daemon; /* Daemon to which this command belong. */
vector strvec; /* Pointing out each description vector. */ vector strvec; /* Pointing out each description vector. */
@ -166,15 +166,15 @@ struct desc
/* DEFUN for vty command interafce. Little bit hacky ;-). */ /* DEFUN for vty command interafce. Little bit hacky ;-). */
#define DEFUN(funcname, cmdname, cmdstr, helpstr) \ #define DEFUN(funcname, cmdname, cmdstr, helpstr) \
int funcname (struct cmd_element *, struct vty *, int, char **); \ int funcname (struct cmd_element *, struct vty *, int, const char *[]); \
struct cmd_element cmdname = \ struct cmd_element cmdname = \
{ \ { \
cmdstr, \ .string = cmdstr, \
funcname, \ .func = funcname, \
helpstr \ .doc = helpstr \
}; \ }; \
int funcname \ int funcname \
(struct cmd_element *self, struct vty *vty, int argc, char **argv) (struct cmd_element *self, struct vty *vty, int argc, const char *argv[])
/* DEFUN_NOSH for commands that vtysh should ignore */ /* DEFUN_NOSH for commands that vtysh should ignore */
#define DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) \ #define DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) \
@ -304,8 +304,8 @@ extern struct cmd_element config_exit_cmd;
extern struct cmd_element config_quit_cmd; extern struct cmd_element config_quit_cmd;
extern struct cmd_element config_help_cmd; extern struct cmd_element config_help_cmd;
extern struct cmd_element config_list_cmd; extern struct cmd_element config_list_cmd;
int config_exit (struct cmd_element *, struct vty *, int, char **); int config_exit (struct cmd_element *, struct vty *, int, const char *[]);
int config_help (struct cmd_element *, struct vty *, int, char **); int config_help (struct cmd_element *, struct vty *, int, const char *[]);
char *host_config_file (); char *host_config_file ();
void host_config_set (char *); void host_config_set (char *);

View File

@ -51,7 +51,7 @@ void
distribute_free (struct distribute *dist) distribute_free (struct distribute *dist)
{ {
if (dist->ifname) if (dist->ifname)
free (dist->ifname); XFREE (MTYPE_DISTRIBUTE_IFNAME, dist->ifname);
if (dist->list[DISTRIBUTE_IN]) if (dist->list[DISTRIBUTE_IN])
free (dist->list[DISTRIBUTE_IN]); free (dist->list[DISTRIBUTE_IN]);
@ -68,12 +68,13 @@ distribute_free (struct distribute *dist)
/* Lookup interface's distribute list. */ /* Lookup interface's distribute list. */
struct distribute * struct distribute *
distribute_lookup (char *ifname) distribute_lookup (const char *ifname)
{ {
struct distribute key; struct distribute key;
struct distribute *dist; struct distribute *dist;
key.ifname = ifname; /* temporary reference */
key.ifname = (char *)ifname;
dist = hash_lookup (disthash, &key); dist = hash_lookup (disthash, &key);
@ -99,7 +100,7 @@ distribute_hash_alloc (struct distribute *arg)
dist = distribute_new (); dist = distribute_new ();
if (arg->ifname) if (arg->ifname)
dist->ifname = strdup (arg->ifname); dist->ifname = XSTRDUP (MTYPE_DISTRIBUTE_IFNAME, arg->ifname);
else else
dist->ifname = NULL; dist->ifname = NULL;
return dist; return dist;
@ -107,12 +108,13 @@ distribute_hash_alloc (struct distribute *arg)
/* Make new distribute list and push into hash. */ /* Make new distribute list and push into hash. */
struct distribute * struct distribute *
distribute_get (char *ifname) distribute_get (const char *ifname)
{ {
struct distribute key; struct distribute key;
key.ifname = ifname; /* temporary reference */
key.ifname = (char *)ifname;
return hash_get (disthash, &key, distribute_hash_alloc); return hash_get (disthash, &key, distribute_hash_alloc);
} }
@ -144,7 +146,8 @@ distribute_cmp (struct distribute *dist1, struct distribute *dist2)
/* Set access-list name to the distribute list. */ /* Set access-list name to the distribute list. */
struct distribute * struct distribute *
distribute_list_set (char *ifname, enum distribute_type type, char *alist_name) distribute_list_set (const char *ifname, enum distribute_type type,
const char *alist_name)
{ {
struct distribute *dist; struct distribute *dist;
@ -172,8 +175,8 @@ distribute_list_set (char *ifname, enum distribute_type type, char *alist_name)
/* Unset distribute-list. If matched distribute-list exist then /* Unset distribute-list. If matched distribute-list exist then
return 1. */ return 1. */
int int
distribute_list_unset (char *ifname, enum distribute_type type, distribute_list_unset (const char *ifname, enum distribute_type type,
char *alist_name) const char *alist_name)
{ {
struct distribute *dist; struct distribute *dist;
@ -221,8 +224,8 @@ distribute_list_unset (char *ifname, enum distribute_type type,
/* Set access-list name to the distribute list. */ /* Set access-list name to the distribute list. */
struct distribute * struct distribute *
distribute_list_prefix_set (char *ifname, enum distribute_type type, distribute_list_prefix_set (const char *ifname, enum distribute_type type,
char *plist_name) const char *plist_name)
{ {
struct distribute *dist; struct distribute *dist;
@ -250,8 +253,8 @@ distribute_list_prefix_set (char *ifname, enum distribute_type type,
/* Unset distribute-list. If matched distribute-list exist then /* Unset distribute-list. If matched distribute-list exist then
return 1. */ return 1. */
int int
distribute_list_prefix_unset (char *ifname, enum distribute_type type, distribute_list_prefix_unset (const char *ifname, enum distribute_type type,
char *plist_name) const char *plist_name)
{ {
struct distribute *dist; struct distribute *dist;

View File

@ -47,7 +47,7 @@ void distribute_list_init (int);
void distribute_list_reset (void); void distribute_list_reset (void);
void distribute_list_add_hook (void (*) (struct distribute *)); void distribute_list_add_hook (void (*) (struct distribute *));
void distribute_list_delete_hook (void (*) (struct distribute *)); void distribute_list_delete_hook (void (*) (struct distribute *));
struct distribute *distribute_lookup (char *); struct distribute *distribute_lookup (const char *);
int config_write_distribute (struct vty *); int config_write_distribute (struct vty *);
int config_show_distribute (struct vty *); int config_show_distribute (struct vty *);

View File

@ -569,7 +569,7 @@ filter_lookup_zebra (struct access_list *access, struct filter *mnew)
} }
int int
vty_access_list_remark_unset (struct vty *vty, afi_t afi, char *name) vty_access_list_remark_unset (struct vty *vty, afi_t afi, const char *name)
{ {
struct access_list *access; struct access_list *access;
@ -594,7 +594,7 @@ vty_access_list_remark_unset (struct vty *vty, afi_t afi, char *name)
} }
int int
filter_set_cisco (struct vty *vty, char *name_str, char *type_str, filter_set_cisco (struct vty *vty, const char *name_str, const char *type_str,
const char *addr_str, const char *addr_mask_str, const char *addr_str, const char *addr_mask_str,
const char *mask_str, const char *mask_mask_str, const char *mask_str, const char *mask_mask_str,
int extended, int set) int extended, int set)
@ -1596,7 +1596,7 @@ void config_write_access_cisco (struct vty *, struct filter *);
/* show access-list command. */ /* show access-list command. */
int int
filter_show (struct vty *vty, char *name, afi_t afi) filter_show (struct vty *vty, const char *name, afi_t afi)
{ {
struct access_list *access; struct access_list *access;
struct access_master *master; struct access_master *master;

View File

@ -123,7 +123,7 @@ if_new ()
} }
struct interface * struct interface *
if_create (char *name, int namelen) if_create (const char *name, int namelen)
{ {
struct interface *ifp; struct interface *ifp;
@ -208,7 +208,7 @@ ifindex2ifname (unsigned int index)
/* Interface existance check by interface name. */ /* Interface existance check by interface name. */
struct interface * struct interface *
if_lookup_by_name (char *name) if_lookup_by_name (const char *name)
{ {
struct listnode *node; struct listnode *node;
struct interface *ifp; struct interface *ifp;
@ -320,7 +320,7 @@ if_lookup_address (struct in_addr src)
/* Get interface by name if given name interface doesn't exist create /* Get interface by name if given name interface doesn't exist create
one. */ one. */
struct interface * struct interface *
if_get_by_name (char *name) if_get_by_name (const char *name)
{ {
struct interface *ifp; struct interface *ifp;

View File

@ -183,12 +183,12 @@ struct connected
/* Prototypes. */ /* Prototypes. */
int if_cmp_func (struct interface *, struct interface *); int if_cmp_func (struct interface *, struct interface *);
struct interface *if_new (void); struct interface *if_new (void);
struct interface *if_create (char *name, int namelen); struct interface *if_create (const char *name, int namelen);
struct interface *if_lookup_by_index (unsigned int); struct interface *if_lookup_by_index (unsigned int);
struct interface *if_lookup_by_name (char *); struct interface *if_lookup_by_name (const char *);
struct interface *if_lookup_exact_address (struct in_addr); struct interface *if_lookup_exact_address (struct in_addr);
struct interface *if_lookup_address (struct in_addr); struct interface *if_lookup_address (struct in_addr);
struct interface *if_get_by_name (char *); struct interface *if_get_by_name (const char *);
void if_delete (struct interface *); void if_delete (struct interface *);
int if_is_up (struct interface *); int if_is_up (struct interface *);
int if_is_running (struct interface *); int if_is_running (struct interface *);

View File

@ -58,12 +58,13 @@ if_rmap_free (struct if_rmap *if_rmap)
} }
struct if_rmap * struct if_rmap *
if_rmap_lookup (char *ifname) if_rmap_lookup (const char *ifname)
{ {
struct if_rmap key; struct if_rmap key;
struct if_rmap *if_rmap; struct if_rmap *if_rmap;
key.ifname = ifname; /* temporary copy */
key.ifname = (char *)ifname;
if_rmap = hash_lookup (ifrmaphash, &key); if_rmap = hash_lookup (ifrmaphash, &key);
@ -94,11 +95,12 @@ if_rmap_hash_alloc (struct if_rmap *arg)
} }
struct if_rmap * struct if_rmap *
if_rmap_get (char *ifname) if_rmap_get (const char *ifname)
{ {
struct if_rmap key; struct if_rmap key;
key.ifname = ifname; /* temporary copy */
key.ifname = (char *)ifname;
return (struct if_rmap *) hash_get (ifrmaphash, &key, if_rmap_hash_alloc); return (struct if_rmap *) hash_get (ifrmaphash, &key, if_rmap_hash_alloc);
} }
@ -124,7 +126,8 @@ if_rmap_hash_cmp (struct if_rmap *if_rmap1, struct if_rmap *if_rmap2)
} }
struct if_rmap * struct if_rmap *
if_rmap_set (char *ifname, enum if_rmap_type type, char *routemap_name) if_rmap_set (const char *ifname, enum if_rmap_type type,
const char *routemap_name)
{ {
struct if_rmap *if_rmap; struct if_rmap *if_rmap;
@ -150,7 +153,8 @@ if_rmap_set (char *ifname, enum if_rmap_type type, char *routemap_name)
} }
int int
if_rmap_unset (char *ifname, enum if_rmap_type type, char *routemap_name) if_rmap_unset (const char *ifname, enum if_rmap_type type,
const char *routemap_name)
{ {
struct if_rmap *if_rmap; struct if_rmap *if_rmap;

View File

@ -41,7 +41,7 @@ void if_rmap_init (int);
void if_rmap_reset (void); void if_rmap_reset (void);
void if_rmap_hook_add (void (*) (struct if_rmap *)); void if_rmap_hook_add (void (*) (struct if_rmap *));
void if_rmap_hook_delete (void (*) (struct if_rmap *)); void if_rmap_hook_delete (void (*) (struct if_rmap *));
struct if_rmap *if_rmap_lookup (char *); struct if_rmap *if_rmap_lookup (const char *);
int config_write_if_rmap (struct vty *); int config_write_if_rmap (struct vty *);
#endif /* _ZEBRA_IF_RMAP_H */ #endif /* _ZEBRA_IF_RMAP_H */

View File

@ -366,7 +366,7 @@ zlog_reset_flag (struct zlog *zl, int flags)
} }
int int
zlog_set_file (struct zlog *zl, int flags, char *filename) zlog_set_file (struct zlog *zl, int flags, const char *filename)
{ {
FILE *fp; FILE *fp;
mode_t oldumask; mode_t oldumask;

View File

@ -112,7 +112,7 @@ void zlog_set_flag (struct zlog *zl, int flags);
void zlog_reset_flag (struct zlog *zl, int flags); void zlog_reset_flag (struct zlog *zl, int flags);
/* Set zlog filename. */ /* Set zlog filename. */
int zlog_set_file (struct zlog *zl, int flags, char *filename); int zlog_set_file (struct zlog *zl, int flags, const char *filename);
int zlog_reset_file (struct zlog *zl); int zlog_reset_file (struct zlog *zl);
/* Rotate log. */ /* Rotate log. */

View File

@ -239,6 +239,8 @@ struct memory_list memory_list_lib[] =
{ MTYPE_ROUTE_TABLE, "Route table " }, { MTYPE_ROUTE_TABLE, "Route table " },
{ MTYPE_ROUTE_NODE, "Route node " }, { MTYPE_ROUTE_NODE, "Route node " },
{ MTYPE_RIB, "RIB " }, { MTYPE_RIB, "RIB " },
{ MTYPE_DISTRIBUTE, "Distribute list " },
{ MTYPE_DISTRIBUTE_IFNAME, "Dist-list ifname" },
{ MTYPE_NEXTHOP, "Nexthop " }, { MTYPE_NEXTHOP, "Nexthop " },
{ MTYPE_LINK_LIST, "Link List " }, { MTYPE_LINK_LIST, "Link List " },
{ MTYPE_LINK_NODE, "Link Node " }, { MTYPE_LINK_NODE, "Link Node " },

View File

@ -75,7 +75,9 @@ enum
MTYPE_ROUTE_MAP_COMPILED, MTYPE_ROUTE_MAP_COMPILED,
MTYPE_RIB, MTYPE_RIB,
MTYPE_DISTRIBUTE, MTYPE_DISTRIBUTE,
MTYPE_DISTRIBUTE_IFNAME,
MTYPE_ZLOG, MTYPE_ZLOG,
MTYPE_ZCLIENT, MTYPE_ZCLIENT,
MTYPE_NEXTHOP, MTYPE_NEXTHOP,

View File

@ -126,7 +126,7 @@ prefix_master_get (afi_t afi)
/* Lookup prefix_list from list of prefix_list by name. */ /* Lookup prefix_list from list of prefix_list by name. */
struct prefix_list * struct prefix_list *
prefix_list_lookup (afi_t afi, char *name) prefix_list_lookup (afi_t afi, const char *name)
{ {
struct prefix_list *plist; struct prefix_list *plist;
struct prefix_master *master; struct prefix_master *master;
@ -182,7 +182,7 @@ prefix_list_entry_free (struct prefix_list_entry *pentry)
/* Insert new prefix list to list of prefix_list. Each prefix_list /* Insert new prefix list to list of prefix_list. Each prefix_list
is sorted by the name. */ is sorted by the name. */
static struct prefix_list * static struct prefix_list *
prefix_list_insert (afi_t afi, char *name) prefix_list_insert (afi_t afi, const char *name)
{ {
unsigned int i; unsigned int i;
long number; long number;
@ -272,7 +272,7 @@ prefix_list_insert (afi_t afi, char *name)
} }
static struct prefix_list * static struct prefix_list *
prefix_list_get (afi_t afi, char *name) prefix_list_get (afi_t afi, const char *name)
{ {
struct prefix_list *plist; struct prefix_list *plist;
@ -647,7 +647,7 @@ prefix_entry_dup_check (struct prefix_list *plist,
} }
static int static int
vty_invalid_prefix_range (struct vty *vty, char *prefix) vty_invalid_prefix_range (struct vty *vty, const char *prefix)
{ {
vty_out (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s", vty_out (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s",
prefix, VTY_NEWLINE); prefix, VTY_NEWLINE);
@ -655,9 +655,9 @@ vty_invalid_prefix_range (struct vty *vty, char *prefix)
} }
static int static int
vty_prefix_list_install (struct vty *vty, afi_t afi, vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
char *name, char *seq, char *typestr, const char *seq, const char *typestr,
char *prefix, char *ge, char *le) const char *prefix, const char *ge, const char *le)
{ {
int ret; int ret;
enum prefix_list_type type; enum prefix_list_type type;
@ -774,9 +774,9 @@ vty_prefix_list_install (struct vty *vty, afi_t afi,
} }
static int static int
vty_prefix_list_uninstall (struct vty *vty, afi_t afi, vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
char *name, char *seq, char *typestr, const char *seq, const char *typestr,
char *prefix, char *ge, char *le) const char *prefix, const char *ge, const char *le)
{ {
int ret; int ret;
enum prefix_list_type type; enum prefix_list_type type;
@ -878,7 +878,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi,
} }
static int static int
vty_prefix_list_desc_unset (struct vty *vty, afi_t afi, char *name) vty_prefix_list_desc_unset (struct vty *vty, afi_t afi, const char *name)
{ {
struct prefix_list *plist; struct prefix_list *plist;
@ -982,8 +982,8 @@ vty_show_prefix_entry (struct vty *vty, afi_t afi, struct prefix_list *plist,
} }
static int static int
vty_show_prefix_list (struct vty *vty, afi_t afi, char *name, vty_show_prefix_list (struct vty *vty, afi_t afi, const char *name,
char *seq, enum display_type dtype) const char *seq, enum display_type dtype)
{ {
struct prefix_list *plist; struct prefix_list *plist;
struct prefix_master *master; struct prefix_master *master;
@ -1026,8 +1026,8 @@ vty_show_prefix_list (struct vty *vty, afi_t afi, char *name,
} }
static int static int
vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, char *name, vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, const char *name,
char *prefix, enum display_type type) const char *prefix, enum display_type type)
{ {
struct prefix_list *plist; struct prefix_list *plist;
struct prefix_list_entry *pentry; struct prefix_list_entry *pentry;
@ -1098,7 +1098,8 @@ vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, char *name,
} }
static int static int
vty_clear_prefix_list (struct vty *vty, afi_t afi, char *name, char *prefix) vty_clear_prefix_list (struct vty *vty, afi_t afi, const char *name,
const char *prefix)
{ {
struct prefix_master *master; struct prefix_master *master;
struct prefix_list *plist; struct prefix_list *plist;

View File

@ -67,7 +67,7 @@ void prefix_list_reset (void);
void prefix_list_add_hook (void (*func) (struct prefix_list *)); void prefix_list_add_hook (void (*func) (struct prefix_list *));
void prefix_list_delete_hook (void (*func) (struct prefix_list *)); void prefix_list_delete_hook (void (*func) (struct prefix_list *));
struct prefix_list *prefix_list_lookup (afi_t, char *); struct prefix_list *prefix_list_lookup (afi_t, const char *);
enum prefix_list_type prefix_list_apply (struct prefix_list *, void *); enum prefix_list_type prefix_list_apply (struct prefix_list *, void *);
struct stream * struct stream *

View File

@ -57,9 +57,9 @@ struct route_map_list
struct route_map *head; struct route_map *head;
struct route_map *tail; struct route_map *tail;
void (*add_hook) (char *); void (*add_hook) (const char *);
void (*delete_hook) (char *); void (*delete_hook) (const char *);
void (*event_hook) (route_map_event_t, char *); void (*event_hook) (route_map_event_t, const char *);
}; };
/* Master list of route map. */ /* Master list of route map. */
@ -75,7 +75,7 @@ route_map_index_delete (struct route_map_index *, int);
/* New route map allocation. Please note route map's name must be /* New route map allocation. Please note route map's name must be
specified. */ specified. */
static struct route_map * static struct route_map *
route_map_new (char *name) route_map_new (const char *name)
{ {
struct route_map *new; struct route_map *new;
@ -86,7 +86,7 @@ route_map_new (char *name)
/* Add new name to route_map. */ /* Add new name to route_map. */
static struct route_map * static struct route_map *
route_map_add (char *name) route_map_add (const char *name)
{ {
struct route_map *map; struct route_map *map;
struct route_map_list *list; struct route_map_list *list;
@ -147,7 +147,7 @@ route_map_delete (struct route_map *map)
/* Lookup route map by route map name string. */ /* Lookup route map by route map name string. */
struct route_map * struct route_map *
route_map_lookup_by_name (char *name) route_map_lookup_by_name (const char *name)
{ {
struct route_map *map; struct route_map *map;
@ -160,7 +160,7 @@ route_map_lookup_by_name (char *name)
/* Lookup route map. If there isn't route map create one and return /* Lookup route map. If there isn't route map create one and return
it. */ it. */
struct route_map * struct route_map *
route_map_get (char *name) route_map_get (const char *name)
{ {
struct route_map *map; struct route_map *map;
@ -241,7 +241,7 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map)
} }
int int
vty_show_route_map (struct vty *vty, char *name) vty_show_route_map (struct vty *vty, const char *name)
{ {
struct route_map *map; struct route_map *map;
@ -852,19 +852,19 @@ route_map_apply (struct route_map *map, struct prefix *prefix,
} }
void void
route_map_add_hook (void (*func) (char *)) route_map_add_hook (void (*func) (const char *))
{ {
route_map_master.add_hook = func; route_map_master.add_hook = func;
} }
void void
route_map_delete_hook (void (*func) (char *)) route_map_delete_hook (void (*func) (const char *))
{ {
route_map_master.delete_hook = func; route_map_master.delete_hook = func;
} }
void void
route_map_event_hook (void (*func) (route_map_event_t, char *)) route_map_event_hook (void (*func) (route_map_event_t, const char *))
{ {
route_map_master.event_hook = func; route_map_master.event_hook = func;
} }

View File

@ -185,16 +185,16 @@ route_map_install_set (struct route_map_rule_cmd *cmd);
/* Lookup route map by name. */ /* Lookup route map by name. */
struct route_map * struct route_map *
route_map_lookup_by_name (char *name); route_map_lookup_by_name (const char *name);
/* Apply route map to the object. */ /* Apply route map to the object. */
route_map_result_t route_map_result_t
route_map_apply (struct route_map *map, struct prefix *, route_map_apply (struct route_map *map, struct prefix *,
route_map_object_t object_type, void *object); route_map_object_t object_type, void *object);
void route_map_add_hook (void (*func) (char *)); void route_map_add_hook (void (*func) (const char *));
void route_map_delete_hook (void (*func) (char *)); void route_map_delete_hook (void (*func) (const char *));
void route_map_event_hook (void (*func) (route_map_event_t, char *)); void route_map_event_hook (void (*func) (route_map_event_t, const char *));
#endif /* _ZEBRA_ROUTEMAP_H */ #endif /* _ZEBRA_ROUTEMAP_H */

View File

@ -61,7 +61,7 @@ size_t smux_default_oid_len;
/* SMUX password. */ /* SMUX password. */
char *smux_passwd; char *smux_passwd;
char *smux_default_passwd = ""; const char *smux_default_passwd = "";
/* SMUX read threads. */ /* SMUX read threads. */
struct thread *smux_read_thread; struct thread *smux_read_thread;
@ -160,9 +160,9 @@ oid_compare_part (oid *o1, int o1_len, oid *o2, int o2_len)
} }
void void
smux_oid_dump (char *prefix, oid *oid, size_t oid_len) smux_oid_dump (const char *prefix, oid *oid, size_t oid_len)
{ {
int i; unsigned int i;
int first = 1; int first = 1;
char buf[MAX_OID_LEN * 3]; char buf[MAX_OID_LEN * 3];
@ -1004,7 +1004,7 @@ smux_trap (oid *name, size_t namelen,
struct trap_object *trapobj, size_t trapobjlen, struct trap_object *trapobj, size_t trapobjlen,
unsigned int tick, u_char sptrap) unsigned int tick, u_char sptrap)
{ {
int i; unsigned int i;
u_char buf[BUFSIZ]; u_char buf[BUFSIZ];
u_char *ptr; u_char *ptr;
int len, length; int len, length;
@ -1249,7 +1249,7 @@ smux_event (enum smux_event event, int sock)
} }
int int
smux_str2oid (char *str, oid *oid, size_t *oid_len) smux_str2oid (const char *str, oid *oid, size_t *oid_len)
{ {
int len; int len;
int val; int val;
@ -1303,7 +1303,7 @@ smux_oid_dup (oid *objid, size_t objid_len)
} }
int int
smux_peer_oid (struct vty *vty, char *oid_str, char *passwd_str) smux_peer_oid (struct vty *vty, const char *oid_str, const char *passwd_str)
{ {
int ret; int ret;
oid oid[MAX_OID_LEN]; oid oid[MAX_OID_LEN];
@ -1319,6 +1319,7 @@ smux_peer_oid (struct vty *vty, char *oid_str, char *passwd_str)
if (smux_oid && smux_oid != smux_default_oid) if (smux_oid && smux_oid != smux_default_oid)
free (smux_oid); free (smux_oid);
/* careful, smux_passwd might point to string constant */
if (smux_passwd && smux_passwd != smux_default_passwd) if (smux_passwd && smux_passwd != smux_default_passwd)
{ {
free (smux_passwd); free (smux_passwd);
@ -1369,10 +1370,12 @@ smux_peer_default ()
smux_oid = smux_default_oid; smux_oid = smux_default_oid;
smux_oid_len = smux_default_oid_len; smux_oid_len = smux_default_oid_len;
} }
/* careful, smux_passwd might be pointing at string constant */
if (smux_passwd != smux_default_passwd) if (smux_passwd != smux_default_passwd)
{ {
free (smux_passwd); free (smux_passwd);
smux_passwd = smux_default_passwd; smux_passwd = (char *)smux_default_passwd;
} }
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1425,7 +1428,7 @@ int
config_write_smux (struct vty *vty) config_write_smux (struct vty *vty)
{ {
int first = 1; int first = 1;
int i; unsigned int i;
if (smux_oid != smux_default_oid || smux_passwd != smux_default_passwd) if (smux_oid != smux_default_oid || smux_passwd != smux_default_passwd)
{ {
@ -1482,7 +1485,9 @@ smux_init (struct thread_master *tm, oid defoid[], size_t defoid_len)
smux_oid = smux_default_oid; smux_oid = smux_default_oid;
smux_oid_len = smux_default_oid_len; smux_oid_len = smux_default_oid_len;
smux_passwd = smux_default_passwd;
/* be careful with smux_passwd, points to string constant by default */
smux_passwd = (char *)smux_default_passwd;
/* copy callers thread master */ /* copy callers thread master */
master = tm; master = tm;

View File

@ -46,6 +46,8 @@ getsockopt_cmsg_data (struct msghdr *msgh, int level, int type)
cmsg = CMSG_NXTHDR(msgh, cmsg)) cmsg = CMSG_NXTHDR(msgh, cmsg))
if (cmsg->cmsg_level == level && cmsg->cmsg_type) if (cmsg->cmsg_level == level && cmsg->cmsg_type)
return (ptr = CMSG_DATA(cmsg)); return (ptr = CMSG_DATA(cmsg));
return NULL;
} }
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6

View File

@ -2422,7 +2422,7 @@ DEFUN (line_vty,
/* Set time out value. */ /* Set time out value. */
int int
exec_timeout (struct vty *vty, char *min_str, char *sec_str) exec_timeout (struct vty *vty, const char *min_str, const char *sec_str)
{ {
unsigned long timeout = 0; unsigned long timeout = 0;