@@ -103,6 +103,12 @@ static
103103char * implode_result ;
104104#endif
105105
106+ static
107+ int session_retries = 2 ;
108+
109+ static
110+ long pdu_max_repetitions = 4096L ;
111+
106112int
107113main (int argc , char * argv [])
108114{
@@ -219,6 +225,8 @@ main(int argc, char *argv[])
219225 {"help" , no_argument , NULL , '?' },
220226 {"timeout" , required_argument , NULL , 2 },
221227 {"sleep" , required_argument , NULL , 3 },
228+ {"retries" , required_argument , NULL , 4 },
229+ {"max-repetitions" , required_argument , NULL , 5 },
222230 {NULL , 0 , NULL , 0 }
223231 };
224232
@@ -318,6 +326,12 @@ main(int argc, char *argv[])
318326 /* convert from ms to us */
319327 sleep_usecs = strtol (optarg , NULL , 10 ) * 1000UL ;
320328 break ;
329+ case 4 :
330+ session_retries = atoi (optarg );
331+ break ;
332+ case 5 :
333+ pdu_max_repetitions = strtol (optarg , NULL , 10 );
334+ break ;
321335 case '?' :
322336 default :
323337 exit (usage (progname ));
@@ -426,7 +440,7 @@ main(int argc, char *argv[])
426440
427441 /* build our request depending on the mode */
428442 if (count == 0 )
429- create_pdu (mode , oid_ifp , & pdu , & OIDp , 2 , MAX_REPETITIONS_LIMIT );
443+ create_pdu (mode , oid_ifp , & pdu , & OIDp , 2 , pdu_max_repetitions );
430444 else {
431445 /* we have not received all interfaces in the preceding packet, so fetch the next lot */
432446
@@ -435,7 +449,7 @@ main(int argc, char *argv[])
435449 else {
436450 pdu = snmp_pdu_create (SNMP_MSG_GETBULK );
437451 pdu -> non_repeaters = 0 ;
438- pdu -> max_repetitions = MAX_REPETITIONS_LIMIT ;
452+ pdu -> max_repetitions = pdu_max_repetitions ;
439453 }
440454 snmp_add_null_var (pdu , lastOid .name , lastOid .name_len );
441455 }
@@ -1193,7 +1207,7 @@ netsnmp_session *start_session(netsnmp_session *session, char *community, char *
11931207 session -> community = (u_char * )community ;
11941208 session -> community_len = strlen (community );
11951209 session -> timeout = global_timeout ;
1196- session -> retries = 0 ;
1210+ session -> retries = session_retries ;
11971211
11981212 /*
11991213 * Open the session
@@ -1276,7 +1290,7 @@ netsnmp_session *start_session_v3(netsnmp_session *session, char *user, char *au
12761290 }
12771291
12781292 session -> timeout = global_timeout ;
1279- session -> retries = 0 ;
1293+ session -> retries = session_retries ;
12801294
12811295 /*
12821296 * Open the session
@@ -1335,6 +1349,8 @@ int usage(char *progname)
13351349 printf (" -N|--if-names\t\tuse ifName instead of ifDescr\n" );
13361350 printf (" --timeout\t\tsets the SNMP timeout (in ms)\n" );
13371351 printf (" --sleep\t\tsleep between every SNMP query (in ms)\n" );
1352+ printf (" --retries\t\thow often to retry before giving up\n" );
1353+ printf (" --max-repetitions\t\tsee <http://www.net-snmp.org/docs/man/snmpbulkwalk.html>\n" );
13381354 printf ("\n" );
13391355 return 3 ;
13401356}
0 commit comments