LIBBGP
This is a BGP/BMP Message unpack/pack lib written by Python which is inspired by exabgp especially its code structure design. We can use this lib to unpack or pack BGP/BMP messages both offline and online(like a live BGP speaker).
Quick Start
Install from source code:
$ git clone https://github.com/smartbgp/libbgp
$ cd libbgp
$ python setup.py install
or pip:
$ pip install libbgp
Usage
$ python
Python 2.7.10 (default, Jul 30 2016, 18:31:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from pprint import pprint
>>> from libbgp.bgp.message import Message
>>> update_msg_dict = {
... 'type': 2,
... 'msg': {
... 'attr': {
... 1: 2,
... 2: [(2, [701, 71])],
... 3: '219.158.1.204',
... 5: 100,
... 6: 0,
... 7: [71, '16.96.243.103'],
... 8: ['NO_EXPORT', '1234:5678'],
... 9: '219.158.1.204',
... 10: ['219.158.1.209', '0.0.0.30']
... },
... 'nlri': ['192.168.1.1/32', '172.16.1.1/32'],
... 'withdraw': []
... }
... }
>>> update_msg = Message.pack(update_msg_dict)
>>> update_msg.hex_value
'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00f\x02\x00\x00\x00E@\x01\x01\x02@\x02\x06\x02\x02\x02\xbd\x00G@\x03\x04\xdb\x9e\x01\xcc@\x05\x04\x00\x00\x00d@\x06\x01\x00\xc0\x07\x06\x00G\x10`\xf3g\xc0\x08\x08\xff\xff\xff\x01\x04\xd2\x16.\x80\t\x04\xdb\x9e\x01\xcc\x80\n\x08\xdb\x9e\x01\xd1\x00\x00\x00\x1e \xc0\xa8\x01\x01 \xac\x10\x01\x01'
>>> pprint(Message.unpack(update_msg.hex_value).dict())
{'msg': {'attr': {1: 2,
2: [(2, [701, 71])],
3: '219.158.1.204',
5: 100,
6: 0,
7: [71, '16.96.243.103'],
8: ['NO_EXPORT', '1234:5678'],
9: '219.158.1.204',
10: ['219.158.1.209', '0.0.0.30']},
'nlri': ['192.168.1.1/32', '172.16.1.1/32'],
'withdraw': []},
'type': 2}
>>> Message.unpack(update_msg.hex_value).dict() == update_msg_dict
True
>>>
For more examples, Please reference libbgp/examples
Support
Please join our Slack http://smartbgp.slack.com/ for questions, discussion, suggestions, etc. And welcome to create issues and pull request.
Metadata
Release files for libbgp 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| libbgp-0.2.0.tar.gz | 22.9 kB | Without provenance | Details |
Release files / libbgp-0.2.0.tar.gz
| Download URL | libbgp-0.2.0.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b873dbc83190d8e5a2acb59b461bd75b8a92afbe168ff1597a7f967cb84431fe
|
|
BLAKE2b-256 checksum How to use checksums |
0c4c2995449bfb23e689cf35decaf672a97e3262ce5b785fea006977558aef36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for libbgp 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.