diff options
| author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-09-17 10:28:27 -0300 |
|---|---|---|
| committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-11-24 07:55:07 -0300 |
| commit | 6655b43d512faffc75a72de6e3df02415b0af709 (patch) | |
| tree | 28fe3569703c81306f3498c1ceee3d8fa4e0d338 /bfdd/bfdd.c | |
| parent | 319d840c02d3645b9b9c87d137d9e4f0cb55aac1 (diff) | |
bfdd: support connecting to BFD data plane
Add option to connect to a data plane server instead of receiving
connections.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'bfdd/bfdd.c')
| -rw-r--r-- | bfdd/bfdd.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/bfdd/bfdd.c b/bfdd/bfdd.c index 5fda85e81c..b8a059708f 100644 --- a/bfdd/bfdd.c +++ b/bfdd/bfdd.c @@ -204,6 +204,7 @@ static void distributed_bfd_init(const char *arg) { char *sptr, *saux; + bool is_client = false; size_t slen; socklen_t salen; char addr[64]; @@ -235,11 +236,17 @@ distributed_bfd_init(const char *arg) memset(&sa, 0, sizeof(sa)); /* Fill the address information. */ - if (strcmp(type, "unix") == 0) { + if (strcmp(type, "unix") == 0 || strcmp(type, "unixc") == 0) { + if (strcmp(type, "unixc") == 0) + is_client = true; + salen = sizeof(sa.sun); sa.sun.sun_family = AF_UNIX; strlcpy(sa.sun.sun_path, addr, sizeof(sa.sun.sun_path)); - } else if (strcmp(type, "ipv4") == 0) { + } else if (strcmp(type, "ipv4") == 0 || strcmp(type, "ipv4c") == 0) { + if (strcmp(type, "ipv4c") == 0) + is_client = true; + salen = sizeof(sa.sin); sa.sin.sin_family = AF_INET; @@ -255,7 +262,10 @@ distributed_bfd_init(const char *arg) if (inet_pton(AF_INET, addr, &sa.sin.sin_addr) != 1) errx(1, "%s: inet_pton: invalid address %s", __func__, addr); - } else if (strcmp(type, "ipv6") == 0) { + } else if (strcmp(type, "ipv6") == 0 || strcmp(type, "ipv6c") == 0) { + if (strcmp(type, "ipv6c") == 0) + is_client = true; + salen = sizeof(sa.sin6); sa.sin6.sin6_family = AF_INET6; @@ -295,7 +305,7 @@ distributed_bfd_init(const char *arg) } /* Initialize BFD data plane listening socket. */ - bfd_dplane_init((struct sockaddr *)&sa, salen); + bfd_dplane_init((struct sockaddr *)&sa, salen, is_client); } static void bg_init(void) |
