-// for the luid-to-idx hashmap
-static unsigned luid_hash(const void *data)
-{
- return ((NET_LUID *)data)->Info.NetLuidIndex;
-}
-static int luid_equal(const void *a, const void *b)
-{
- return (((NET_LUID *)a)->Value == ((NET_LUID *)b)->Value);
-}
-
-static CattaIfIndex find_ifindex(CattaInterfaceMonitor *m, NET_LUID luid)
-{
- CattaIfIndex *pi = NULL;
- NET_LUID *key = NULL;
-
- if((pi = catta_hashmap_lookup(m->osdep.idxmap, &luid)) == NULL) {
- // allocate memory for the hashmap key and value
- key = catta_malloc(sizeof(luid));
- pi = catta_malloc(sizeof(CattaIfIndex));
- if(!key || !pi)
- goto fail;
-
- *key = luid;
-
- // find an index for this luid
- *pi = m->osdep.nidx;
- if(*pi < 0) // overflow
- goto fail;
-
- // register the index
- if(catta_hashmap_replace(m->osdep.idxmap, key, pi) < 0)
- goto fail;
- m->osdep.nidx++;
- }
-
- return *pi;
-
-fail:
- catta_free(key);
- catta_free(pi);
- return -1;
-}
-