How can I change these SNMP ports where the Rabbit listen and where the traps are sent while the code is running?

I need to code a SW which changes while running the value of the SNMP ports which my device listens to SNMP packets and which trap packets are sent to instead of using the macros SNMP_PORT and SNMP_TRAP_PORT.

Here is the link to the TCPIP user manual, volume 2 Chapter 12 has full details on the SNMP library and its functions.

I see of no way to change the ports at runtime, only through the macros.

If you want to do it so that the port numbers are programmable there is a simple way to do it and a complicated way!

Simple way assumes you can reset the Rabbit device either by power cycling it or by doing a watchdog reset. To do this you define the macros to be integer variables instead of constants and set those variables up on power up. This is simple enough but does require a reset before the new values are recognised as the SNMP library does not have a shut down and reinitialise option.

The more complicated way would be to change the macros to variables as above and modify the library to add a shutdown function so that you can shut down SNMP (closing open sockets, resetting state variables etc), modify the variables and restart SNMP. It would not be a huge job to do this.