]> git.hungrycats.org Git - linux/commitdiff
[NET] Introduce and use several common stuff for snmp item list.
authorHideaki Yoshifuji <yoshfuji@linux-ipv6.org>
Wed, 2 Jun 2004 00:51:12 +0000 (09:51 +0900)
committerHideaki Yoshifuji <yoshfuji@linux-ipv6.org>
Wed, 2 Jun 2004 00:51:12 +0000 (09:51 +0900)
include/net/snmp.h
net/ipv6/proc.c

index 67e22b82e9084048a83402463dad10284ef45300..ccb4236362e8ccce308288c23f135db9919f28fd 100644 (file)
  * 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
index e6e4621f5b12e7c3cfb5b1078491178a49f15fd2..129c4f04f12fcbf9d9dc5574f3f5e34a9c0cdaac 100644 (file)
@@ -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++)