linkd

Control plane daemon for unos
git clone git://git.finwo.net/app/linkd
Log | Files | Refs | README

ifaces.h (2695B)


      1 #ifndef __LINKD_CONFIG_IFACES_H__
      2 #define __LINKD_CONFIG_IFACES_H__
      3 
      4 #include <stdbool.h>
      5 #include <stdint.h>
      6 #include <stdio.h>
      7 
      8 #include "finwo/cnfparse.h"
      9 
     10 // Network interface configuration from /etc/network/interfaces
     11 // IPv6 is first-class: address may be v4 or v6, gateway may be v4 or v6.
     12 
     13 struct iface_addr {
     14   char              *address; // "192.168.1.1/24" or "2001:db8::1/64"
     15   char              *netmask; // v4 only, optional
     16   struct iface_addr *next;
     17 };
     18 
     19 struct linkd_iface {
     20   char               *name;    // e.g., "eth0", "swp1.100" -- cumulus style `iface <name>` preferred
     21   char               *method;  // "static", "dhcp", "loopback", "manual" -- optional, defaults to "static" when `iface <name>` used without `inet`
     22   char               *family;  // "inet", "inet6" -- optional, NULL when cumulus style
     23   struct iface_addr  *addrs;
     24   char               *gateway;
     25   char               *broadcast;
     26   int                 mtu;     // 0 = unset
     27   char               *hwaddress;
     28   char               *vlan_raw_device;
     29   int                 vlan_id; // -1 = unset, 1..4094
     30   char               *pre_up;
     31   char               *post_up;
     32   char               *pre_down;
     33   char               *post_down;
     34   char               *bridge_ports; // space-separated, e.g. "swp1 swp2"
     35   char               *bridge_stp; // "on"/"off"
     36   int                 bridge_vlan_aware; // -1 unset, 0 no, 1 yes
     37   // VRF. Two distinct roles, deliberately separate fields:
     38   //   vrf_table >= 0  -> THIS interface is a VRF device with that table id
     39   //                      (`vrf-table <id|auto>`)
     40   //   vrf_master      -> this interface is a MEMBER of the named VRF
     41   //                      (`vrf <name>`)
     42   // Both appear in every production Cumulus config we captured; a mgmt VRF is
     43   // how management traffic is kept out of the table BGP populates.
     44   int                 vrf_table;  // -1 unset, otherwise 1..2^31-1
     45   char               *vrf_master; // NULL unset
     46   int                 auto_flag; // 1 if listed in auto
     47   struct linkd_iface  *next;
     48 };
     49 
     50 // Shared classification. Previously duplicated in cli/linkd.c and ipc.c, which
     51 // let the two drift; keep exactly one definition.
     52 bool iface_is_bridge(const struct linkd_iface *ifc);
     53 bool iface_is_vrf(const struct linkd_iface *ifc);
     54 
     55 void ifaces_register(void);
     56 
     57 struct cnf_directive * cfg_parse_auto(FILE *fd, struct cnf_directive *dir, void *user);
     58 struct cnf_directive * cfg_parse_iface(FILE *fd, struct cnf_directive *dir, void *user);
     59 
     60 struct linkd_iface * ifaces_list(void);
     61 struct linkd_iface * ifaces_find(const char *name);
     62 void ifaces_free(void);
     63 void ifaces_set_auto(const char *name, int flag);
     64 
     65 #endif // __LINKD_CONFIG_IFACES_H__