1 /* This is an include file for the NetX SNMP demo programs for setting up the MIB for 2 user callback functions. It is not part of the official release of NetX SNMP Agent. */ 3 4 #ifndef SNMP_HELPER_H 5 #define SNMP_HELPER_H 6 7 /* Determine if a C++ compiler is being used. If so, ensure that standard 8 C is used to process the API information. */ 9 10 #ifdef __cplusplus 11 12 /* Yes, C++ compiler is present. Use standard C. */ 13 extern "C" { 14 #endif 15 16 #include "tx_api.h" 17 #include "nx_api.h" 18 #include "nxd_snmp.h" 19 20 /* Define application MIB data structure. Actual application structures would certainly vary. */ 21 22 typedef struct MIB_ENTRY_STRUCT 23 { 24 25 UCHAR *object_name; 26 void *object_value_ptr; 27 UINT (*object_get_callback)(VOID *source_ptr, NX_SNMP_OBJECT_DATA *object_data); 28 UINT (*object_get_octet_callback)(VOID *source_ptr, NX_SNMP_OBJECT_DATA *object_data, UINT length); 29 UINT (*object_set_callback)(VOID *destination_ptr, NX_SNMP_OBJECT_DATA *object_data); 30 UINT length; 31 } MIB_ENTRY; 32 33 /* Define the MIB-2 "system" group. */ 34 35 UCHAR sysDescr[] = "NetX SNMP Agent"; /* sysDescr:OctetString RO */ 36 UCHAR sysObjectID[] = "1.3.6.1.2.1.1"; /* sysObjectID:ObjectID RO */ 37 ULONG sysUpTime = 0; /* sysUpTime:TimeTicks RO */ 38 UCHAR sysContact[128] = "NetX sysContact Name"; /* sysContact:OctetString RW */ 39 UCHAR sysName[128] = "NetX sysName"; /* sysName:OctetString RW */ 40 UCHAR sysLocation[128] = "NetX sysLocation"; /* sysLocation:OctetString RW */ 41 ULONG sysServices = 1; /* sysServices:Integer RW */ 42 ULONG ipForwarding = 0; /* ipForwarding:Integer RW */ 43 ULONG ipDefaultTTL = NX_IP_TIME_TO_LIVE; /* ipDefaultTTL:Integer RW */ 44 45 /* Define the MIB-2 "interfaces" group, assuming one interface. Update of these variables could be added to the 46 underlying application driver, but for now simple defaults are used. */ 47 ULONG ifLastChange = 2048; /* ifLastChange:TimeTicks RO */ 48 ULONG ifInOctets = 155; /* ifInOctets:Counter RO */ 49 ULONG ifInUcastPkts = 0; /* ifInUcastPkts:Counter RO */ 50 UCHAR ifDescr[] = "NetX Physical Interface"; /* ifDescr:OctetString RO */ 51 52 /* Define the MIB-2 "address translation" group, assuming one address translation. */ 53 54 UCHAR atPhysAddress[] = {0x00,0x04,0xac,0xe3,0x1d,0xc5};/* atPhysAddress:OctetString RW */ 55 ULONG atNetworkAddress = 0; /* atNetworkAddress:NetworkAddr RW */ 56 UCHAR atIPv6NetworkAddress[16]; /* atNetworkAddress:NetworkAddr IPv6 RW */ 57 58 59 /* Define the actual MIB-2. */ 60 61 MIB_ENTRY mib2_mib[] = { 62 63 /* OBJECT ID OBJECT VARIABLE GET ROUTINE/ GET_OCTET_ROUTINE SET ROUTINE LENGTH */ 64 65 {(UCHAR *) "1.3.6.1.2.1.1.1.0", sysDescr, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, 0}, 66 {(UCHAR *) "1.3.6.1.2.1.1.2.0", sysObjectID, nx_snmp_object_id_get, NX_NULL, NX_NULL, 0}, 67 {(UCHAR *) "1.3.6.1.2.1.1.3.0", &sysUpTime, nx_snmp_object_timetics_get, NX_NULL, NX_NULL, 0}, 68 {(UCHAR *) "1.3.6.1.2.1.1.4.0", sysContact, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, 0}, 69 {(UCHAR *) "1.3.6.1.2.1.1.5.0", sysName, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, 0}, 70 {(UCHAR *) "1.3.6.1.2.1.1.6.0", sysLocation, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, 0}, 71 {(UCHAR *) "1.3.6.1.2.1.1.7.0", &sysServices, nx_snmp_object_integer_get, NX_NULL, NX_NULL, 0}, 72 73 {(UCHAR *) "1.3.6.1.2.1.3.1.1.3.0", &atNetworkAddress, nx_snmp_object_ip_address_get, NX_NULL, nx_snmp_object_ip_address_set, 0}, 74 #ifdef FEATURE_NX_IPV6 75 /* Either GET method should work. IPv6 addresses are handled as octet strings and accept any IPv6 address format e.g. addresses with '::'s are accepted as is. */ 76 {(UCHAR *) "1.3.6.1.2.1.3.1.1.3.1", &atIPv6NetworkAddress, nx_snmp_object_ipv6_address_get, NX_NULL, nx_snmp_object_ipv6_address_set, 0}, 77 {(UCHAR *) "1.3.6.1.2.1.3.1.1.3.2", &atIPv6NetworkAddress, NX_NULL, nx_snmp_object_octet_string_get, nx_snmp_object_octet_string_set, 0}, 78 #endif 79 80 {(UCHAR *) "1.3.6.1.2.1.2.2.1.2.0", ifDescr, nx_snmp_object_string_get, NX_NULL, NX_NULL, 0}, 81 {(UCHAR *) "1.3.6.1.2.1.3.1.1.2.0", &atPhysAddress, NX_NULL, nx_snmp_object_octet_string_get, nx_snmp_object_octet_string_set, 0}, 82 {(UCHAR *) "1.3.6.1.2.1.2.2.1.9.0", &ifLastChange, nx_snmp_object_timetics_get, NX_NULL, nx_snmp_object_timetics_set, 0}, 83 {(UCHAR *) "1.3.6.1.2.1.2.2.1.10.0", &ifInOctets, nx_snmp_object_counter_get, NX_NULL, nx_snmp_object_counter_set, 0}, 84 {(UCHAR *) "1.3.6.1.2.1.2.2.1.11.0", &ifInUcastPkts, nx_snmp_object_counter64_get, NX_NULL, nx_snmp_object_counter64_set, 0}, 85 86 {(UCHAR *) "1.3.6.1.2.1.4.1.0", &ipForwarding, nx_snmp_object_integer_get, NX_NULL, nx_snmp_object_integer_set, 0}, 87 {(UCHAR *) "1.3.6.1.2.1.4.2.0", &ipDefaultTTL, nx_snmp_object_integer_get, NX_NULL, NX_NULL, 0}, 88 89 {(UCHAR *) "1.3.6.1.7", (UCHAR *) "1.3.6.1.7", nx_snmp_object_end_of_mib, NX_NULL, NX_NULL, 0}, 90 {NX_NULL, NX_NULL, NX_NULL, NX_NULL, NX_NULL, 0} 91 92 }; 93 94 95 #endif /* SNMP_HELPER_H */ 96