diff options
author | Jordan Augé <jordan.auge+fdio@cisco.com> | 2020-01-13 15:12:55 +0100 |
---|---|---|
committer | Jordan Augé <jordan.auge+fdio@cisco.com> | 2020-01-13 15:12:55 +0100 |
commit | 63312d00f31de987101a3a3edc4939730d269fef (patch) | |
tree | 8ebd2b0bddb8d92e2173d1024fe9d14da94a7b90 /ctrl | |
parent | 3f4acd6752d19ebe29fd0b04101fbe5b5199c119 (diff) |
[HICN-473] Add getter functions for face manager rule configuration
Change-Id: I8b78694462d2fc5dfc085c9e198a06ca4b93a199
Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl')
-rw-r--r-- | ctrl/facemgr/includes/hicn/facemgr/cfg.h | 14 | ||||
-rw-r--r-- | ctrl/facemgr/src/cfg.c | 121 |
2 files changed, 135 insertions, 0 deletions
diff --git a/ctrl/facemgr/includes/hicn/facemgr/cfg.h b/ctrl/facemgr/includes/hicn/facemgr/cfg.h index 9d227f30a..797104836 100644 --- a/ctrl/facemgr/includes/hicn/facemgr/cfg.h +++ b/ctrl/facemgr/includes/hicn/facemgr/cfg.h @@ -139,6 +139,20 @@ int facemgr_cfg_get_overlay_remote_port(const facemgr_cfg_t * cfg, const netdevice_t * netdevice, netdevice_type_t netdevice_type, int family, u16 * port); +int facemgr_cfg_rule_get_face_type(const facemgr_cfg_rule_t * cfg_rule, facemgr_face_type_t * face_type); +int facemgr_cfg_rule_get_discovery(const facemgr_cfg_rule_t * cfg_rule, bool * status); +int facemgr_cfg_rule_get_ignore(const facemgr_cfg_rule_t * cfg_rule, bool * status); +int facemgr_cfg_rule_get_ipv4(const facemgr_cfg_rule_t * cfg_rule, bool * status); +int facemgr_cfg_rule_get_ipv6(const facemgr_cfg_rule_t * cfg_rule, bool * status); +int facemgr_cfg_rule_get_overlay_local_addr(const facemgr_cfg_rule_t * rule, int family, + ip_address_t * addr); +int facemgr_cfg_rule_get_overlay_local_port(const facemgr_cfg_rule_t * rule, int family, + uint16_t * port); +int facemgr_cfg_rule_get_overlay_remote_addr(const facemgr_cfg_rule_t * rule, int family, + ip_address_t * addr); +int facemgr_cfg_rule_get_overlay_remote_port(const facemgr_cfg_rule_t * rule, int family, + uint16_t * port); + int facemgr_cfg_add_static_facelet(facemgr_cfg_t * cfg, facelet_t * facelet); int facemgr_cfg_remove_static_facelet(facemgr_cfg_t * cfg, facelet_t * facelet, facelet_t ** removed_facelet); diff --git a/ctrl/facemgr/src/cfg.c b/ctrl/facemgr/src/cfg.c index e324d04c3..9712466a5 100644 --- a/ctrl/facemgr/src/cfg.c +++ b/ctrl/facemgr/src/cfg.c @@ -1076,6 +1076,127 @@ facemgr_cfg_get_overlay_remote_port(const facemgr_cfg_t * cfg, return 0; } +int facemgr_cfg_rule_get_face_type(const facemgr_cfg_rule_t * rule, + facemgr_face_type_t * face_type) +{ + if (!rule->override.is_face_type) + return -1; + *face_type = rule->override.face_type; + return 0; +} + +int facemgr_cfg_rule_get_discovery(const facemgr_cfg_rule_t * rule, bool * discovery) +{ + if (!rule->override.is_discovery) + return -1; + *discovery = rule->override.discovery; + return 0; +} + +int facemgr_cfg_rule_get_ignore(const facemgr_cfg_rule_t * rule, bool * ignore) +{ + if (!rule->override.is_ignore) + return -1; + *ignore = rule->override.ignore; + return 0; +} + +int facemgr_cfg_rule_get_ipv4(const facemgr_cfg_rule_t * rule, bool * ipv4) +{ + if (!rule->override.is_ipv4) + return -1; + *ipv4 = rule->override.ipv4; + return 0; +} + +int facemgr_cfg_rule_get_ipv6(const facemgr_cfg_rule_t * rule, bool * ipv6) +{ + if (!rule->override.is_ipv6) + return -1; + *ipv6 = rule->override.ipv6; + return 0; +} + +int facemgr_cfg_rule_get_overlay_local_addr(const facemgr_cfg_rule_t * rule, int family, + ip_address_t * addr) +{ + facemgr_cfg_overlay_t * overlay = NULL; + switch(family) { + case AF_INET: + overlay = rule->override.overlays.v4; + break; + case AF_INET6: + overlay = rule->override.overlays.v6; + break; + default: + return -1; + } + if (!overlay->is_local_addr) + return -1; + *addr = overlay->local_addr; + return 0; +} + +int facemgr_cfg_rule_get_overlay_local_port(const facemgr_cfg_rule_t * rule, int family, + uint16_t * port) +{ + facemgr_cfg_overlay_t * overlay = NULL; + switch(family) { + case AF_INET: + overlay = rule->override.overlays.v4; + break; + case AF_INET6: + overlay = rule->override.overlays.v6; + break; + default: + return -1; + } + if (!overlay->is_local_port) + return -1; + *port = overlay->local_port; + return 0; +} + +int facemgr_cfg_rule_get_overlay_remote_addr(const facemgr_cfg_rule_t * rule, int family, + ip_address_t * addr) +{ + facemgr_cfg_overlay_t * overlay = NULL; + switch(family) { + case AF_INET: + overlay = rule->override.overlays.v4; + break; + case AF_INET6: + overlay = rule->override.overlays.v6; + break; + default: + return -1; + } + if (!overlay->is_remote_addr) + return -1; + *addr = overlay->remote_addr; + return 0; +} + +int facemgr_cfg_rule_get_overlay_remote_port(const facemgr_cfg_rule_t * rule, int family, + uint16_t * port) +{ + facemgr_cfg_overlay_t * overlay = NULL; + switch(family) { + case AF_INET: + overlay = rule->override.overlays.v4; + break; + case AF_INET6: + overlay = rule->override.overlays.v6; + break; + default: + return -1; + } + if (!overlay->is_remote_port) + return -1; + *port = overlay->remote_port; + return 0; +} + int facemgr_cfg_add_static_facelet(facemgr_cfg_t * cfg, facelet_t * facelet) { |