File 0930-snmp-agent-Make-it-possible-to-exclude-varbids-from-.patch of Package erlang
From b912ff1c6138782bab9750669380a862fc5659d4 Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Wed, 11 Dec 2019 12:18:10 +0100
Subject: [PATCH 1/3] [snmp|agent] Make it possible to exclude varbids from
notifications
By introducing an 'ignore' value, we allow the sender to exclude
a varbind from the notification.
OTP-16349
---
lib/snmp/include/snmp_types.hrl | 8 ++++++++
lib/snmp/src/agent/snmpa_trap.erl | 5 ++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/lib/snmp/include/snmp_types.hrl b/lib/snmp/include/snmp_types.hrl
index eff17a13a3..a521db502b 100644
--- a/lib/snmp/include/snmp_types.hrl
+++ b/lib/snmp/include/snmp_types.hrl
@@ -22,6 +22,14 @@
%% Note: All internal representations may be changed without notice.
%%----------------------------------------------------------------------
+%%----------------------------------------------------------------------
+%% Use this 'value' when sending a notification if wanting to exclude
+%% a varbind form the (notification) message.
+%%----------------------------------------------------------------------
+
+-define(NOTIFICATION_IGNORE_VB_VALUE, '$ignore-oid').
+
+
%%----------------------------------------------------------------------
%% Variablebinding
%% oid: a list of integers (see snmp_misc:is_oid)
diff --git a/lib/snmp/src/agent/snmpa_trap.erl b/lib/snmp/src/agent/snmpa_trap.erl
index 62f35cdaf9..eaf5fde687 100644
--- a/lib/snmp/src/agent/snmpa_trap.erl
+++ b/lib/snmp/src/agent/snmpa_trap.erl
@@ -132,7 +132,7 @@
%%-----------------------------------------------------------------
construct_trap(Trap, Varbinds) ->
?vdebug("construct_trap -> entry with"
- "~n Trap: ~p", [Trap]),
+ "~n Trap: ~p", [Trap]),
case snmpa_symbolic_store:get_notification(Trap) of
undefined ->
user_err("construct_trap got undef Trap: ~w" , [Trap]),
@@ -193,6 +193,8 @@ initiate_vars([{Oid, Asn1Type} | T], Varbinds) ->
case delete_oid_from_varbinds(Oid, Varbinds) of
{undefined, _, _} ->
[{Oid, Asn1Type} | initiate_vars(T, Varbinds)];
+ {?NOTIFICATION_IGNORE_VB_VALUE, _VarOid, RestOfVarbinds} -> % Skip this oid!
+ initiate_vars(T, RestOfVarbinds);
{Value, VarOid, RestOfVarbinds} ->
[{VarOid, Asn1Type, Value} | initiate_vars(T, RestOfVarbinds)]
end;
@@ -212,6 +214,7 @@ delete_oid_from_varbinds(Oid, [H | T]) ->
{Value, VarOid, [H | T2]};
delete_oid_from_varbinds(_Oid, []) -> {undefined, undefined, []}.
+
%%-----------------------------------------------------------------
%% Func: try_initialise_vars(Mib, Varbinds)
%% Args: Mib is the local mib process
--
2.16.4