LCOV - code coverage report
Current view: top level - network - networkd-util.h (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 5 5 100.0 %
Date: 2019-08-22 15:41:25 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : #pragma once
       3             : 
       4             : #include "conf-parser.h"
       5             : #include "hash-funcs.h"
       6             : #include "macro.h"
       7             : 
       8             : typedef enum AddressFamily {
       9             :         /* This is a bitmask, though it usually doesn't feel that way! */
      10             :         ADDRESS_FAMILY_NO             = 0,
      11             :         ADDRESS_FAMILY_IPV4           = 1 << 0,
      12             :         ADDRESS_FAMILY_IPV6           = 1 << 1,
      13             :         ADDRESS_FAMILY_YES            = ADDRESS_FAMILY_IPV4 | ADDRESS_FAMILY_IPV6,
      14             :         ADDRESS_FAMILY_FALLBACK_IPV4  = 1 << 2,
      15             :         ADDRESS_FAMILY_FALLBACK       = ADDRESS_FAMILY_FALLBACK_IPV4 | ADDRESS_FAMILY_IPV6,
      16             :         _ADDRESS_FAMILY_MAX,
      17             :         _ADDRESS_FAMILY_INVALID = -1,
      18             : } AddressFamily;
      19             : 
      20             : typedef struct NetworkConfigSection {
      21             :         unsigned line;
      22             :         bool invalid;
      23             :         char filename[];
      24             : } NetworkConfigSection;
      25             : 
      26             : CONFIG_PARSER_PROTOTYPE(config_parse_link_local_address_family);
      27             : CONFIG_PARSER_PROTOTYPE(config_parse_address_family_with_kernel);
      28             : 
      29             : const char *address_family_to_string(AddressFamily b) _const_;
      30             : AddressFamily address_family_from_string(const char *s) _pure_;
      31             : 
      32             : const char *link_local_address_family_to_string(AddressFamily b) _const_;
      33             : AddressFamily link_local_address_family_from_string(const char *s) _pure_;
      34             : 
      35             : const char *routing_policy_rule_address_family_to_string(AddressFamily b) _const_;
      36             : AddressFamily routing_policy_rule_address_family_from_string(const char *s) _pure_;
      37             : 
      38             : int kernel_route_expiration_supported(void);
      39             : 
      40             : int network_config_section_new(const char *filename, unsigned line, NetworkConfigSection **s);
      41             : void network_config_section_free(NetworkConfigSection *network);
      42          25 : DEFINE_TRIVIAL_CLEANUP_FUNC(NetworkConfigSection*, network_config_section_free);
      43             : extern const struct hash_ops network_config_hash_ops;
      44             : 
      45          25 : static inline bool section_is_invalid(NetworkConfigSection *section) {
      46             :         /* If this returns false, then it does _not_ mean the section is valid. */
      47             : 
      48          25 :         if (!section)
      49           2 :                 return false;
      50             : 
      51          23 :         return section->invalid;
      52             : }
      53             : 
      54             : #define DEFINE_NETWORK_SECTION_FUNCTIONS(type, free_func)               \
      55             :         static inline void free_func##_or_set_invalid(type *p) {        \
      56             :                 assert(p);                                              \
      57             :                                                                         \
      58             :                 if (p->section)                                         \
      59             :                         p->section->invalid = true;                     \
      60             :                 else                                                    \
      61             :                         free_func(p);                                   \
      62             :         }                                                               \
      63             :         DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func);                  \
      64             :         DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func##_or_set_invalid);

Generated by: LCOV version 1.14