make all filtering handles take const args.

(Logical change 1.77)
This commit is contained in:
osdl.net!shemminger 2004-08-31 17:45:21 +00:00
parent 1798c9d5a4
commit 6dc9f01634
17 changed files with 75 additions and 52 deletions

View File

@ -19,29 +19,30 @@ extern int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, in
extern void rtnl_close(struct rtnl_handle *rth);
extern int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type);
extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len);
extern int rtnl_dump_filter(struct rtnl_handle *rth,
int (*filter)(struct sockaddr_nl *, struct nlmsghdr *n, void *),
typedef int (*rtnl_filter_t)(const struct sockaddr_nl *, const struct nlmsghdr *n, void *);
extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter,
void *arg1,
int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
rtnl_filter_t junk,
void *arg2);
extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
unsigned groups, struct nlmsghdr *answer,
int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
rtnl_filter_t junk,
void *jarg);
extern int rtnl_send(struct rtnl_handle *rth, char *buf, int);
extern int rtnl_send(struct rtnl_handle *rth, const char *buf, int);
extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data);
extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen);
extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen);
extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data);
extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen);
extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, const void *data, int alen);
extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
extern int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int len);
extern int rtnl_listen(struct rtnl_handle *, int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
extern int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler,
void *jarg);
extern int rtnl_from_file(FILE *, int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
extern int rtnl_from_file(FILE *, rtnl_filter_t handler,
void *jarg);
#endif /* __LIBNETLINK_H__ */

View File

@ -1,9 +1,10 @@
#ifndef __LL_MAP_H__
#define __LL_MAP_H__ 1
extern int ll_remember_index(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
extern int ll_remember_index(const struct sockaddr_nl *who, const struct nlmsghdr *n,
void *arg);
extern int ll_init_map(struct rtnl_handle *rth);
extern int ll_name_to_index(char *name);
extern int ll_name_to_index(const char *name);
extern const char *ll_index_to_name(int idx);
extern const char *ll_idx_n2a(int idx, char *buf);
extern int ll_index_to_type(int idx);

View File

@ -1,6 +1,11 @@
extern int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
extern int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
extern int print_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
extern int print_linkinfo(const struct sockaddr_nl *who,
const struct nlmsghdr *n,
void *arg);
extern int print_addrinfo(const struct sockaddr_nl *who,
const struct nlmsghdr *n,
void *arg);
extern int print_neigh(const struct sockaddr_nl *who,
const struct nlmsghdr *n, void *arg);
extern int ipaddr_list(int argc, char **argv);
extern int ipaddr_list_link(int argc, char **argv);
extern int iproute_monitor(int argc, char **argv);
@ -8,7 +13,8 @@ extern void iplink_usage(void) __attribute__((noreturn));
extern void iproute_reset_filter(void);
extern void ipaddr_reset_filter(int);
extern void ipneigh_reset_filter(void);
extern int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
extern int print_route(const struct sockaddr_nl *who,
const struct nlmsghdr *n, void *arg);
extern int do_ipaddr(int argc, char **argv);
extern int do_iproute(int argc, char **argv);
extern int do_iprule(int argc, char **argv);

View File

@ -126,7 +126,7 @@ void print_queuelen(char *name)
printf("qlen %d", ifr.ifr_qlen);
}
int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
int print_linkinfo(const struct sockaddr_nl *who, const struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;
struct ifinfomsg *ifi = NLMSG_DATA(n);
@ -275,7 +275,8 @@ static int flush_update(void)
return 0;
}
int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
int print_addrinfo(const struct sockaddr_nl *who, const struct nlmsghdr *n,
void *arg)
{
FILE *fp = (FILE*)arg;
struct ifaddrmsg *ifa = NLMSG_DATA(n);
@ -465,7 +466,8 @@ int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo, FILE *fp)
}
int store_nlmsg(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
static int store_nlmsg(const struct sockaddr_nl *who, const struct nlmsghdr *n,
void *arg)
{
struct nlmsg_list **linfo = (struct nlmsg_list**)arg;
struct nlmsg_list *h;

View File

@ -33,7 +33,8 @@ static void usage(void)
}
int accept_msg(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
int accept_msg(const struct sockaddr_nl *who,
const struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;

View File

@ -217,7 +217,7 @@ static int ipneigh_modify(int cmd, int flags, int argc, char **argv)
}
int print_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
int print_neigh(const struct sockaddr_nl *who, const struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;
struct ndmsg *r = NLMSG_DATA(n);

View File

@ -103,7 +103,7 @@ static int flush_update(void)
return 0;
}
int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
int print_route(const struct sockaddr_nl *who, const struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;
struct rtmsg *r = NLMSG_DATA(n);

View File

@ -42,7 +42,8 @@ static void usage(void)
exit(-1);
}
int print_rule(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
static int print_rule(const struct sockaddr_nl *who, const struct nlmsghdr *n,
void *arg)
{
FILE *fp = (FILE*)arg;
struct rtmsg *r = NLMSG_DATA(n);

View File

@ -46,7 +46,8 @@ static void write_stamp(FILE *fp)
fwrite((void*)n1, 1, NLMSG_ALIGN(n1->nlmsg_len), fp);
}
static int dump_msg(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
static int dump_msg(const struct sockaddr_nl *who, const struct nlmsghdr *n,
void *arg)
{
FILE *fp = (FILE*)arg;
if (!init_phase)

View File

@ -334,7 +334,8 @@ static int xfrm_policy_filter_match(struct xfrm_userpolicy_info *xpinfo)
return 1;
}
int xfrm_policy_print(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
static int xfrm_policy_print(const struct sockaddr_nl *who,
const struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;
struct xfrm_userpolicy_info *xpinfo = NLMSG_DATA(n);
@ -518,7 +519,9 @@ static int xfrm_policy_get(int argc, char **argv)
* With an existing policy of nlmsg, make new nlmsg for deleting the policy
* and store it to buffer.
*/
int xfrm_policy_keep(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
static int xfrm_policy_keep(const struct sockaddr_nl *who,
const struct nlmsghdr *n,
void *arg)
{
struct xfrm_buffer *xb = (struct xfrm_buffer *)arg;
struct rtnl_handle *rth = xb->rth;

View File

@ -371,7 +371,9 @@ static int xfrm_selector_iszero(struct xfrm_selector *s)
return (memcmp(&s0, s, sizeof(s0)) == 0);
}
int xfrm_state_print(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
static int xfrm_state_print(const struct sockaddr_nl *who,
const struct nlmsghdr *n,
void *arg)
{
FILE *fp = (FILE*)arg;
struct xfrm_usersa_info *xsinfo = NLMSG_DATA(n);
@ -511,7 +513,9 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete)
* With an existing state of nlmsg, make new nlmsg for deleting the state
* and store it to buffer.
*/
int xfrm_state_keep(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
static int xfrm_state_keep(const struct sockaddr_nl *who,
const struct nlmsghdr *n,
void *arg)
{
struct xfrm_buffer *xb = (struct xfrm_buffer *)arg;
struct rtnl_handle *rth = xb->rth;

View File

@ -105,7 +105,7 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
return sendto(rth->fd, (void*)&req, sizeof(req), 0, (struct sockaddr*)&nladdr, sizeof(nladdr));
}
int rtnl_send(struct rtnl_handle *rth, char *buf, int len)
int rtnl_send(struct rtnl_handle *rth, const char *buf, int len)
{
struct sockaddr_nl nladdr;
@ -140,9 +140,9 @@ int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
}
int rtnl_dump_filter(struct rtnl_handle *rth,
int (*filter)(struct sockaddr_nl *, struct nlmsghdr *n, void *),
rtnl_filter_t filter,
void *arg1,
int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
rtnl_filter_t junk,
void *arg2)
{
char buf[16384];
@ -224,7 +224,7 @@ skip_it:
int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
unsigned groups, struct nlmsghdr *answer,
int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
rtnl_filter_t junk,
void *jarg)
{
int status;
@ -341,8 +341,8 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
}
int rtnl_listen(struct rtnl_handle *rtnl,
int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
void *jarg)
rtnl_filter_t handler,
void *jarg)
{
int status;
struct nlmsghdr *h;
@ -414,9 +414,8 @@ int rtnl_listen(struct rtnl_handle *rtnl,
}
}
int rtnl_from_file(FILE *rtnl,
int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
void *jarg)
int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler,
void *jarg)
{
int status;
struct sockaddr_nl nladdr;
@ -486,7 +485,8 @@ int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data)
return 0;
}
int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen)
int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
int alen)
{
int len = RTA_LENGTH(alen);
struct rtattr *rta;
@ -520,7 +520,8 @@ int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data)
return 0;
}
int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen)
int rta_addattr_l(struct rtattr *rta, int maxlen, int type,
const void *data, int alen)
{
struct rtattr *subrta;
int len = RTA_LENGTH(alen);
@ -537,7 +538,6 @@ int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen
return 0;
}
int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
{
while (RTA_OK(rta, len)) {

View File

@ -35,7 +35,7 @@ struct idxmap
static struct idxmap *idxmap[16];
int ll_remember_index(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
int ll_remember_index(const struct sockaddr_nl *who, const struct nlmsghdr *n, void *arg)
{
int h;
struct ifinfomsg *ifi = NLMSG_DATA(n);
@ -131,7 +131,7 @@ unsigned ll_index_to_flags(int idx)
return 0;
}
int ll_name_to_index(char *name)
int ll_name_to_index(const char *name)
{
static char ncache[16];
static int icache;

View File

@ -77,7 +77,7 @@ int match(char *id)
return 0;
}
int get_nlmsg(struct sockaddr_nl *who, struct nlmsghdr *m, void *arg)
int get_nlmsg(const struct sockaddr_nl *who, const struct nlmsghdr *m, void *arg)
{
struct ifinfomsg *ifi = NLMSG_DATA(m);
struct rtattr * tb[IFLA_MAX+1];

View File

@ -176,7 +176,8 @@ void print_class_tcstats(FILE *fp, struct tc_stats *st)
int filter_ifindex;
__u32 filter_qdisc;
int print_class(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
static int print_class(const struct sockaddr_nl *who,
const struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;
struct tcmsg *t = NLMSG_DATA(n);
@ -250,7 +251,7 @@ int print_class(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, "\n");
}
}
if (q && tb[TCA_XSTATS]) {
if (q && tb[TCA_XSTATS] && q->print_xstats) {
q->print_xstats(q, fp, tb[TCA_XSTATS]);
fprintf(fp, "\n");
}

View File

@ -418,7 +418,7 @@ int action_a2n(char *arg, int *result)
return 0;
}
void print_tm(FILE * f, struct tcf_t *tm)
void print_tm(FILE * f, const struct tcf_t *tm)
{
int hz = get_hz();
if (tm->install != 0)

View File

@ -9,7 +9,7 @@
struct qdisc_util
{
struct qdisc_util *next;
char id[16];
const char *id;
int (*parse_qopt)(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n);
int (*print_qopt)(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
int (*print_xstats)(struct qdisc_util *qu, FILE *f, struct rtattr *xstats);
@ -58,7 +58,7 @@ extern char * sprint_tc_classid(__u32 h, char *buf);
extern char * sprint_usecs(__u32 usecs, char *buf);
extern char * sprint_percent(__u32 percent, char *buf);
extern void print_tcstats(FILE *fp, struct tc_stats *st);
extern void print_tcstats_attr(FILE *fp, const struct rtattr *ts);
extern int get_tc_classid(__u32 *h, const char *str);
extern int print_tc_classid(char *buf, int len, __u32 h);
@ -70,11 +70,13 @@ extern int parse_police(int *, char ***, int, struct nlmsghdr *);
extern char *action_n2a(int action, char *buf, int len);
extern int action_a2n(char *arg, int *result);
extern int act_parse_police(struct action_util *a,int *, char ***, int, struct nlmsghdr *);
extern int print_police(struct action_util *a,FILE *f, struct rtattr *tb);
extern int police_print_xstats(struct action_util *a,FILE *f, struct rtattr *tb);
extern int tc_print_action(FILE *f, struct rtattr *tb);
extern int tc_print_ipt(FILE *f, struct rtattr *tb);
extern int print_police(struct action_util *a, FILE *f,
struct rtattr *tb);
extern int police_print_xstats(struct action_util *a,FILE *f,
struct rtattr *tb);
extern int tc_print_action(FILE *f, const struct rtattr *tb);
extern int tc_print_ipt(FILE *f, const struct rtattr *tb);
extern int parse_action(int *, char ***, int, struct nlmsghdr *);
extern void print_tm(FILE *f, struct tcf_t *tm);
extern void print_tm(FILE *f, const struct tcf_t *tm);
#endif