state: add interface alias support

This commit is contained in:
Ariadne Conill 2020-07-20 07:45:39 -06:00
parent d4e1997486
commit 6fe4630f52
2 changed files with 17 additions and 0 deletions

View file

@ -46,3 +46,19 @@ lif_state_write(const struct lif_dict *state, FILE *f)
fprintf(f, "%s=%s\n", entry->key, (const char *) entry->data); fprintf(f, "%s=%s\n", entry->key, (const char *) entry->data);
} }
} }
struct lif_interface *
lif_state_lookup(struct lif_dict *state, struct lif_dict *if_collection, const char *ifname)
{
struct lif_dict_entry *entry = lif_dict_find(state, ifname);
if (entry == NULL)
return NULL;
struct lif_dict_entry *if_entry = lif_dict_find(if_collection, (const char *) entry->data);
if (if_entry == NULL)
return NULL;
return if_entry->data;
}

View file

@ -22,5 +22,6 @@
extern void lif_state_upsert(struct lif_dict *state, const char *ifname, struct lif_interface *iface); extern void lif_state_upsert(struct lif_dict *state, const char *ifname, struct lif_interface *iface);
extern void lif_state_delete(struct lif_dict *state, const char *ifname); extern void lif_state_delete(struct lif_dict *state, const char *ifname);
extern void lif_state_write(const struct lif_dict *state, FILE *f); extern void lif_state_write(const struct lif_dict *state, FILE *f);
extern struct lif_interface *lif_state_lookup(struct lif_dict *state, struct lif_dict *if_collection, const char *ifname);
#endif #endif