summaryrefslogtreecommitdiff
path: root/src/conf_mode/snmp.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2022-07-24 17:33:09 +0100
committerGitHub <noreply@github.com>2022-07-24 17:33:09 +0100
commit4168e03721b2a9595de4090fddf1280d39ccce4c (patch)
tree8d91f6363eaed85980eb2a85e67457f699b4b8c0 /src/conf_mode/snmp.py
parent91efb252a73af6f8531a196bda147dca3b0978eb (diff)
parenta5580f2fc6f76026a0e72561bf797d03fee40a8c (diff)
downloadvyos-1x-4168e03721b2a9595de4090fddf1280d39ccce4c.tar.gz
vyos-1x-4168e03721b2a9595de4090fddf1280d39ccce4c.zip
Merge pull request #1416 from sever-sever/T2763-eq
snmp: T2763: Add protocol TCP for service SNMP
Diffstat (limited to 'src/conf_mode/snmp.py')
-rwxr-xr-xsrc/conf_mode/snmp.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py
index 6d22d06f1..25ff9d0dd 100755
--- a/src/conf_mode/snmp.py
+++ b/src/conf_mode/snmp.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2018-2020 VyOS maintainers and contributors
+# Copyright (C) 2018-2022 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -56,6 +56,7 @@ default_config_data = {
'communities': [],
'smux_peers': [],
'location' : '',
+ 'protocol' : 'udp',
'description' : '',
'contact' : '',
'trap_source': '',
@@ -154,6 +155,9 @@ def get_config():
if conf.exists('location'):
snmp['location'] = conf.return_value('location')
+ if conf.exists('protocol'):
+ snmp['protocol'] = conf.return_value('protocol')
+
if conf.exists('smux-peer'):
snmp['smux_peers'] = conf.return_values('smux-peer')
@@ -404,14 +408,15 @@ def verify(snmp):
for listen in snmp['listen_address']:
addr = listen[0]
port = listen[1]
+ protocol = snmp['protocol']
tmp = None
if is_ipv4(addr):
# example: udp:127.0.0.1:161
- tmp = f'udp:{addr}:{port}'
+ tmp = f'{protocol}:{addr}:{port}'
elif snmp['ipv6_enabled']:
# example: udp6:[::1]:161
- tmp = f'udp6:[{addr}]:{port}'
+ tmp = f'{protocol}6:[{addr}]:{port}'
# We only wan't to configure addresses that exist on the system.
# Hint the user if they don't exist