{"id":27557317,"url":"https://github.com/leitwert-net/ftlbgp","last_synced_at":"2025-07-22T22:04:20.906Z","repository":{"id":265782403,"uuid":"880967764","full_name":"leitwert-net/ftlbgp","owner":"leitwert-net","description":"A Python parser for BGP data in MRT or looking glass format.","archived":false,"fork":false,"pushed_at":"2025-05-30T08:38:25.000Z","size":79,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-02T14:16:40.089Z","etag":null,"topics":["bgp","border-gateway-protocol","mrt","parser","pypy","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leitwert-net.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-30T17:22:22.000Z","updated_at":"2025-06-12T21:10:28.000Z","dependencies_parsed_at":"2025-04-19T20:36:43.868Z","dependency_job_id":"d9afbe6a-f662-42c2-9255-e1e83b049235","html_url":"https://github.com/leitwert-net/ftlbgp","commit_stats":null,"previous_names":["leitwert-net/ftlbgp"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/leitwert-net/ftlbgp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leitwert-net%2Fftlbgp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leitwert-net%2Fftlbgp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leitwert-net%2Fftlbgp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leitwert-net%2Fftlbgp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leitwert-net","download_url":"https://codeload.github.com/leitwert-net/ftlbgp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leitwert-net%2Fftlbgp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266580298,"owners_count":23951193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bgp","border-gateway-protocol","mrt","parser","pypy","python3"],"created_at":"2025-04-19T20:29:25.371Z","updated_at":"2025-07-22T22:04:20.896Z","avatar_url":"https://github.com/leitwert-net.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ftlbgp\n\nA Python parser for BGP data in MRT or looking glass format.\n\n### Key features\n\n- Support for all MRT entry types, BGP messages, and BGP attributes\n- Customizable record and attribute types (no parsing of unneeded data)\n- Programmatic data access with optional CSV and JSON serialization\n- Raw values and human-readable output (e.g. integers vs. strings)\n- Rapid prototyping (namedtuple) and high-performance mode (tuple)\n- Context manager with built-in statistics and flexible error handling\n- Zero-copy operations on all data items (as fast as it gets in Python)\n\n## Compatibility\n\nThis package is compatible with `python3.6` and `pypy3.6-v7.0.0` or greater.\n\n## Installation\n\nRun `pip install ftlbgp` or\n\n```\n~$ git clone https://github.com/leitwert-net/ftlbgp.git`\n~$ cd ftlbgp.git/src\n```\n\nto download and run the source code manually.\n\n## Usage\n\n### Parsing MRT files\n\n```\n~$ python3 -m ftlbgp -h\nusage: python3 -m ftlbgp [-h] [--pkg-help] [--json] \u003cFILE\u003e [\u003cFILE\u003e ...]\n\nftlbgp [v1.0.3] - Parse BGP archives in MRT or looking glass format\n\npositional arguments:\n  \u003cFILE\u003e      input file with BGP data (supports bz2/gz)\n\noptional arguments:\n  -h, --help  show this help message and exit\n  --pkg-help  show package help for BgpParser usage\n  --json      output BGP records in JSON format\n\n```\n\n### Programmatic use\n\n```python\n# Import parser\nfrom ftlbgp import BgpParser\n\n# Prepare input file\nfilename = ...\n\n# Parse default records and attributes\nwith BgpParser() as parse:\n    for record in parse(filename):\n        print(record)\n```\n\n## Customization\n\n```python\n# Parse all records\nwith BgpParser(bgp_records=BgpParser.bgp.records.ALL) as parse:\n    for record in parse(filename):\n        print(record)\n\n# Parse specific records (route and error)\nwith BgpParser(bgp_records=BgpParser.bgp.records.route | BgpParser.bgp.records.error) as parse:\n    for record in parse(filename):\n        print(record)\n\n# Parse all route attributes\nwith BgpParser(bgp_route=BgpParser.bgp.route.ALL) as parse:\n    for record in parse(filename):\n        print(record)\n\n# Parse specific route attributes (default and local_pref)\nwith BgpParser(bgp_route=BgpParser.bgp.route.DEFAULT | BgpParser.bgp.route.local_pref) as parse:\n    for record in parse(filename):\n        print(record)\n```\n\n## Full specification\n\n```\nBgpParser()\n      \nThis @FtlParser instance is used to read input files and generate a set of BGP records (Python tuples).\nIt must be used with a context manager (see sample usage below) and accepts the following arguments.\n\nKeyword arguments:\n  named_records     - Return named tuples instead of plain unnamed tuple records. [Default: True]\n  serialize         - Convert output records to JSON (if named) or CSV (if unnamed). [Default: False]\n  use_cache         - Cache expensive low-entropy values (memory consumption \u003c 1MB). [Default: True]\n  raise_on_errors   - Raise exceptions and stop parsing in case of data errors. [Default: False]\n  bgp_records       - Select the types of BgpRecord entries to be returned by the parser.\n                      Supports bitwise logical operators OR, AND, NOT to specify multiple records.\n                      [Default:\n                        BgpParser.bgp.records.route |\n                        BgpParser.bgp.records.stats |\n                        BgpParser.bgp.records.error\n                       Available:\n                        BgpParser.bgp.records.peer_table\n                        BgpParser.bgp.records.state_change\n                        BgpParser.bgp.records.keep_alive\n                        BgpParser.bgp.records.route_refresh\n                        BgpParser.bgp.records.notification\n                        BgpParser.bgp.records.open\n                        BgpParser.bgp.records.ALL\n                        BgpParser.bgp.records.NONE\n                        BgpParser.bgp.records.DEFAULT]\n  bgp_peer_table    - Select [optionally human-readable] attribute to be included in BgpPeerTableRecord entries.\n                      Supports bitwise logical operators (OR/AND/NOT) to specify multiple attributes.\n                      [Default:\n                        BgpParser.bgp.peer_table[.human].type |\n                        BgpParser.bgp.peer_table[.human].peer_protocol |\n                        BgpParser.bgp.peer_table[.human].peer_bgp_id |\n                        BgpParser.bgp.peer_table[.human].peer_as |\n                        BgpParser.bgp.peer_table[.human].peer_ip\n                       Available:\n                        BgpParser.bgp.peer_table[.human].collector_bgp_id\n                        BgpParser.bgp.peer_table[.human].view_name\n                        BgpParser.bgp.peer_table[.human].ALL\n                        BgpParser.bgp.peer_table[.human].NONE\n                        BgpParser.bgp.peer_table[.human].DEFAULT]\n  bgp_state_change  - Select [optionally human-readable] attribute to be included in BgpStateChangeRecord entries.\n                      Supports bitwise logical operators (OR/AND/NOT) to specify multiple attributes.\n                      [Default:\n                        BgpParser.bgp.state_change[.human].type |\n                        BgpParser.bgp.state_change[.human].timestamp |\n                        BgpParser.bgp.state_change[.human].peer_protocol |\n                        BgpParser.bgp.state_change[.human].peer_as |\n                        BgpParser.bgp.state_change[.human].peer_ip |\n                        BgpParser.bgp.state_change[.human].old_state |\n                        BgpParser.bgp.state_change[.human].new_state\n                       Available:\n                        BgpParser.bgp.state_change[.human].ALL\n                        BgpParser.bgp.state_change[.human].NONE\n                        BgpParser.bgp.state_change[.human].DEFAULT]\n  bgp_route         - Select [optionally human-readable] attribute to be included in BgpRouteRecord entries.\n                      Supports bitwise logical operators (OR/AND/NOT) to specify multiple attributes.\n                      [Default:\n                        BgpParser.bgp.route[.human].type |\n                        BgpParser.bgp.route[.human].source |\n                        BgpParser.bgp.route[.human].sequence |\n                        BgpParser.bgp.route[.human].timestamp |\n                        BgpParser.bgp.route[.human].peer_protocol |\n                        BgpParser.bgp.route[.human].peer_bgp_id |\n                        BgpParser.bgp.route[.human].peer_as |\n                        BgpParser.bgp.route[.human].peer_ip |\n                        BgpParser.bgp.route[.human].nexthop_protocol |\n                        BgpParser.bgp.route[.human].nexthop_ip |\n                        BgpParser.bgp.route[.human].prefix_protocol |\n                        BgpParser.bgp.route[.human].prefix |\n                        BgpParser.bgp.route[.human].path_id |\n                        BgpParser.bgp.route[.human].aspath |\n                        BgpParser.bgp.route[.human].origin |\n                        BgpParser.bgp.route[.human].communities |\n                        BgpParser.bgp.route[.human].large_communities\n                       Available:\n                        BgpParser.bgp.route[.human].extended_communities\n                        BgpParser.bgp.route[.human].multi_exit_disc\n                        BgpParser.bgp.route[.human].atomic_aggregate\n                        BgpParser.bgp.route[.human].aggregator_protocol\n                        BgpParser.bgp.route[.human].aggregator_as\n                        BgpParser.bgp.route[.human].aggregator_ip\n                        BgpParser.bgp.route[.human].only_to_customer\n                        BgpParser.bgp.route[.human].originator_id\n                        BgpParser.bgp.route[.human].cluster_list\n                        BgpParser.bgp.route[.human].local_pref\n                        BgpParser.bgp.route[.human].attr_set\n                        BgpParser.bgp.route[.human].as_pathlimit\n                        BgpParser.bgp.route[.human].aigp\n                        BgpParser.bgp.route[.human].attrs_unknown\n                        BgpParser.bgp.route[.human].ALL\n                        BgpParser.bgp.route[.human].NONE\n                        BgpParser.bgp.route[.human].DEFAULT]\n  bgp_keep_alive    - Select [optionally human-readable] attribute to be included in BgpKeepAliveRecord entries.\n                      Supports bitwise logical operators (OR/AND/NOT) to specify multiple attributes.\n                      [Default:\n                        BgpParser.bgp.keep_alive[.human].type |\n                        BgpParser.bgp.keep_alive[.human].timestamp |\n                        BgpParser.bgp.keep_alive[.human].peer_protocol |\n                        BgpParser.bgp.keep_alive[.human].peer_as |\n                        BgpParser.bgp.keep_alive[.human].peer_ip\n                       Available:\n                        BgpParser.bgp.keep_alive[.human].ALL\n                        BgpParser.bgp.keep_alive[.human].NONE\n                        BgpParser.bgp.keep_alive[.human].DEFAULT]\n  bgp_route_refresh - Select [optionally human-readable] attribute to be included in BgpRouteRefreshRecord entries.\n                      Supports bitwise logical operators (OR/AND/NOT) to specify multiple attributes.\n                      [Default:\n                        BgpParser.bgp.route_refresh[.human].type |\n                        BgpParser.bgp.route_refresh[.human].timestamp |\n                        BgpParser.bgp.route_refresh[.human].peer_protocol |\n                        BgpParser.bgp.route_refresh[.human].peer_as |\n                        BgpParser.bgp.route_refresh[.human].peer_ip |\n                        BgpParser.bgp.route_refresh[.human].refresh_protocol\n                       Available:\n                        BgpParser.bgp.route_refresh[.human].ALL\n                        BgpParser.bgp.route_refresh[.human].NONE\n                        BgpParser.bgp.route_refresh[.human].DEFAULT]\n  bgp_notification  - Select [optionally human-readable] attribute to be included in BgpNotificationRecord entries.\n                      Supports bitwise logical operators (OR/AND/NOT) to specify multiple attributes.\n                      [Default:\n                        BgpParser.bgp.notification[.human].type |\n                        BgpParser.bgp.notification[.human].timestamp |\n                        BgpParser.bgp.notification[.human].peer_protocol |\n                        BgpParser.bgp.notification[.human].peer_as |\n                        BgpParser.bgp.notification[.human].peer_ip |\n                        BgpParser.bgp.notification[.human].error_code |\n                        BgpParser.bgp.notification[.human].error_subcode |\n                        BgpParser.bgp.notification[.human].data\n                       Available:\n                        BgpParser.bgp.notification[.human].ALL\n                        BgpParser.bgp.notification[.human].NONE\n                        BgpParser.bgp.notification[.human].DEFAULT]\n  bgp_open          - Select [optionally human-readable] attribute to be included in BgpOpenRecord entries.\n                      Supports bitwise logical operators (OR/AND/NOT) to specify multiple attributes.\n                      [Default:\n                        BgpParser.bgp.open[.human].type |\n                        BgpParser.bgp.open[.human].timestamp |\n                        BgpParser.bgp.open[.human].peer_protocol |\n                        BgpParser.bgp.open[.human].peer_as |\n                        BgpParser.bgp.open[.human].peer_ip |\n                        BgpParser.bgp.open[.human].version |\n                        BgpParser.bgp.open[.human].my_as |\n                        BgpParser.bgp.open[.human].hold_time |\n                        BgpParser.bgp.open[.human].bgp_id |\n                        BgpParser.bgp.open[.human].capabilities\n                       Available:\n                        BgpParser.bgp.open[.human].params_unknown\n                        BgpParser.bgp.open[.human].ALL\n                        BgpParser.bgp.open[.human].NONE\n                        BgpParser.bgp.open[.human].DEFAULT]\n  bgp_stats         - Select [optionally human-readable] attribute to be included in BgpStatsRecord entries.\n                      Supports bitwise logical operators (OR/AND/NOT) to specify multiple attributes.\n                      [Default:\n                        BgpParser.bgp.stats[.human].type |\n                        BgpParser.bgp.stats[.human].parser_lifetime |\n                        BgpParser.bgp.stats[.human].parser_runtime |\n                        BgpParser.bgp.stats[.human].parser_errors |\n                        BgpParser.bgp.stats[.human].lgl_runtime |\n                        BgpParser.bgp.stats[.human].lgl_entries |\n                        BgpParser.bgp.stats[.human].lgl_errors |\n                        BgpParser.bgp.stats[.human].mrt_runtime |\n                        BgpParser.bgp.stats[.human].mrt_entries |\n                        BgpParser.bgp.stats[.human].mrt_errors |\n                        BgpParser.bgp.stats[.human].mrt_fixes |\n                        BgpParser.bgp.stats[.human].mrt_bgp_entry_types |\n                        BgpParser.bgp.stats[.human].mrt_bgp_message_types |\n                        BgpParser.bgp.stats[.human].mrt_bgp_attribute_types |\n                        BgpParser.bgp.stats[.human].mrt_bgp_capability_types |\n                        BgpParser.bgp.stats[.human].bgp_routes_rib_ipv4 |\n                        BgpParser.bgp.stats[.human].bgp_routes_rib_ipv6 |\n                        BgpParser.bgp.stats[.human].bgp_routes_announce_ipv4 |\n                        BgpParser.bgp.stats[.human].bgp_routes_announce_ipv6 |\n                        BgpParser.bgp.stats[.human].bgp_routes_withdraw_ipv4 |\n                        BgpParser.bgp.stats[.human].bgp_routes_withdraw_ipv6\n                       Available:\n                        BgpParser.bgp.stats[.human].ALL\n                        BgpParser.bgp.stats[.human].NONE\n                        BgpParser.bgp.stats[.human].DEFAULT]\n  bgp_error         - Select [optionally human-readable] attribute to be included in BgpErrorRecord entries.\n                      Supports bitwise logical operators (OR/AND/NOT) to specify multiple attributes.\n                      [Default:\n                        BgpParser.bgp.error[.human].type |\n                        BgpParser.bgp.error[.human].source |\n                        BgpParser.bgp.error[.human].scope |\n                        BgpParser.bgp.error[.human].record |\n                        BgpParser.bgp.error[.human].reason |\n                        BgpParser.bgp.error[.human].message |\n                        BgpParser.bgp.error[.human].data |\n                        BgpParser.bgp.error[.human].trace\n                       Available:\n                        BgpParser.bgp.error[.human].ALL\n                        BgpParser.bgp.error[.human].NONE\n                        BgpParser.bgp.error[.human].DEFAULT]\n\nReturns:\n  parse(\u003cfilename\u003e) - Parse function that accepts a filename as single positional argument and generates\n                      all specified BGP records on invocation. Input files can be provided in .bz2 or .gz\n                      format. The parse function may be invoked multiple times within a single context.\n\nRaises:\n  FtlError          - Generic parser or runtime error.\n  FtlFileError      - Failure during access of input file.\n  FtlFormatError    - Unexpected format of input file.\n  FtlDataError      - Invalid data entry in input file.\n```\n\n## Author\n\nJohann SCHLAMP \u003c[schlamp@leitwert.net](mailto:schlamp@leitwert.net)\u003e \n\n## License\n\nCopyright (C) 2014-2025 Leitwert GmbH\n\nThis software is distributed under the terms of the MIT license.    \nIt can be found in the LICENSE file or at [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleitwert-net%2Fftlbgp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleitwert-net%2Fftlbgp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleitwert-net%2Fftlbgp/lists"}