On Wed, 3 Apr 2024 at 18:45, Bart Van Assche <bvanass...@acm.org> wrote:

> I think this is the callchain for registering the ports that the agent
> listens on:
>
> init_master_agent()
>   netsnmp_agent_listen_on()
>     netsnmp_transport_open_server()
>     netsnmp_register_agent_nsap()
>       netsnmp_sess_config_transport()
>       snmp_add()
>         snmp_sess_add_ex()
>           transport->f_setup_session()
>
> One possible approach is to implement the .f_setup_session() callback in
> the TCP transport and to make it copy the port information from the
> transport into the session.
>
>
> Hi Bart,

The possible approach that is suggested appears to work very well.

I have implemented the f_setup_session() callback in
the snmpTCPBaseDomain.h/.c files.
This callback obtains the port number and copies that into the session
object.
Then from the session object, the local_port is available while processing
the SNMP requests.
I am happy it works and that we can use this local_port in our software,
that is so helpful.

The patch with the above modification is attached.
It would be so great if this patch can make it in the official tarball of
Net-SNMP.

Thank you for the suggestions and all the help all along.

Regards,

Teus

Attachment: local_tcp_port.patch
Description: Binary data

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

Reply via email to