From 6e93454761e99a1d90e51cd5be3b8e4b1328360f Mon Sep 17 00:00:00 2001 From: Hideaki Yoshifuji Date: Wed, 2 Jun 2004 09:51:12 +0900 Subject: [PATCH] [NET] Introduce and use several common stuff for snmp item list. --- include/net/snmp.h | 16 +++++++++++++++- net/ipv6/proc.c | 27 ++++++++++----------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/include/net/snmp.h b/include/net/snmp.h index 67e22b82e9084..ccb4236362e8c 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h @@ -41,7 +41,21 @@ * cacheline machine it makes a *lot* of sense -AK */ - +struct snmp_item { + char *name; + int offset; +}; + +#define SNMP_ITEM(mib,entry,procname) { \ + .name = procname, \ + .offset = offsetof(mib, entry), \ +} + +#define SNMP_ITEM_SENTINEL { \ + .name = NULL, \ + .offset = 0, \ +} + /* * RFC 1213: MIB-II * RFC 2011 (updates 1213): SNMPv2-MIB-IP diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index e6e4621f5b12e..129c4f04f12fc 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c @@ -57,16 +57,9 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v) return 0; } -struct snmp6_item -{ - char *name; - int offset; -}; -#define SNMP6_SENTINEL { .name = NULL, .offset = 0 } - -static struct snmp6_item snmp6_ipv6_list[] = { +static struct snmp_item snmp6_ipv6_list[] = { /* ipv6 mib according to RFC 2465 */ -#define SNMP6_GEN(x) { .name = #x , .offset = offsetof(struct ipv6_mib, x) } +#define SNMP6_GEN(x) SNMP_ITEM(struct ipv6_mib, x, "Ip6" #x) SNMP6_GEN(Ip6InReceives), SNMP6_GEN(Ip6InHdrErrors), SNMP6_GEN(Ip6InTooBigErrors), @@ -90,10 +83,10 @@ static struct snmp6_item snmp6_ipv6_list[] = { SNMP6_GEN(Ip6InMcastPkts), SNMP6_GEN(Ip6OutMcastPkts), #undef SNMP6_GEN - SNMP6_SENTINEL + SNMP_ITEM_SENTINEL }; -static struct snmp6_item snmp6_icmp6_list[] = { +static struct snmp_item snmp6_icmp6_list[] = { /* icmpv6 mib according to RFC 2466 Exceptions: {In|Out}AdminProhibs are removed, because I see @@ -104,7 +97,7 @@ static struct snmp6_item snmp6_icmp6_list[] = { OutRouterAdvertisements too. OutGroupMembQueries too. */ -#define SNMP6_GEN(x) { .name = #x , .offset = offsetof(struct icmpv6_mib, x) } +#define SNMP6_GEN(x) SNMP_ITEM(struct icmpv6_mib, x, #x) SNMP6_GEN(Icmp6InMsgs), SNMP6_GEN(Icmp6InErrors), SNMP6_GEN(Icmp6InDestUnreachs), @@ -134,17 +127,17 @@ static struct snmp6_item snmp6_icmp6_list[] = { SNMP6_GEN(Icmp6OutGroupMembResponses), SNMP6_GEN(Icmp6OutGroupMembReductions), #undef SNMP6_GEN - SNMP6_SENTINEL + SNMP_ITEM_SENTINEL }; -static struct snmp6_item snmp6_udp6_list[] = { -#define SNMP6_GEN(x) { .name = "Udp6" #x , .offset = offsetof(struct udp_mib, Udp##x) } +static struct snmp_item snmp6_udp6_list[] = { +#define SNMP6_GEN(x) SNMP_ITEM(struct udp_mib, Udp##x, "Udp6" #x) SNMP6_GEN(InDatagrams), SNMP6_GEN(NoPorts), SNMP6_GEN(InErrors), SNMP6_GEN(OutDatagrams), #undef SNMP6_GEN - SNMP6_SENTINEL + SNMP_ITEM_SENTINEL }; static unsigned long @@ -167,7 +160,7 @@ fold_field(void *mib[], int offt) } static inline void -snmp6_seq_show_item(struct seq_file *seq, void **mib, struct snmp6_item *itemlist) +snmp6_seq_show_item(struct seq_file *seq, void **mib, struct snmp_item *itemlist) { int i; for (i=0; itemlist[i].name; i++) -- 2.53.0