408
408
cat >> $tmpfile <<EOF
409
const char *app_name = "$outname";
409
411
extern int netsnmp_running;
414
#define UNUSED __attribute__((unused))
420
stop_server(UNUSED int a) {
413
421
netsnmp_running = 0;
425
usage(const char *prog)
428
"USAGE: %s [OPTIONS]\n"
433
" -d\t\t\tdump all traffic\n"
434
" -D TOKEN[,...]\tturn on debugging output for the specified "
436
"\t\t\t (ALL gives extremely verbose debugging output)\n"
437
" -f\t\t\tDo not fork() from the calling shell.\n"
438
" -h\t\t\tdisplay this help message\n"
439
" -H\t\t\tdisplay a list of configuration file directives\n"
440
" -L LOGOPTS\t\tToggle various defaults controlling logging:\n");
441
snmp_log_options_usage("\t\t\t ", stderr);
442
#ifndef DISABLE_MIB_LOADING
444
" -m MIB[:...]\t\tload given list of MIBs (ALL loads "
446
" -M DIR[:...]\t\tlook in given list of directories for MIBs\n");
447
#endif /* DISABLE_MIB_LOADING */
448
#ifndef DISABLE_MIB_LOADING
450
" -P MIBOPTS\t\tToggle various defaults controlling mib "
452
snmp_mib_toggle_options_usage("\t\t\t ", stderr);
453
#endif /* DISABLE_MIB_LOADING */
455
" -v\t\t\tdisplay package version number\n"
456
" -x TRANSPORT\tconnect to master agent using TRANSPORT\n");
463
fprintf(stderr, "NET-SNMP version: %s\n", netsnmp_get_version());
417
main (int argc, char **argv) {
418
/* print log errors to stderr */
419
snmp_enable_stderrlog();
420
/* we are a subagent */
421
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
423
/* initialize tcpip, if necessary */
468
main (int argc, char **argv)
472
int dont_fork = 0, do_help = 0;
474
while ((arg = getopt(argc, argv, "dD:fhHL:"
475
#ifndef DISABLE_MIB_LOADING
477
#endif /* DISABLE_MIB_LOADING */
479
#ifndef DISABLE_MIB_LOADING
481
#endif /* DISABLE_MIB_LOADING */
485
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
486
NETSNMP_DS_LIB_DUMP_PACKET, 1);
490
debug_register_tokens(optarg);
491
snmp_set_do_debugging(1);
507
if (snmp_log_options(optarg, argc, argv) < 0) {
512
#ifndef DISABLE_MIB_LOADING
514
if (optarg != NULL) {
515
setenv("MIBS", optarg, 1);
522
if (optarg != NULL) {
523
setenv("MIBDIRS", optarg, 1);
528
#endif /* DISABLE_MIB_LOADING */
531
if (optarg != NULL) {
533
netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
534
NETSNMP_DS_LIB_APPTYPE, app_name);
540
#ifndef DISABLE_MIB_LOADING
542
cp = snmp_mib_toggle_options(optarg);
544
fprintf(stderr, "Unknown parser option to -P: %c.\n", *cp);
548
#endif /* DISABLE_MIB_LOADING */
555
if (optarg != NULL) {
556
netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
557
NETSNMP_DS_AGENT_X_SOCKET, optarg);
564
fprintf(stderr, "invalid option: -%c\n", arg);
571
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
572
NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
574
/* we are a subagent */
575
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
576
NETSNMP_DS_AGENT_ROLE, 1);
579
if (netsnmp_daemonize(1, snmp_stderrlog_status()) != 0)
583
/* initialize tcpip, if necessary */
426
587
/* initialize the agent library */
427
init_agent("$outname");
588
init_agent(app_name);
429
590
/* initialize your mib code here */