diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-06-13 08:05:25 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-06-13 08:05:25 +0900 |
commit | 5474bf214c22ca459719ddbe786a3c9a8f967757 (patch) | |
tree | 8734b1fbee081e4fbee928504f7a392a176a4ee6 /doc | |
parent | 6fbd67e29b071e5e63eff832e9cb8b1e7da0ea92 (diff) |
bgp: add bgpspaker module for non Ryu application usage
This enables you to use Ryu BGP feature as 'bgp speaker' python
library, that is, without ryu-manager, RPC API, REST API, or other Ryu
stuff, you can use Ryu BGP feature in your python application (just
import bgpspeaker.py). The sample code and the API reference docs are
included too.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/source/library.rst | 2 | ||||
-rw-r--r-- | doc/source/library_bgp_speaker.rst | 44 | ||||
-rw-r--r-- | doc/source/library_bgp_speaker_ref.rst | 12 |
3 files changed, 58 insertions, 0 deletions
diff --git a/doc/source/library.rst b/doc/source/library.rst index eee6877a..38cc3872 100644 --- a/doc/source/library.rst +++ b/doc/source/library.rst @@ -10,3 +10,5 @@ Ryu provides some useful library for your network applications. library_packet.rst library_packet_ref.rst library_of_config.rst + library_bgp_speaker.rst + library_bgp_speaker_ref.rst diff --git a/doc/source/library_bgp_speaker.rst b/doc/source/library_bgp_speaker.rst new file mode 100644 index 00000000..443242cf --- /dev/null +++ b/doc/source/library_bgp_speaker.rst @@ -0,0 +1,44 @@ +******************* +BGP speaker library +******************* + +Introduction +============ + +Ryu BGP speaker library helps you to enable your code to speak BGP +protocol. The library supports ipv4, ipv4 vpn, and ipv6 vpn address +families. + +Example +======= + +The following simple code creates a BGP instance with AS number 64512 +and Router ID 10.0.0.1. It tries to establish a bgp session with a +peer (its IP is 192.168.177.32 and the AS number is 64513). The +instance advertizes some prefixes. + +.. code-block:: python + + import eventlet + from ryu.services.protocols.bgp.bgpspeaker import BGPSpeaker + + def dump_remote_best_path_change(event): + print 'the best path changed:', event.remote_as, event.prefix,\ + event.nexthop, event.is_withdraw + + if __name__ == "__main__": + speaker = BGPSpeaker(as_number=64512, router_id='10.0.0.1', + best_path_change_handler=dump_remote_best_path_change) + + speaker.neighbor_add('192.168.177.32', 64513) + + count = 1 + while True: + eventlet.sleep(30) + prefix = '10.20.' + str(count) + '.0/24' + print "add a new prefix", prefix + speaker.prefix_add(prefix) + count += 1 + if count == 4: + speaker.shutdown() + break diff --git a/doc/source/library_bgp_speaker_ref.rst b/doc/source/library_bgp_speaker_ref.rst new file mode 100644 index 00000000..493f322e --- /dev/null +++ b/doc/source/library_bgp_speaker_ref.rst @@ -0,0 +1,12 @@ +********************************* +BGP speaker library API Reference +********************************* + +BGPSpeaker class +================ + +.. autoclass:: ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker + :members: + +.. autoclass:: ryu.services.protocols.bgp.bgpspeaker.EventPrefix + :members: |