]>
git.proxmox.com Git - mirror_frr.git/blob - nhrpd/reqid.c
5 static unsigned int nhrp_reqid_key(void *data
)
7 struct nhrp_reqid
*r
= data
;
11 static int nhrp_reqid_cmp(const void *data
, const void *key
)
13 const struct nhrp_reqid
*a
= data
, *b
= key
;
14 return a
->request_id
== b
->request_id
;
17 uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool
*p
, struct nhrp_reqid
*r
, void (*cb
)(struct nhrp_reqid
*, void *))
20 p
->reqid_hash
= hash_create(nhrp_reqid_key
,
23 p
->next_request_id
= 1;
27 r
->request_id
= p
->next_request_id
;
28 if (++p
->next_request_id
== 0) p
->next_request_id
= 1;
30 hash_get(p
->reqid_hash
, r
, hash_alloc_intern
);
35 void nhrp_reqid_free(struct nhrp_reqid_pool
*p
, struct nhrp_reqid
*r
)
38 hash_release(p
->reqid_hash
, r
);
43 struct nhrp_reqid
*nhrp_reqid_lookup(struct nhrp_reqid_pool
*p
, uint32_t reqid
)
45 struct nhrp_reqid key
;
46 if (!p
->reqid_hash
) return 0;
47 key
.request_id
= reqid
;
48 return hash_lookup(p
->reqid_hash
, &key
);