TargetCollection Filter

I have a quick question regarding TargetCollection filtering for a trap receiver service. I understand that typically you achieve target filtering by specifying the target origin location, <IP>:<Port>. However, if the exact port number of the trap sender is not known is there a way to handle a specific IP address with any port number?

The reason I ask is I believe the device we are attempting to communicate with will choose any available port upon runtime to send the notifications from - to the registered TrapDestination. Because of this our trap service wouldn’t be able to know ahead of time what IP Port combination to use.

Snmp_pp::UTarget target = this->getTarget();
std::string trapOrigin = 127.0.0.1:16300
Snmp_pp::UdpAddress address(trapOrigin.c_str());
target.set_address(address);
this->targetCollections += target;
...
...

status = snmp.notify_register(trapOidCollection, targetCollections, static_my_callback, NULL);

Hi,

you are right. There is no requirement that an agent will always use the same static port for sending traps.

You can just replace the UdpAddress with an IpAddress object and the trap filter code will ignore the port and only compare the IPs.

Kind regars,
Jochen