/* See the DRL-LICENSE file for this file's software license. */ #ifndef _DRL_CONFIG_ #define _DRL_CONFIG_ struct drl_instance; /** Enumeration of identity types. */ enum ident_types { /** Type used by identities that will limit all slivers on the machine. */ IDENT_MACHINE = 1, /** Type used by identities that will limit only a subset of slivers. */ IDENT_SET = 2 }; /** Enumeration of identity member types. */ enum member_types { /** The member is an identifier (xid) of a single sliver. */ MEMBER_XID = 1, /** The member is an identifier (guid) of another sliver-set identity. */ MEMBER_GUID = 2 }; /** * Linked list node containing address information for one of the identity's * peers. */ typedef struct ident_peer { /** The peer's IP address. */ in_addr_t ip; /** Pointer to the next peer in the list or NULL if this is the last. */ struct ident_peer *next; } ident_peer; /** * Linked list node containing hierarchy information. For whole-machine * identities, this is unnecessary. For sliver-set identities, this specifies * which slivers and other sliver-sets belong in the set. */ typedef struct ident_member { /** The numerical xid or guid of the member. */ int value; /** Specifies whether the value is an xid or guid. */ enum member_types type; /** Pointer to the next member in the list or NULL if this is the last. */ struct ident_member *next; } ident_member; /** * Linked list node containing identity information. */ typedef struct ident_config { /** The guid of this identity. */ int id; /** The global DRL limit for this identity. */ int limit; /** The communication fabric (COMM_MESH or COMM_GOSSIP) for this identity.*/ enum commfabrics commfabric; /** The gossip branch factor (when commfabric is COMM_GOSSIP). */ int branch; /** The flow accounting mechanism to be used by this identity. */ enum accountings accounting; /** The fixed (1-second) ewma weight value for this identity. */ double fixed_ewma_weight; /** The number of estimate intervals to wait between calls to estimate, * allocate and enforce. */ int intervals; /** The type of this identity. */ enum ident_types type; /** List of the identity's peers. */ ident_peer *peers; /** The number of peers. */ int peer_count; /** List of the identity's members (type IDENT_SET only). */ ident_member *members; /** Pointer to the next ident in the list or NULL if this is the last. */ struct ident_config *next; } ident_config; /** * Structure used to pass two lists after parsing is complete. */ typedef struct parsed_configs { /** A list of IDENT_MACHINE type identities. */ ident_config *machines; /** The number of machine identities. */ int machine_count; /** A list of IDENT_SET type identities. */ ident_config *sets; /** The number of set identities. */ int set_count; /** Pointer to the tail of the machines list. */ ident_config *last_machine; /** Pointer to the tail of the sets list. */ ident_config *last_set; } parsed_configs; /** * Frees the specified ident and all of the memory associated with it and its * fields. * * @param ident The ident to free. */ void free_ident(ident_config *ident); /** * Frees the specified list of identities and all of the memory associated * with them. * * @param list The ident_config list to free. */ void free_ident_list(ident_config *list); /** * Uses libxml2 to parse a DRL configuration XML file and converts the * information into a linked list of identities. * * @param configfile The path to the XML configuration file. * @param configs A parsed_configs structure to be filled in with linked list * of machine and set configs. * * @returns zero on success, non-zero on error. */ int parse_drl_config(const char *configfile, parsed_configs *configs); /** * Reads /proc/virtual to get a list of viable xids. It creates an array of * leaf_t structures and a map that maps xid to the leaf_t in the array with * the xid. * * @param instance The drl_instance_t to be filled in. This function sets * the instance's leaf_map, leaves, and leaf_count fields. * * @returns zero on success, non-zero on error. (Possibly ENOMEM if memory * allocation fails, or 1 if the cause of the error is unclear. */ int get_eligible_leaves(struct drl_instance *instance); #endif /* _DRL_CONFIG_ */