On Thu, 28 Mar 2024 at 00:13, Bart Van Assche <bvanass...@acm.org> wrote:

> Thanks for the background information. I'm not sure the Net-SNMP API needs
> to be modified to realize this. How about the following approach:
>
>    - Use netsnmp_register_handler() in MIB implementations to associate
>    OIDs with callback functions.
>    - In the handler callback function, use the
>    reqinfo->asp->session->local_port information.
>    - Make sure that session->local_port is set correctly. This may
>    require a code change in Net-SNMP.
>
>
> Hi Bart,

I have gone through the above very helpful steps, as follows:

A snmpd was set to listen on 10 ports through multiple entries like
“agentaddress tcp:<port>” in the snmpd.conf file.
It was verified through snmpget that the snmpd listens on all 10 ports.

Function “netsnmp_callback_open” in file
snmplib/transports/snmpCallbackDomain.c was patched to write a few debug
messages.

It appears that the function “netsnmp_callback_open” is called once.
It sets the “callback_ss->local_port” to “((netsnmp_callback_info *)
callback_tr->data)->callback_num”, which is 1.
In the handler callback function, the reqinfo->asp->session->local_port is
0 while processing each snmpget.

You wrote "Make sure that session->local_port is set correctly." I studied
the code to set this properly, but didn't manage to get the port number set
correctly.

Any help or hints for setting session->local_port would be greatly
appreciated :)

With kind regards,

Teus.
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to