]>
git.proxmox.com Git - mirror_frr.git/blob - nhrpd/reqid.c
5 static unsigned int nhrp_reqid_key(const void *data
)
7 const struct nhrp_reqid
*r
= data
;
11 static bool nhrp_reqid_cmp(const void *data
, const void *key
)
13 const struct nhrp_reqid
*a
= data
, *b
= key
;
15 return a
->request_id
== b
->request_id
;
18 uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool
*p
, struct nhrp_reqid
*r
,
19 void (*cb
)(struct nhrp_reqid
*, void *))
22 p
->reqid_hash
= hash_create(nhrp_reqid_key
, nhrp_reqid_cmp
,
24 p
->next_request_id
= 1;
28 r
->request_id
= p
->next_request_id
;
29 if (++p
->next_request_id
== 0)
30 p
->next_request_id
= 1;
32 hash_get(p
->reqid_hash
, r
, hash_alloc_intern
);
37 void nhrp_reqid_free(struct nhrp_reqid_pool
*p
, struct nhrp_reqid
*r
)
40 hash_release(p
->reqid_hash
, r
);
45 struct nhrp_reqid
*nhrp_reqid_lookup(struct nhrp_reqid_pool
*p
, uint32_t reqid
)
47 struct nhrp_reqid key
;
50 key
.request_id
= reqid
;
51 return hash_lookup(p
->reqid_hash
, &key
);