00001
00002
00003
00004
00005
00013
00014
00015
00016 #include <net-snmp/net-snmp-config.h>
00017 #include <net-snmp/net-snmp-includes.h>
00018 #include <net-snmp/agent/net-snmp-agent-includes.h>
00019
00020 void init_watched_string(void);
00021
00022 void init_watched(void)
00023 {
00024 init_watched_string();
00025 }
00026
00027 void init_watched_string(void)
00028 {
00029
00030
00031
00032
00033 static char my_string[256] = "So long, and thanks for all the fish!";
00034
00035
00036
00037
00038
00039
00040
00041 oid my_registration_oid[] =
00042 { 1, 3, 6, 1, 4, 1, 8072, 2, 1, 3, 0 };
00043
00044
00045
00046
00047 netsnmp_handler_registration *reginfo;
00048 netsnmp_watcher_info *watcher_info;
00049 int watcher_flags;
00050
00051
00052
00053
00054
00055 DEBUGMSGTL(("example_string_instance",
00056 "Initalizing example string instance. Default value = %s\n",
00057 my_string));
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 reginfo = netsnmp_create_handler_registration("my example string", NULL,
00070 my_registration_oid,
00071 OID_LENGTH(my_registration_oid),
00072 HANDLER_CAN_RWRITE);
00073
00074
00075
00076
00077
00078
00079
00080
00081 watcher_flags = WATCHER_MAX_SIZE;
00082
00083
00084
00085
00086 watcher_info =
00087 netsnmp_create_watcher_info(my_string, strlen(my_string),
00088 ASN_OCTET_STR, watcher_flags);
00089 watcher_info->max_size = sizeof(my_string);
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 netsnmp_register_watched_instance(reginfo, watcher_info);
00101
00102 DEBUGMSGTL(("example_string_instance",
00103 "Done initalizing example string instance\n"));
00104 }