Skip to content

Commit

Permalink
WIP: bird import proto
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgyKirichenko committed Jun 7, 2024
1 parent abc6233 commit 1a525e7
Show file tree
Hide file tree
Showing 13 changed files with 1,290 additions and 23 deletions.
1 change: 1 addition & 0 deletions controlplane/acl/bitset.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstdint>
#include <string_view>
#include <tuple>
#include <vector>
Expand Down
3 changes: 0 additions & 3 deletions controlplane/configconverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class config_converter_t
config_converter_t(cControlPlane* controlplane,
const controlplane::base_t& baseNext,
const common::idp::limits::response& limits) :
controlplane(controlplane),
baseNext(baseNext),
limits(limits)
{
Expand Down Expand Up @@ -64,8 +63,6 @@ class config_converter_t
void acl_rules_balancer_icmp_forward(controlplane::base::acl_t& acl, const std::string& nextModule) const;

private:
cControlPlane* controlplane;

controlplane::base_t baseNext;
common::idp::updateGlobalBase::request globalbase;
common::idp::limits::response limits;
Expand Down
174 changes: 174 additions & 0 deletions controlplane/libbird.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
#ifndef LIBBIRD_H
#define LIBBIRD_H

#include <stdint.h>

#define NET_IP4 1
#define NET_IP6 2
#define NET_VPN4 3
#define NET_VPN6 4
#define NET_ROA4 5
#define NET_ROA6 6
#define NET_FLOW4 7
#define NET_FLOW6 8
#define NET_IP6_SADR 9
#define NET_MPLS 10
#define NET_MAX 11

#define NB_IP4 (1 << NET_IP4)
#define NB_IP6 (1 << NET_IP6)
#define NB_VPN4 (1 << NET_VPN4)
#define NB_VPN6 (1 << NET_VPN6)
#define NB_ROA4 (1 << NET_ROA4)
#define NB_ROA6 (1 << NET_ROA6)
#define NB_FLOW4 (1 << NET_FLOW4)
#define NB_FLOW6 (1 << NET_FLOW6)
#define NB_IP6_SADR (1 << NET_IP6_SADR)
#define NB_MPLS (1 << NET_MPLS)

#define NB_IP (NB_IP4 | NB_IP6)
#define NB_VPN (NB_VPN4 | NB_VPN6)
#define NB_ROA (NB_ROA4 | NB_ROA6)
#define NB_FLOW (NB_FLOW4 | NB_FLOW6)
#define NB_DEST (NB_IP | NB_IP6_SADR | NB_VPN | NB_MPLS)
#define NB_ANY 0xffffffff

#define BA_ORIGIN 0x01 /* RFC 4271 */ /* WM */
#define BA_AS_PATH 0x02 /* WM */
#define BA_NEXT_HOP 0x03 /* WM */
#define BA_MULTI_EXIT_DISC 0x04 /* ON */
#define BA_LOCAL_PREF 0x05 /* WD */
#define BA_ATOMIC_AGGR 0x06 /* WD */
#define BA_AGGREGATOR 0x07 /* OT */
#define BA_COMMUNITY 0x08 /* RFC 1997 */ /* OT */
#define BA_ORIGINATOR_ID 0x09 /* RFC 4456 */ /* ON */
#define BA_CLUSTER_LIST 0x0a /* RFC 4456 */ /* ON */
#define BA_MP_REACH_NLRI 0x0e /* RFC 4760 */
#define BA_MP_UNREACH_NLRI 0x0f /* RFC 4760 */
#define BA_EXT_COMMUNITY 0x10 /* RFC 4360 */
#define BA_AS4_PATH 0x11 /* RFC 6793 */
#define BA_AS4_AGGREGATOR 0x12 /* RFC 6793 */
#define BA_AIGP 0x1a /* RFC 7311 */
#define BA_LARGE_COMMUNITY 0x20 /* RFC 8092 */
#define BA_ONLY_TO_CUSTOMER 0x23 /* RFC 9234 */

/* Bird's private internal BGP attributes */
#define BA_MPLS_LABEL_STACK 0xfe /* MPLS label stack transfer attribute */

#define EA_ID(ea) ((ea) & 0xff)
#define EA_PROTO(ea) ((ea) >> 8)

typedef uint32_t ip4_addr;

typedef struct ip6_addr {
uint32_t addr[4];
} ip6_addr;

typedef ip6_addr ip_addr;

typedef struct net_addr {
uint8_t type;
uint8_t pxlen;
uint16_t length;
uint8_t data[20];
uint64_t align[0];
} net_addr;

typedef struct net_addr_ip4 {
uint8_t type;
uint8_t pxlen;
uint16_t length;
ip4_addr prefix;
} net_addr_ip4;

typedef struct net_addr_ip6 {
uint8_t type;
uint8_t pxlen;
uint16_t length;
ip6_addr prefix;
} net_addr_ip6;

typedef struct net_addr_vpn4 {
uint8_t type;
uint8_t pxlen;
uint16_t length;
ip4_addr prefix;
uint64_t rd;
} net_addr_vpn4;

typedef struct net_addr_vpn6 {
uint8_t type;
uint8_t pxlen;
uint16_t length;
ip6_addr prefix;
uint32_t padding;
uint64_t rd;
} net_addr_vpn6;

typedef struct net_addr_roa4 {
uint8_t type;
uint8_t pxlen;
uint16_t length;
ip4_addr prefix;
uint32_t max_pxlen;
uint32_t asn;
} net_addr_roa4;

typedef struct net_addr_roa6 {
uint8_t type;
uint8_t pxlen;
uint16_t length;
ip6_addr prefix;
uint32_t max_pxlen;
uint32_t asn;
} net_addr_roa6;

typedef struct net_addr_flow4 {
uint8_t type;
uint8_t pxlen;
uint16_t length;
ip4_addr prefix;
uint8_t data[0];
} net_addr_flow4;

typedef struct net_addr_flow6 {
uint8_t type;
uint8_t pxlen;
uint16_t length;
ip6_addr prefix;
uint8_t data[0];
} net_addr_flow6;

typedef struct net_addr_mpls {
uint8_t type;
uint8_t pxlen;
uint16_t length;
uint32_t label;
} net_addr_mpls;

typedef struct net_addr_ip6_sadr {
uint8_t type;
uint8_t dst_pxlen;
uint16_t length;
ip6_addr dst_prefix;
int32_t src_pxlen; /* s32 to avoid padding */
ip6_addr src_prefix;
} net_addr_ip6_sadr;

typedef union net_addr_union {
net_addr n;
net_addr_ip4 ip4;
net_addr_ip6 ip6;
net_addr_vpn4 vpn4;
net_addr_vpn6 vpn6;
net_addr_roa4 roa4;
net_addr_roa6 roa6;
net_addr_flow4 flow4;
net_addr_flow6 flow6;
net_addr_ip6_sadr ip6_sadr;
net_addr_mpls mpls;
} net_addr_union;



#endif
4 changes: 2 additions & 2 deletions controlplane/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <signal.h>
#include <systemd/sd-daemon.h>
//#include <systemd/sd-daemon.h>

#include <iostream>

Expand Down Expand Up @@ -58,7 +58,7 @@ int main(int argc,
return 3;
}

sd_notify(0, "READY=1");
// sd_notify(0, "READY=1");

application.start();
application.join();
Expand Down
2 changes: 1 addition & 1 deletion controlplane/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies = []
dependencies += libjson.get_variable('nlohmann_json_dep')
dependencies += dependency('libsystemd')
#dependencies += dependency('libsystemd')
dependencies += dependency('threads')
dependencies += libyanet_fwparser_dep
dependencies += libyanet_protobuf_dep
Expand Down
Loading

0 comments on commit 1a525e7

Please sign in to comment.