Commit ec2ace4f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Generalise find_request, split.

parent f2778e5d
...@@ -37,33 +37,41 @@ struct timeval resend_time = {0, 0}; ...@@ -37,33 +37,41 @@ struct timeval resend_time = {0, 0};
struct resend *to_resend = NULL; struct resend *to_resend = NULL;
static int static int
request_match(struct resend *request, resend_match(struct resend *resend,
const unsigned char *prefix, unsigned char plen) int kind, const unsigned char *prefix, unsigned char plen)
{ {
return request->plen == plen && memcmp(request->prefix, prefix, 16) == 0; return (resend->kind == kind &&
resend->plen == plen && memcmp(resend->prefix, prefix, 16) == 0);
} }
struct resend * static struct resend *
find_request(const unsigned char *prefix, unsigned char plen, find_resend(int kind, const unsigned char *prefix, unsigned char plen,
struct resend **previous_return) struct resend **previous_return)
{ {
struct resend *request, *previous; struct resend *current, *previous;
previous = NULL; previous = NULL;
request = to_resend; current = to_resend;
while(request) { while(current) {
if(request_match(request, prefix, plen)) { if(resend_match(current, kind, prefix, plen)) {
if(previous_return) if(previous_return)
*previous_return = previous; *previous_return = previous;
return request; return current;
} }
previous = request; previous = current;
request = request->next; current = current->next;
} }
return NULL; return NULL;
} }
struct resend *
find_request(const unsigned char *prefix, unsigned char plen,
struct resend **previous_return)
{
return find_resend(RESEND_REQUEST, prefix, plen, previous_return);
}
int int
record_request(const unsigned char *prefix, unsigned char plen, record_request(const unsigned char *prefix, unsigned char plen,
unsigned short seqno, unsigned short router_hash, unsigned short seqno, unsigned short router_hash,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment