{"id":15056282,"url":"https://github.com/joaohf/ospfclient","last_synced_at":"2026-01-02T16:04:15.015Z","repository":{"id":255214671,"uuid":"848321667","full_name":"joaohf/ospfclient","owner":"joaohf","description":"FRR ospf client in Erlang","archived":false,"fork":false,"pushed_at":"2024-09-05T17:42:19.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T00:50:13.823Z","etag":null,"topics":["erlang","frr","frrouting","ospf"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joaohf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2024-08-27T14:49:12.000Z","updated_at":"2024-09-05T17:42:23.000Z","dependencies_parsed_at":"2024-11-19T21:39:00.328Z","dependency_job_id":null,"html_url":"https://github.com/joaohf/ospfclient","commit_stats":null,"previous_names":["joaohf/ospfclient"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaohf%2Fospfclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaohf%2Fospfclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaohf%2Fospfclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaohf%2Fospfclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joaohf","download_url":"https://codeload.github.com/joaohf/ospfclient/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243532562,"owners_count":20306156,"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","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":["erlang","frr","frrouting","ospf"],"created_at":"2024-09-24T21:49:44.155Z","updated_at":"2026-01-02T16:04:15.002Z","avatar_url":"https://github.com/joaohf.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"ospfclient\n==========\n\nThis is an Erlang/OTP client for accessing the link-state database (LSDB) of\nthe OSPF daemon from [FRRouting](https://frrouting.org/) routing protocol suite.\n\nUsing this client, an Erlang application could:\n\n* monitor the LSDB from OSPF daemon\n* get informed from NSM, ISM, Router ID changes\n* sync or resync LSDB, ISM, NSM\n\nHow to use\n----------\n\nYou can register callbacks and get notified when something changed\nin OSPF daemon.\n\n```erlang\n    Callbacks = #{\n        'MSG_NSM_CHANGE' =\u003e fun my/3\n        % 'MSG_LSA_UPDATE_NOTIFY' =\u003e fun my/3,\n        % 'MSG_LSA_DELETE_NOTIFY' =\u003e fun my/3\n    },\n    Opts = [{callbacks, Callbacks}, {callback_data, self()}],\n\n    {ok, Handle} = ospfclient:connect({192, 168, 56, 102}, Opts),\n```\n\nFor now, the default OSPF client daemon is: 2607. And is not possible to define an alternative port.\n\nAll callbacks follow the type (`ospfclient:async_handler()`):\n\n```erlang\n    -type async_handler() :: fun((string(), term(), any()) -\u003e ok).\n```\n\nThe follow async messages are supported:\n\n* 'MSG_READY_NOTIFY'\n* 'MSG_LSA_UPDATE_NOTIFY'\n* 'MSG_LSA_DELETE_NOTIFY'\n* 'MSG_NEW_IF'\n* 'MSG_DEL_IF'\n* 'MSG_ISM_CHANGE'\n* 'MSG_NSM_CHANGE'\n* 'MSG_REACHABLE_CHANGE'\n* 'MSG_ROUTER_ID_CHANGE'\n\nDesign\n------\n\nThe module `ospfclient` spawns two erlang process responsible for handle sync and async messages.\n\n* sync messages are to OSPF daemon\n* async messages are messages from OSPF daemon\n\nThe sync and async process are linked for safe reasons. Each process manages a specific Socket.\n\n```mermaid\nflowchart LR\n    sync((Sync))-. link .-async((Async))\n```\n\nThere is a small connection protocol in order to get the async socket working:\n\n* 4001/tcp port is open and waits for connection from OSPF daemon, this is the async socket\n* next, a connection is made to OSPF daemon through dest 2607/tcp port and having the port 4000/tcp as source port\n* the OSPF daemon receives the connection and also makes another connection to ospfclient which is listening connections to 4001/tcp port\n* now both sockets are up and running.\n\nThe function `ospfclient:do_connect/2` is responsible for implementing that logic.\n\nWhen calling: `ospfclient:connect/1` function, the caller receives back a Handle. That handle (which is a process id) should be used for further interactions with ospfclient.\n\nIf `callbacks` were registered when calling `ospfclient:connect/2` function, then the async process will call these callbacks for registered messages. In this context the caller will receive notifications for OSPF events like ISM, NSM, etc.\n\nBuild\n-----\n\n    $ rebar3 compile\n\nTest Environment\n----------------\n\nThere is no secret and all what we need is some FRR hosts in order to configure OSPF routes. My environment\nwas made using 3 virtual machines with Ubuntu 24 and FF installed from packages. Then I made OSPF configuration\nand connect to one of virtual hosts. That is all.\n\nTest\n----\n\nThis project does not support unit test yet. It's a challenge to implement tests because it depends on\nFRR ospf daemon.\n\n    $ rebar3 as test shell\n    Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:32:12] [ds:32:12:10] [async-threads:1] [jit:ns]\n\n    Eshell V14.2.5 (press Ctrl+G to abort, type help(). for help)\n    \n    1\u003e H = ospfclient_test:test().\n\n    2\u003e ospfclinet:sync_nsm(H).\n    \n    callback mt \"NSM_CHANGE\" data \u003c0.483.0\u003e payload {msg_nsm_change,\n                                                 {10,90,0,1},\n                                                 {10,90,0,2},\n                                                 {192,168,56,101},\n                                                 4}\n    callback mt \"NSM_CHANGE\" data \u003c0.483.0\u003e payload {msg_nsm_change,\n                                                 {10,90,0,1},\n                                                 {10,90,0,2},\n                                                 {192,168,56,101},\n                                                 6}\n    callback mt \"NSM_CHANGE\" data \u003c0.483.0\u003e payload {msg_nsm_change,\n                                                 {10,90,0,1},\n                                                 {10,90,0,2},\n                                                 {192,168,56,101},\n                                                 7}\n    callback mt \"NSM_CHANGE\" data \u003c0.483.0\u003e payload {msg_nsm_change,\n                                                 {10,90,0,1},\n                                                 {10,90,0,2},\n                                                 {192,168,56,101},\n                                                 9}\n\n\n\nReferences\n----------\n\n* [OSPF API Documentation](https://docs.frrouting.org/projects/dev-guide/en/latest/ospf-api.html)\n* [ospfclient in python](https://github.com/FRRouting/frr/blob/3d2c589766a7bd8694bcbdb8c6979178d1f2d811/ospfclient/ospfclient.py)\n* [ospfclient in C](https://github.com/FRRouting/frr/blob/3d2c589766a7bd8694bcbdb8c6979178d1f2d811/ospfclient/ospfclient.c)\n* [OSPF-API client in C](https://github.com/FRRouting/frr/blob/3d2c589766a7bd8694bcbdb8c6979178d1f2d811/ospfclient/ospf_apiclient.c)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaohf%2Fospfclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoaohf%2Fospfclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaohf%2Fospfclient/lists"}