-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1223 from ton31337/feature/bgp_software_version_c…
…apability Implement software version capability for BGP (needs fixing)
- Loading branch information
Showing
11 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
neighbor 127.0.0.1 { | ||
router-id 10.0.0.2; | ||
local-address 127.0.0.1; | ||
local-as 65533; | ||
peer-as 65533; | ||
hold-time 180; | ||
|
||
capability { | ||
software-version enable; | ||
} | ||
|
||
family { | ||
ipv4 unicast; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
conf-cap-software-version.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
option:open:inspect-open-message | ||
1:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0051:01:04FFFD00B40A000002340206010400010001020641040000FFFD02224B201F4578614247502F6D61696E2D346634323232663265642D3230323430373135 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/exabgp/bgp/message/open/capability/software_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# encoding: utf-8 | ||
""" | ||
software_version.py | ||
Copyright (c) 2024 Donatas Abraitis. All rights reserved. | ||
License: 3-clause BSD. (See the COPYRIGHT file) | ||
""" | ||
|
||
# https://datatracker.ietf.org/doc/html/draft-abraitis-bgp-version-capability | ||
|
||
|
||
from exabgp.bgp.message.open.capability.capability import Capability | ||
from exabgp.version import version | ||
|
||
|
||
@Capability.register() | ||
class SoftwareVersion(Capability): | ||
ID = Capability.CODE.SOFTRWARE_VERSION | ||
SOFTWARE_VERSION_MAX_LEN = 64 | ||
|
||
def __init__(self): | ||
self.software_version = f"ExaBGP/{version}" | ||
|
||
def __str__(self): | ||
return f'SoftwareVersion({self.software_version})' | ||
|
||
def json(self): | ||
return f'{ "software-version": "{self.software_version}" }' | ||
|
||
def extract(self): | ||
software_version = self.software_version.encode('utf-8') | ||
if len(software_version) > self.SOFTWARE_VERSION_MAX_LEN: | ||
software_version = software_version[: self.SOFTWARE_VERSION_MAX_LEN] | ||
return [bytes([len(software_version)]) + software_version] | ||
|
||
@staticmethod | ||
def unpack_capability(instance, data, capability=None): # pylint: disable=W0613 | ||
l1 = data[0] | ||
instance.software_version = data[1 : l1 + 1].decode('utf-8') | ||
return instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters