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};
struct resend *to_resend = NULL;
static int
request_match(struct resend *request,
const unsigned char *prefix, unsigned char plen)
resend_match(struct resend *resend,
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 *
find_request(const unsigned char *prefix, unsigned char plen,
static struct resend *
find_resend(int kind, const unsigned char *prefix, unsigned char plen,
struct resend **previous_return)
{
struct resend *request, *previous;
struct resend *current, *previous;
previous = NULL;
request = to_resend;
while(request) {
if(request_match(request, prefix, plen)) {
current = to_resend;
while(current) {
if(resend_match(current, kind, prefix, plen)) {
if(previous_return)
*previous_return = previous;
return request;
return current;
}
previous = request;
request = request->next;
previous = current;
current = current->next;
}
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
record_request(const unsigned char *prefix, unsigned char plen,
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