Commit 25ddad56 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Rename struct request to resend.

parent 8a5109b3
...@@ -834,7 +834,7 @@ send_update(struct network *net, int urgent, ...@@ -834,7 +834,7 @@ send_update(struct network *net, int urgent,
const unsigned char *prefix, unsigned char plen) const unsigned char *prefix, unsigned char plen)
{ {
int i, selfonly; int i, selfonly;
struct request *request; struct resend *request;
if(prefix) { if(prefix) {
/* This is needed here, since really_send_update only handles the /* This is needed here, since really_send_update only handles the
......
...@@ -34,23 +34,23 @@ THE SOFTWARE. ...@@ -34,23 +34,23 @@ THE SOFTWARE.
#include "filter.h" #include "filter.h"
struct timeval resend_time = {0, 0}; struct timeval resend_time = {0, 0};
struct request *recorded_requests = NULL; struct resend *to_resend = NULL;
static int static int
request_match(struct request *request, request_match(struct resend *request,
const unsigned char *prefix, unsigned char plen) const unsigned char *prefix, unsigned char plen)
{ {
return request->plen == plen && memcmp(request->prefix, prefix, 16) == 0; return request->plen == plen && memcmp(request->prefix, prefix, 16) == 0;
} }
struct request * struct resend *
find_request(const unsigned char *prefix, unsigned char plen, find_request(const unsigned char *prefix, unsigned char plen,
struct request **previous_return) struct resend **previous_return)
{ {
struct request *request, *previous; struct resend *request, *previous;
previous = NULL; previous = NULL;
request = recorded_requests; request = to_resend;
while(request) { while(request) {
if(request_match(request, prefix, plen)) { if(request_match(request, prefix, plen)) {
if(previous_return) if(previous_return)
...@@ -69,7 +69,7 @@ record_request(const unsigned char *prefix, unsigned char plen, ...@@ -69,7 +69,7 @@ record_request(const unsigned char *prefix, unsigned char plen,
unsigned short seqno, unsigned short router_hash, unsigned short seqno, unsigned short router_hash,
struct network *network, int resend) struct network *network, int resend)
{ {
struct request *request; struct resend *request;
unsigned int ifindex = network ? network->ifindex : 0; unsigned int ifindex = network ? network->ifindex : 0;
if(input_filter(NULL, prefix, plen, NULL, ifindex) >= INFINITY || if(input_filter(NULL, prefix, plen, NULL, ifindex) >= INFINITY ||
...@@ -92,7 +92,7 @@ record_request(const unsigned char *prefix, unsigned char plen, ...@@ -92,7 +92,7 @@ record_request(const unsigned char *prefix, unsigned char plen,
if(request->network != network) if(request->network != network)
request->network = NULL; request->network = NULL;
} else { } else {
request = malloc(sizeof(struct request)); request = malloc(sizeof(struct resend));
if(request == NULL) if(request == NULL)
return -1; return -1;
memcpy(request->prefix, prefix, 16); memcpy(request->prefix, prefix, 16);
...@@ -102,8 +102,8 @@ record_request(const unsigned char *prefix, unsigned char plen, ...@@ -102,8 +102,8 @@ record_request(const unsigned char *prefix, unsigned char plen,
request->network = network; request->network = network;
request->time = now; request->time = now;
request->resend = resend; request->resend = resend;
request->next = recorded_requests; request->next = to_resend;
recorded_requests = request; to_resend = request;
} }
if(request->resend) { if(request->resend) {
...@@ -118,7 +118,7 @@ int ...@@ -118,7 +118,7 @@ int
unsatisfied_request(const unsigned char *prefix, unsigned char plen, unsatisfied_request(const unsigned char *prefix, unsigned char plen,
unsigned short seqno, unsigned short router_hash) unsigned short seqno, unsigned short router_hash)
{ {
struct request *request; struct resend *request;
request = find_request(prefix, plen, NULL); request = find_request(prefix, plen, NULL);
if(request == NULL) if(request == NULL)
...@@ -136,7 +136,7 @@ satisfy_request(const unsigned char *prefix, unsigned char plen, ...@@ -136,7 +136,7 @@ satisfy_request(const unsigned char *prefix, unsigned char plen,
unsigned short seqno, unsigned short router_hash, unsigned short seqno, unsigned short router_hash,
struct network *network) struct network *network)
{ {
struct request *request, *previous; struct resend *request, *previous;
request = find_request(prefix, plen, &previous); request = find_request(prefix, plen, &previous);
if(request == NULL) if(request == NULL)
...@@ -148,7 +148,7 @@ satisfy_request(const unsigned char *prefix, unsigned char plen, ...@@ -148,7 +148,7 @@ satisfy_request(const unsigned char *prefix, unsigned char plen,
if(request->router_hash != router_hash || if(request->router_hash != router_hash ||
seqno_compare(request->seqno, seqno) <= 0) { seqno_compare(request->seqno, seqno) <= 0) {
if(previous == NULL) if(previous == NULL)
recorded_requests = request->next; to_resend = request->next;
else else
previous->next = request->next; previous->next = request->next;
free(request); free(request);
...@@ -162,17 +162,17 @@ satisfy_request(const unsigned char *prefix, unsigned char plen, ...@@ -162,17 +162,17 @@ satisfy_request(const unsigned char *prefix, unsigned char plen,
void void
expire_requests() expire_requests()
{ {
struct request *request, *previous; struct resend *request, *previous;
int recompute = 0; int recompute = 0;
previous = NULL; previous = NULL;
request = recorded_requests; request = to_resend;
while(request) { while(request) {
if(timeval_minus_msec(&now, &request->time) >= REQUEST_TIMEOUT) { if(timeval_minus_msec(&now, &request->time) >= REQUEST_TIMEOUT) {
if(previous == NULL) { if(previous == NULL) {
recorded_requests = request->next; to_resend = request->next;
free(request); free(request);
request = recorded_requests; request = to_resend;
} else { } else {
previous->next = request->next; previous->next = request->next;
free(request); free(request);
...@@ -190,10 +190,10 @@ expire_requests() ...@@ -190,10 +190,10 @@ expire_requests()
void void
recompute_resend_time() recompute_resend_time()
{ {
struct request *request; struct resend *request;
struct timeval resend = {0, 0}; struct timeval resend = {0, 0};
request = recorded_requests; request = to_resend;
while(request) { while(request) {
if(request->resend) { if(request->resend) {
struct timeval timeout; struct timeval timeout;
...@@ -209,9 +209,9 @@ recompute_resend_time() ...@@ -209,9 +209,9 @@ recompute_resend_time()
void void
do_resend() do_resend()
{ {
struct request *request; struct resend *request;
request = recorded_requests; request = to_resend;
while(request) { while(request) {
if(request->resend) { if(request->resend) {
struct timeval timeout; struct timeval timeout;
......
...@@ -22,7 +22,7 @@ THE SOFTWARE. ...@@ -22,7 +22,7 @@ THE SOFTWARE.
#define REQUEST_TIMEOUT 125000 #define REQUEST_TIMEOUT 125000
struct request { struct resend {
unsigned char prefix[16]; unsigned char prefix[16];
unsigned char plen; unsigned char plen;
unsigned short seqno; unsigned short seqno;
...@@ -30,13 +30,13 @@ struct request { ...@@ -30,13 +30,13 @@ struct request {
struct network *network; struct network *network;
struct timeval time; struct timeval time;
int resend; int resend;
struct request *next; struct resend *next;
}; };
extern struct timeval resend_time; extern struct timeval resend_time;
struct request *find_request(const unsigned char *prefix, unsigned char plen, struct resend *find_request(const unsigned char *prefix, unsigned char plen,
struct request **previous_return); struct resend **previous_return);
int record_request(const unsigned char *prefix, unsigned char plen, int record_request(const unsigned char *prefix, unsigned char plen,
unsigned short seqno, unsigned short router_hash, unsigned short seqno, unsigned short router_hash,
struct network *net, int resend); struct network *net, int resend);
......
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