mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 13:53:31 +01:00
Folded cell.? into src/or
Removed more obsolete files svn:r61
This commit is contained in:
parent
926081ad69
commit
61d10b309f
@ -3,12 +3,9 @@ noinst_LIBRARIES = libor.a
|
||||
|
||||
#CFLAGS = -Wall -Wpointer-arith -O2
|
||||
|
||||
libor_a_SOURCES = cell.c config.c key.c log.c opcell.c \
|
||||
routent.c scheduler.c utils.c
|
||||
libor_a_SOURCES = config.c key.c log.c utils.c
|
||||
|
||||
# ss.h is not used anywhere, distributing it just because
|
||||
|
||||
noinst_HEADERS = cell.h config.h key.h log.h opcell.h \
|
||||
policies.h routent.h scheduler.h utils.h \
|
||||
noinst_HEADERS = config.h key.h log.h \
|
||||
policies.h utils.h \
|
||||
ss.h version.h
|
||||
|
||||
|
@ -1,355 +0,0 @@
|
||||
/**
|
||||
* cell.c
|
||||
* Cell manipulation.
|
||||
*
|
||||
* Matej Pfajfar <mp292@cam.ac.uk>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changes :
|
||||
* $Log$
|
||||
* Revision 1.1 2002/06/26 22:45:50 arma
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.16 2002/06/14 20:41:19 mp292
|
||||
* Parameter checking error - thanks Roger.
|
||||
*
|
||||
* Revision 1.15 2002/04/02 14:27:11 badbytes
|
||||
* Final finishes.
|
||||
*
|
||||
* Revision 1.14 2002/04/02 10:19:37 badbytes
|
||||
* Stricter parameter checking.
|
||||
*
|
||||
* Revision 1.13 2002/03/12 23:30:19 mp292
|
||||
* Removed some memory overruns.
|
||||
*
|
||||
* Revision 1.12 2002/03/03 00:06:45 mp292
|
||||
* Modifications to support re-transmission.
|
||||
*
|
||||
* Revision 1.11 2002/02/03 22:41:45 mp292
|
||||
* Changes to cell size.
|
||||
*
|
||||
* Revision 1.10 2002/01/21 20:57:19 mp292
|
||||
* Reviewed according to Secure-Programs-HOWTO.
|
||||
*
|
||||
* Revision 1.9 2002/01/17 15:00:43 mp292
|
||||
* Fixed a bug which caused malloc() generate a seg fault.
|
||||
*
|
||||
* Revision 1.8 2002/01/16 23:01:54 mp292
|
||||
* First phase of system testing completed (main functionality).
|
||||
*
|
||||
* Revision 1.7 2002/01/14 13:05:37 badbytes
|
||||
* System testing in progress.
|
||||
*
|
||||
* Revision 1.6 2002/01/10 13:15:54 badbytes
|
||||
* Fixed ACI size from 32bits to 16bits.
|
||||
*
|
||||
* Revision 1.5 2002/01/07 13:06:06 badbytes
|
||||
* cell.ACI is now cell.aci
|
||||
*
|
||||
* Revision 1.4 2002/01/07 09:26:00 badbytes
|
||||
* Added pack_create() and pack_data().
|
||||
*
|
||||
* Revision 1.3 2002/01/07 07:48:34 badbytes
|
||||
* fixed new_create_cell()
|
||||
*
|
||||
* Revision 1.2 2002/01/04 12:11:54 badbytes
|
||||
* Syntax errors fixed.
|
||||
*
|
||||
* Revision 1.1 2002/01/04 12:08:34 badbytes
|
||||
* Added functions for cell creation.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include "cell.h"
|
||||
#include "log.h"
|
||||
|
||||
cell_t *new_padding_cell()
|
||||
{
|
||||
cell_t *c = NULL;
|
||||
int retval;
|
||||
|
||||
c = malloc(sizeof(cell_t));
|
||||
if (!c) /* malloc() error */
|
||||
return NULL;
|
||||
|
||||
retval = RAND_pseudo_bytes((unsigned char *)c,sizeof(cell_t));
|
||||
if (retval == -1) /* RAND_pseudo_bytes() error */
|
||||
{
|
||||
free((void *)c);
|
||||
return NULL;
|
||||
} /* RAND_pseudo_bytes() error */
|
||||
|
||||
c->command = CELL_PADDING;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
cell_t *new_destroy_cell(uint16_t aci)
|
||||
{
|
||||
cell_t *c = NULL;
|
||||
int retval;
|
||||
|
||||
if (aci) /* valid ACI */
|
||||
{
|
||||
c = (cell_t *)malloc(sizeof(cell_t));
|
||||
if (!c) /* malloc error */
|
||||
return NULL;
|
||||
|
||||
retval = RAND_pseudo_bytes((unsigned char *)c+3,sizeof(cell_t)-3);
|
||||
if (retval == -1) /* RAND_pseudo_bytes() error */
|
||||
{
|
||||
free((void *)c);
|
||||
return NULL;
|
||||
} /* RAND_pseudo_bytes() error */
|
||||
|
||||
c->aci = aci;
|
||||
c->command = CELL_DESTROY;
|
||||
|
||||
return c;
|
||||
} /* valid ACI */
|
||||
else /* invalid ACI */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cell_t *new_ack_cell(uint16_t aci)
|
||||
{
|
||||
cell_t *c = NULL;
|
||||
int retval;
|
||||
|
||||
if (aci) /* valid ACI */
|
||||
{
|
||||
c = (cell_t *)malloc(sizeof(cell_t));
|
||||
if (!c) /* malloc error */
|
||||
return NULL;
|
||||
|
||||
retval = RAND_pseudo_bytes((unsigned char *)c+3,sizeof(cell_t)-3);
|
||||
if (retval == -1) /* RAND_pseudo_bytes() error */
|
||||
{
|
||||
free((void *)c);
|
||||
return NULL;
|
||||
} /* RAND_pseudo_bytes() error */
|
||||
|
||||
c->aci = aci;
|
||||
c->command = CELL_ACK;
|
||||
|
||||
return c;
|
||||
} /* valid ACI */
|
||||
else /* invalid ACI */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cell_t *new_nack_cell(uint16_t aci)
|
||||
{
|
||||
cell_t *c = NULL;
|
||||
int retval;
|
||||
|
||||
if (aci) /* valid ACI */
|
||||
{
|
||||
c = (cell_t *)malloc(sizeof(cell_t));
|
||||
if (!c) /* malloc error */
|
||||
return NULL;
|
||||
|
||||
retval = RAND_pseudo_bytes((unsigned char *)c+3,sizeof(cell_t)-3);
|
||||
if (retval == -1) /* RAND_pseudo_bytes() error */
|
||||
{
|
||||
free((void *)c);
|
||||
return NULL;
|
||||
} /* RAND_pseudo_bytes() error */
|
||||
|
||||
c->aci = aci;
|
||||
c->command = CELL_NACK;
|
||||
|
||||
return c;
|
||||
} /* valid ACI */
|
||||
else /* invalid ACI */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cell_t *new_create_cell(uint16_t aci, unsigned char length, unsigned char *buf)
|
||||
{
|
||||
cell_t *c = NULL;
|
||||
int retval;
|
||||
|
||||
if ((aci) && (buf) && (length <= CELL_PAYLOAD_SIZE)) /* valid parameters */
|
||||
{
|
||||
c = (cell_t *)malloc(sizeof(cell_t));
|
||||
if (!c) /* malloc() error */
|
||||
return NULL;
|
||||
|
||||
c->command = CELL_CREATE;
|
||||
c->aci = aci;
|
||||
c->length = length;
|
||||
c->seq = 0;
|
||||
|
||||
memcpy((void *)c->payload, (void *)buf, length);
|
||||
retval = RAND_pseudo_bytes((unsigned char *)(c->payload+length),CELL_PAYLOAD_SIZE-length);
|
||||
if (retval == -1) /* RAND_pseudo_bytes() error */
|
||||
{
|
||||
free((void *)c);
|
||||
return NULL;
|
||||
} /* RAND_pseudo_bytes() error */
|
||||
|
||||
return c;
|
||||
} /* valid parameters */
|
||||
else /* invalid parameters */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
cell_t *new_data_cell(uint16_t aci, unsigned char length, unsigned char *buf)
|
||||
{
|
||||
cell_t *c = NULL;
|
||||
int retval;
|
||||
|
||||
if ((aci) && (buf) && (length <= CELL_PAYLOAD_SIZE)) /* valid parameters */
|
||||
{
|
||||
c = malloc(sizeof(cell_t));
|
||||
if (!c) /* malloc() error */
|
||||
return NULL;
|
||||
|
||||
c->command = CELL_DATA;
|
||||
c->aci = aci;
|
||||
c->length = length;
|
||||
c->seq = 0;
|
||||
|
||||
memcpy((void *)c->payload, (void *)buf, length);
|
||||
retval = RAND_pseudo_bytes((unsigned char *)(c->payload+length),CELL_PAYLOAD_SIZE-length);
|
||||
if (retval == -1) /* RAND_pseudo_bytes() error */
|
||||
{
|
||||
free((void *)c);
|
||||
return NULL;
|
||||
} /* RAND_pseudo_bytes() error */
|
||||
|
||||
return c;
|
||||
} /* valid parameters */
|
||||
else /* invalid parameters */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int pack_create(uint16_t aci, unsigned char *onion, uint32_t onionlen, unsigned char **cellbuf, unsigned int *cellbuflen)
|
||||
{
|
||||
cell_t *c;
|
||||
unsigned char *buf;
|
||||
unsigned int buflen;
|
||||
unsigned int cells;
|
||||
unsigned int dataleft;
|
||||
unsigned int i;
|
||||
|
||||
if ((aci) && (onion) && (cellbuf) && (cellbuflen) && (onionlen)) /* valid parameters */
|
||||
{
|
||||
/* copy the onion into a buffer, prepend with onion length */
|
||||
buflen = onionlen+4;
|
||||
buf = (unsigned char *)malloc(buflen);
|
||||
if (!buf) /* malloc() error */
|
||||
return -1;
|
||||
|
||||
log(LOG_DEBUG,"pack_create() : Setting onion length to %u.",onionlen);
|
||||
onionlen=htonl(onionlen);
|
||||
memcpy((void *)buf,(void *)&onionlen,4);
|
||||
onionlen=ntohl(onionlen);
|
||||
memcpy((void *)(buf+4),(void *)onion,onionlen);
|
||||
|
||||
/* calculate number of cells required */
|
||||
if (buflen%CELL_PAYLOAD_SIZE == 0)
|
||||
cells = buflen/CELL_PAYLOAD_SIZE;
|
||||
else
|
||||
cells = buflen/CELL_PAYLOAD_SIZE+1;
|
||||
|
||||
/* allocate memory for the cells */
|
||||
*cellbuflen = cells * sizeof(cell_t);
|
||||
*cellbuf = malloc(*cellbuflen);
|
||||
if (!*cellbuf) /* malloc() error */
|
||||
return -1;
|
||||
|
||||
log(LOG_DEBUG,"pack_create() : Allocated memory for %u cells.",cells);
|
||||
|
||||
/* create cells one by one */
|
||||
dataleft = buflen;
|
||||
for(i=0; i<cells; i++)
|
||||
{
|
||||
log(LOG_DEBUG,"pack_create() : Packing %u bytes of data.",dataleft);
|
||||
if (dataleft >= CELL_PAYLOAD_SIZE)
|
||||
{
|
||||
c = new_create_cell(aci,CELL_PAYLOAD_SIZE,buf+i*CELL_PAYLOAD_SIZE);
|
||||
dataleft -= CELL_PAYLOAD_SIZE;
|
||||
}
|
||||
else
|
||||
c = new_create_cell(aci,dataleft,buf+i*CELL_PAYLOAD_SIZE);
|
||||
|
||||
if (!c) /* cell creation failed */
|
||||
{
|
||||
free((void *)*cellbuf);
|
||||
return -1;
|
||||
} /* cell creation failed */
|
||||
|
||||
log(LOG_DEBUG,"pack_create() : new_create_cell succeeded; copying the cell into output buffer");
|
||||
/* cell has been created, now copy into buffer */
|
||||
memcpy((void *)(*cellbuf+i*sizeof(cell_t)),(void *)c,sizeof(cell_t));
|
||||
free((void *)c);
|
||||
}
|
||||
|
||||
free(buf);
|
||||
return 0;
|
||||
} /* valid parameters */
|
||||
else /* invalid parameters */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int pack_data(uint16_t aci,unsigned char *buf, size_t buflen, unsigned char **cellbuf, unsigned int *cellbuflen)
|
||||
{
|
||||
cell_t *c;
|
||||
unsigned int cells;
|
||||
unsigned int dataleft;
|
||||
unsigned int i;
|
||||
|
||||
if ((aci) && (buf) && (cellbuf) && (cellbuflen) && (buflen)) /* valid parameters */
|
||||
{
|
||||
/* calculate number of cells required */
|
||||
if (buflen%CELL_PAYLOAD_SIZE == 0)
|
||||
cells = buflen/CELL_PAYLOAD_SIZE;
|
||||
else
|
||||
cells = buflen/CELL_PAYLOAD_SIZE+1;
|
||||
|
||||
/* allocate memory for the cells */
|
||||
*cellbuf = malloc(cells * sizeof(cell_t));
|
||||
if (!*cellbuf) /* malloc() error */
|
||||
return -1;
|
||||
|
||||
log(LOG_DEBUG,"pack_data() : Allocated memory for %u cells.",cells);
|
||||
/* create cells one by one */
|
||||
dataleft = buflen;
|
||||
for(i=0; i<cells; i++)
|
||||
{
|
||||
log(LOG_DEBUG,"pack_data() : Packing %u bytes of data.",dataleft);
|
||||
if (dataleft >= CELL_PAYLOAD_SIZE)
|
||||
{
|
||||
c = new_data_cell(aci,CELL_PAYLOAD_SIZE,buf+i*CELL_PAYLOAD_SIZE);
|
||||
dataleft -= CELL_PAYLOAD_SIZE;
|
||||
}
|
||||
else
|
||||
c = new_data_cell(aci,dataleft,buf+i*CELL_PAYLOAD_SIZE);
|
||||
|
||||
if (!c) /* cell creation failed */
|
||||
{
|
||||
free((void *)*cellbuf);
|
||||
return -1;
|
||||
} /* cell creation failed */
|
||||
|
||||
/* cell has been created, now copy into buffer */
|
||||
memcpy((void *)(*cellbuf+i*sizeof(cell_t)),(void *)c,sizeof(cell_t));
|
||||
free((void *)c);
|
||||
}
|
||||
|
||||
*cellbuflen = cells * sizeof(cell_t);
|
||||
return 0;
|
||||
} /* valid parameters */
|
||||
else /* invalid parameters */
|
||||
return -1;
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
/**
|
||||
* cell.h
|
||||
* Cell definition.
|
||||
*
|
||||
* Matej Pfajfar <mp292@cam.ac.uk>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changes :
|
||||
* $Log$
|
||||
* Revision 1.2 2002/07/18 06:38:32 arma
|
||||
* changes to support sendme cells
|
||||
*
|
||||
* Revision 1.1.1.1 2002/06/26 22:45:50 arma
|
||||
* initial commit: current code
|
||||
*
|
||||
* Revision 1.14 2002/04/02 14:27:11 badbytes
|
||||
* Final finishes.
|
||||
*
|
||||
* Revision 1.13 2002/03/03 00:06:45 mp292
|
||||
* Modifications to support re-transmission.
|
||||
*
|
||||
* Revision 1.12 2002/02/09 17:51:52 mp292
|
||||
* CELL_ACK should be 4 not 3
|
||||
*
|
||||
* Revision 1.11 2002/02/03 22:41:45 mp292
|
||||
* Changes to cell size.
|
||||
*
|
||||
* Revision 1.10 2002/01/21 20:57:19 mp292
|
||||
* Reviewed according to Secure-Programs-HOWTO.
|
||||
*
|
||||
* Revision 1.9 2002/01/17 15:00:43 mp292
|
||||
* Fixed a bug which caused malloc() generate a seg fault.
|
||||
*
|
||||
* Revision 1.8 2002/01/14 13:05:37 badbytes
|
||||
* System testing in progress.
|
||||
*
|
||||
* Revision 1.7 2002/01/10 13:15:54 badbytes
|
||||
* Fixed ACI size from 32bits to 16bits.
|
||||
*
|
||||
* Revision 1.6 2002/01/09 08:10:32 badbytes
|
||||
* *** empty log message ***
|
||||
*
|
||||
* Revision 1.5 2002/01/07 13:03:28 badbytes
|
||||
* cell.ACI is now cell.aci
|
||||
*
|
||||
* Revision 1.4 2002/01/07 09:26:00 badbytes
|
||||
* Added pack_create() and pack_data().
|
||||
*
|
||||
* Revision 1.3 2002/01/07 07:48:34 badbytes
|
||||
* fixed new_create_cell()
|
||||
*
|
||||
* Revision 1.2 2002/01/04 12:08:34 badbytes
|
||||
* Added functions for cell creation.
|
||||
*
|
||||
* Revision 1.1 2002/01/04 10:02:07 badbytes
|
||||
* Added cell definition.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __CELL_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* cell commands */
|
||||
#define CELL_PADDING 0
|
||||
#define CELL_CREATE 1
|
||||
#define CELL_DATA 2
|
||||
#define CELL_DESTROY 3
|
||||
#define CELL_ACK 4
|
||||
#define CELL_NACK 5
|
||||
#define CELL_SENDME 6
|
||||
|
||||
#define CELL_PAYLOAD_SIZE 120
|
||||
|
||||
/* cell definition */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t aci; /* Anonymous Connection Identifier */
|
||||
unsigned char command;
|
||||
unsigned char length; /* of payload if data cell, else value of sendme */
|
||||
uint32_t seq; /* sequence number */
|
||||
unsigned char payload[120];
|
||||
} cell_t;
|
||||
|
||||
cell_t *new_padding_cell(void);
|
||||
cell_t *new_create_cell(uint16_t aci, unsigned char length, unsigned char *buf);
|
||||
cell_t *new_destroy_cell(uint16_t aci);
|
||||
cell_t *new_data_cell(uint16_t aci, unsigned char length, unsigned char *buf);
|
||||
cell_t *new_ack_cell(uint16_t aci);
|
||||
cell_t *new_nack_cell(uint16_t aci);
|
||||
|
||||
int pack_create(uint16_t aci, unsigned char *onion, uint32_t onionlen, unsigned char **cellbuf, unsigned int *cellbuflen);
|
||||
int pack_data(uint16_t aci, unsigned char *buf, size_t buflen, unsigned char **cellbuf, unsigned int *cellbuflen);
|
||||
|
||||
#define __CELL_H
|
||||
#endif
|
||||
|
@ -1,77 +0,0 @@
|
||||
/**
|
||||
* opcell.c
|
||||
* Onion Proxy Cell
|
||||
*
|
||||
* Matej Pfajfar <mp292@cam.ac.uk>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changes :
|
||||
* $Log$
|
||||
* Revision 1.1 2002/06/26 22:45:50 arma
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.1 2002/03/03 12:08:18 mp292
|
||||
* Added a new type of cell - used for data going between the onion proxy and
|
||||
* the first or hop. Payload size identical to that of a normal cell.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include "opcell.h"
|
||||
#include "log.h"
|
||||
|
||||
opcell_t *new_padding_opcell()
|
||||
{
|
||||
opcell_t *c = NULL;
|
||||
int retval;
|
||||
|
||||
c = malloc(sizeof(opcell_t));
|
||||
if (!c) /* malloc() error */
|
||||
return NULL;
|
||||
|
||||
retval = RAND_pseudo_bytes((unsigned char *)c,sizeof(opcell_t));
|
||||
if (retval == -1) /* RAND_pseudo_bytes() error */
|
||||
{
|
||||
free((void *)c);
|
||||
return NULL;
|
||||
} /* RAND_pseudo_bytes() error */
|
||||
|
||||
c->command = OPCELL_PADDING;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
opcell_t *new_data_opcell(unsigned char length, unsigned char *buf)
|
||||
{
|
||||
opcell_t *c = NULL;
|
||||
int retval;
|
||||
|
||||
if ((length <= OPCELL_PAYLOAD_SIZE) && (buf)) /* valid parameters */
|
||||
{
|
||||
c = malloc(sizeof(opcell_t));
|
||||
if (!c) /* malloc() error */
|
||||
return NULL;
|
||||
|
||||
c->command = OPCELL_DATA;
|
||||
c->length = length;
|
||||
|
||||
memcpy((void *)c->payload, (void *)buf, length);
|
||||
retval = RAND_pseudo_bytes((unsigned char *)(c->payload+length),OPCELL_PAYLOAD_SIZE-length);
|
||||
if (retval == -1) /* RAND_pseudo_bytes() error */
|
||||
{
|
||||
free((void *)c);
|
||||
return NULL;
|
||||
} /* RAND_pseudo_bytes() error */
|
||||
|
||||
return c;
|
||||
} /* valid parameters */
|
||||
else /* invalid parameters */
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,44 +0,0 @@
|
||||
/**
|
||||
* opcell.h
|
||||
* Onion Proxy Cell.
|
||||
*
|
||||
* Matej Pfajfar <mp292@cam.ac.uk>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changes :
|
||||
* $Log$
|
||||
* Revision 1.1 2002/06/26 22:45:50 arma
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.1 2002/03/03 12:08:18 mp292
|
||||
* Added a new type of cell - used for data going between the onion proxy and
|
||||
* the first or hop. Payload size identical to that of a normal cell.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OPCELL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cell.h"
|
||||
|
||||
#define OPCELL_PAYLOAD_SIZE CELL_PAYLOAD_SIZE
|
||||
|
||||
#define OPCELL_PADDING 0
|
||||
#define OPCELL_DATA 1
|
||||
|
||||
/* cell definition */
|
||||
typedef struct
|
||||
{
|
||||
unsigned char command;
|
||||
unsigned char length; /* of payload */
|
||||
unsigned char payload[OPCELL_PAYLOAD_SIZE];
|
||||
} opcell_t;
|
||||
|
||||
opcell_t *new_data_opcell(unsigned char length, unsigned char *buf);
|
||||
opcell_t *new_padding_opcell();
|
||||
|
||||
#define __OPCELL_H
|
||||
#endif
|
||||
|
@ -1,147 +0,0 @@
|
||||
/*
|
||||
* routent.c
|
||||
* Onion Router and related definitions.
|
||||
*
|
||||
* Matej Pfajfar <mp292@cam.ac.uk>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changes :
|
||||
* $Log$
|
||||
* Revision 1.1 2002/06/26 22:45:50 arma
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.6 2002/04/02 14:27:11 badbytes
|
||||
* Final finishes.
|
||||
*
|
||||
* Revision 1.5 2002/03/12 23:38:54 mp292
|
||||
* Being pedantic about some pointer conversions.
|
||||
*
|
||||
* Revision 1.4 2002/03/03 00:24:26 mp292
|
||||
* Corrected paths to some #include files.
|
||||
*
|
||||
* Revision 1.3 2002/03/03 00:06:45 mp292
|
||||
* Modifications to support re-transmission.
|
||||
*
|
||||
* Revision 1.2 2002/01/26 19:26:55 mp292
|
||||
* Reviewed according to Secure-Programs-HOWTO.
|
||||
*
|
||||
* Revision 1.1 2002/01/10 08:28:33 badbytes
|
||||
* routent and routentEX related routines
|
||||
*
|
||||
*/
|
||||
|
||||
#include "policies.h"
|
||||
|
||||
#include "routent.h"
|
||||
|
||||
routentEX_t *id_router(routentEX_t **routerarray, size_t rarray_len, uint32_t addr, uint16_t port)
|
||||
{
|
||||
routentEX_t *router;
|
||||
int i;
|
||||
|
||||
if (!routerarray)
|
||||
return NULL;
|
||||
|
||||
for(i=0;i<rarray_len;i++)
|
||||
{
|
||||
router = routerarray[i];
|
||||
if ((router->addr == addr) && (router->port == port))
|
||||
return router;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
routentEX_t *id_routerbys(routentEX_t **routerarray, size_t rarray_len, int s)
|
||||
{
|
||||
routentEX_t *router;
|
||||
int i;
|
||||
|
||||
if (!routerarray)
|
||||
return NULL;
|
||||
|
||||
for(i=0;i<rarray_len;i++)
|
||||
{
|
||||
router = routerarray[i];
|
||||
if (router->s == s)
|
||||
return router;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
conn_buf_t *new_conn_buf(uint16_t aci, int policy, conn_buf_t **conn_bufs, conn_buf_t **last_conn_buf)
|
||||
{
|
||||
conn_buf_t *conn_buf;
|
||||
|
||||
if ((!aci) || (!conn_bufs) || (!last_conn_buf)) /* invalid parameters */
|
||||
return NULL;
|
||||
|
||||
conn_buf = (conn_buf_t *)malloc(sizeof(conn_buf_t));
|
||||
if (!conn_buf)
|
||||
return NULL;
|
||||
|
||||
memset((void *)conn_buf,0,sizeof(conn_buf_t));
|
||||
conn_buf->win_size = DEFAULT_WINDOW_SIZE;
|
||||
conn_buf->win_avail = DEFAULT_WINDOW_SIZE;
|
||||
conn_buf->aci = aci;
|
||||
conn_buf->policy = policy;
|
||||
|
||||
if (!*conn_bufs)
|
||||
{
|
||||
*conn_bufs = conn_buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*last_conn_buf)->next=(void *)conn_buf;
|
||||
conn_buf->prev = (void *)*last_conn_buf;
|
||||
}
|
||||
|
||||
*last_conn_buf = conn_buf;
|
||||
|
||||
return conn_buf;
|
||||
}
|
||||
|
||||
int remove_conn_buf(conn_buf_t *conn_buf, conn_buf_t **conn_bufs, conn_buf_t **last_conn_buf)
|
||||
{
|
||||
if ( (!conn_buf) || (!*conn_bufs) || (!*last_conn_buf) ) /* invalid parameters */
|
||||
return -1;
|
||||
|
||||
if (conn_buf->next)
|
||||
((conn_buf_t *)(conn_buf->next))->prev = conn_buf->prev;
|
||||
if (conn_buf->prev)
|
||||
((conn_buf_t *)(conn_buf->prev))->next = conn_buf->next;
|
||||
|
||||
if (conn_buf == *last_conn_buf)
|
||||
*last_conn_buf = (conn_buf_t *)conn_buf->prev;
|
||||
|
||||
if (conn_buf == *conn_bufs)
|
||||
*conn_bufs = (conn_buf_t *)conn_buf->next;
|
||||
|
||||
if (conn_buf->buf)
|
||||
free((void *)conn_buf->buf);
|
||||
|
||||
free((void *)conn_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
conn_buf_t *id_conn_buf(conn_buf_t *conn_bufs, uint16_t aci)
|
||||
{
|
||||
conn_buf_t *conn_buf;
|
||||
|
||||
if ( (!aci) || (!conn_bufs) )
|
||||
return NULL;
|
||||
|
||||
conn_buf = conn_bufs;
|
||||
while (conn_buf)
|
||||
{
|
||||
if (conn_buf->aci == aci)
|
||||
return conn_buf;
|
||||
|
||||
conn_buf = conn_buf->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
@ -1,189 +0,0 @@
|
||||
/*
|
||||
* routent.h
|
||||
* Onion Router and related definitions.
|
||||
*
|
||||
* Matej Pfajfar <mp292@cam.ac.uk>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changes :
|
||||
* $Log$
|
||||
* Revision 1.1 2002/06/26 22:45:50 arma
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.25 2002/04/02 14:27:11 badbytes
|
||||
* Final finishes.
|
||||
*
|
||||
* Revision 1.24 2002/03/29 09:54:19 badbytes
|
||||
* Fixed type of routentEX.min_interval to struct timeval.
|
||||
*
|
||||
* Revision 1.23 2002/03/21 07:20:59 badbytes
|
||||
* Added a dependency to <sys/time.h>.
|
||||
*
|
||||
* Revision 1.22 2002/03/12 23:37:14 mp292
|
||||
* Additional flag - destory_buf saying whether the buffer should be destroyed
|
||||
* when the destroy cell is sent.
|
||||
*
|
||||
* Revision 1.21 2002/03/03 00:06:45 mp292
|
||||
* Modifications to support re-transmission.
|
||||
*
|
||||
* Revision 1.20 2002/02/09 16:58:53 mp292
|
||||
* Postponed implementtion of POLICY_DROP_CONNECTIONS due to problems. Need to
|
||||
* discuss with Andrei first.
|
||||
*
|
||||
* Revision 1.19 2002/02/09 16:54:59 mp292
|
||||
* routentEX now contains a per anonymous connection packet count
|
||||
*
|
||||
* Revision 1.18 2002/01/29 00:59:16 mp292
|
||||
* Slight changes in the way timers are kept, c.f. changes in the network funnel.
|
||||
*
|
||||
* Revision 1.17 2002/01/28 21:37:36 mp292
|
||||
* Router's output buffer is now dynamic. Time of last output to the router
|
||||
* added to routentEX.
|
||||
*
|
||||
* Revision 1.16 2002/01/26 19:26:55 mp292
|
||||
* Reviewed according to Secure-Programs-HOWTO.
|
||||
*
|
||||
* Revision 1.15 2002/01/18 22:55:40 mp292
|
||||
* Added a cell buffer to struct routent so that a cell can be received in
|
||||
* several bursts of data. This prevents a DoS attack on the network funnel.
|
||||
*
|
||||
* Revision 1.14 2002/01/14 13:05:37 badbytes
|
||||
* System testing in progress.
|
||||
*
|
||||
* Revision 1.13 2002/01/11 15:47:17 badbytes
|
||||
* *** empty log message ***
|
||||
*
|
||||
* Revision 1.12 2002/01/10 08:28:33 badbytes
|
||||
* routent and routentEX related routines
|
||||
*
|
||||
* Revision 1.11 2002/01/08 15:13:30 badbytes
|
||||
* Added cipher context to routentEX
|
||||
*
|
||||
* Revision 1.10 2002/01/08 13:18:48 badbytes
|
||||
* Added a connection buffer to routentEX
|
||||
*
|
||||
* Revision 1.9 2002/01/08 13:02:16 badbytes
|
||||
* routentEX now contains f_key and b_key, 56-bit DES keys for link encryption
|
||||
*
|
||||
* Revision 1.8 2002/01/03 11:17:01 badbytes
|
||||
* routentEX.max and routentEX.min values changed to 32bit not 64bit.
|
||||
*
|
||||
* Revision 1.7 2002/01/03 11:04:16 badbytes
|
||||
* *** empty log message ***
|
||||
*
|
||||
* Revision 1.6 2002/01/03 11:03:14 badbytes
|
||||
* Added an extended version of routent which includes link utilisation info.
|
||||
*
|
||||
* Revision 1.5 2001/12/18 15:26:34 badbytes
|
||||
* Added #inclusion of <stdint.h>
|
||||
*
|
||||
* Revision 1.4 2001/12/18 15:19:41 badbytes
|
||||
* In struct routent, changed long and short types to uint32_t and uint16_t
|
||||
*
|
||||
* Revision 1.3 2001/12/18 10:37:47 badbytes
|
||||
* Header files now only apply if they were not previously included from somewhere else.
|
||||
*
|
||||
* Revision 1.2 2001/12/17 13:35:17 badbytes
|
||||
* Still writing handle_connection()
|
||||
*
|
||||
* Revision 1.1 2001/12/14 13:14:03 badbytes
|
||||
* Split types.h into routent.h and ss.h. Keeping them all in one file created unnecesary dependencies.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ROUTENT_H
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <sys/timeb.h>
|
||||
|
||||
#include "cell.h"
|
||||
|
||||
/* per-anonymous-connection cell buffer */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t aci;
|
||||
int policy;
|
||||
unsigned int cells;
|
||||
unsigned char *buf;
|
||||
unsigned int buflen;
|
||||
unsigned int offset; /* offset to the position of the first cell in the buffer */
|
||||
cell_t dc; /* static buffer for the destroy cell - so we are always able to destroy a connection */
|
||||
unsigned char dc_set; /* flag that signifies presence of a destroy cell */
|
||||
unsigned char destroy_buf; /* flag that signifies that the buffer shuld be destroyed when the destroy cell is sent */
|
||||
|
||||
/* POLICY_DROP_CELLS only */
|
||||
unsigned int win_size; /* window size for the connection (number of cells)*/
|
||||
unsigned int win_avail; /* available window size */
|
||||
uint32_t seq_out; /* next sequence number to use for outgoing cells */
|
||||
uint32_t seq_in; /* next expected sequence number */
|
||||
uint32_t ack; /* next expected ack/nack */
|
||||
struct timeval last_ack; /* time of last ACK/NACK */
|
||||
|
||||
void *prev;
|
||||
void *next;
|
||||
} conn_buf_t;
|
||||
|
||||
/* onion router as seen by the onion proxy */
|
||||
typedef struct
|
||||
{
|
||||
char *address;
|
||||
uint32_t addr; /* address in network byte order */
|
||||
uint16_t port; /* network port in network byte order */
|
||||
uint16_t entry_port; /* entry port in network byte order */
|
||||
RSA *pkey;
|
||||
void *next;
|
||||
} routent_t;
|
||||
|
||||
/* onion router as seen by other routers */
|
||||
typedef struct
|
||||
{
|
||||
char *address;
|
||||
|
||||
uint32_t addr;
|
||||
uint16_t port;
|
||||
|
||||
RSA *pkey; /* public RSA key */
|
||||
/* 64-bit DES keys for link encryption */
|
||||
char f_key[8];
|
||||
char b_key[8];
|
||||
char f_iv[8];
|
||||
char b_iv[8];
|
||||
EVP_CIPHER_CTX f_ctx;
|
||||
EVP_CIPHER_CTX b_ctx;
|
||||
|
||||
/* link info */
|
||||
uint32_t min;
|
||||
uint32_t max;
|
||||
struct timeval min_interval;
|
||||
|
||||
/* time when last data was sent to that router */
|
||||
struct timeval lastsend;
|
||||
|
||||
/* socket */
|
||||
int s;
|
||||
|
||||
/* connection buffers */
|
||||
conn_buf_t *conn_bufs; /* linked list of connection buffers */
|
||||
conn_buf_t *last_conn_buf; /* last item in the list */
|
||||
unsigned int next_to_service; /* offset to the connection buffer that is next in turn to be serviced */
|
||||
|
||||
/* cell buffer */
|
||||
unsigned char cellbuf[128];
|
||||
unsigned int celllen;
|
||||
|
||||
void *next;
|
||||
} routentEX_t;
|
||||
|
||||
routentEX_t *id_router(routentEX_t **routerarray, size_t rarray_len, uint32_t addr, uint16_t port);
|
||||
routentEX_t *id_routerbys(routentEX_t **routerarray, size_t rarray_len, int s);
|
||||
|
||||
conn_buf_t *new_conn_buf(uint16_t aci, int policy, conn_buf_t **conn_bufs, conn_buf_t **last_conn_buf);
|
||||
int remove_conn_buf(conn_buf_t *conn_buf, conn_buf_t **conn_bufs, conn_buf_t **last_conn_buf);
|
||||
conn_buf_t *id_conn_buf(conn_buf_t *conn_bufs, uint16_t aci);
|
||||
|
||||
#define __ROUTENT_H
|
||||
#endif
|
@ -1,260 +0,0 @@
|
||||
/*
|
||||
* scheduler.c
|
||||
* Scheduler
|
||||
*
|
||||
* Matej Pfajfar <mp292@cam.ac.uk>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changes :
|
||||
* $Log$
|
||||
* Revision 1.1 2002/06/26 22:45:50 arma
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.3 2002/04/02 10:20:37 badbytes
|
||||
* Bug fixes.
|
||||
*
|
||||
* Revision 1.2 2002/03/28 10:49:07 badbytes
|
||||
* Renamed get_trigger() to sched_trigger().
|
||||
*
|
||||
* Revision 1.1 2002/03/28 10:36:55 badbytes
|
||||
* A generic scheduler.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
#include "log.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
/* create a new scheduler */
|
||||
sched_t *new_sched()
|
||||
{
|
||||
sched_t *sched;
|
||||
|
||||
sched = (sched_t *)malloc(sizeof(sched_t));
|
||||
if (!sched)
|
||||
return NULL;
|
||||
|
||||
sched->entries = NULL;
|
||||
return sched;
|
||||
}
|
||||
|
||||
/* delete a scheduler from memory */
|
||||
void free_sched(sched_t *sched)
|
||||
{
|
||||
sched_entry_t *entry;
|
||||
if (!sched)
|
||||
return;
|
||||
|
||||
while(sched->entries)
|
||||
{
|
||||
entry = (sched_entry_t *)sched->entries->next;
|
||||
free((void *)sched->entries);
|
||||
sched->entries = entry;
|
||||
}
|
||||
}
|
||||
|
||||
/* add a new item to the scheduler */
|
||||
int add_sched_entry(sched_t *sched, struct timeval last, struct timeval interval)
|
||||
{
|
||||
sched_entry_t *new_entry;
|
||||
sched_entry_t *prev;
|
||||
sched_entry_t *next;
|
||||
|
||||
if (!sched) /* invalid parameters */
|
||||
return -1;
|
||||
|
||||
new_entry = (sched_entry_t *)malloc(sizeof(sched_entry_t));
|
||||
if (!new_entry)
|
||||
return -1;
|
||||
|
||||
new_entry->last = last;
|
||||
new_entry->interval = interval;
|
||||
|
||||
if (!sched->entries) /* empty list */
|
||||
{
|
||||
sched->entries = new_entry;
|
||||
new_entry->prev = NULL;
|
||||
new_entry->next = NULL;
|
||||
}
|
||||
else /* maintain a priority queue of items */
|
||||
{
|
||||
/* find the next largest element in the list */
|
||||
next = sched->entries;
|
||||
while(next)
|
||||
{
|
||||
if (sched_entry_geq(next->last, next->interval, last, interval))
|
||||
{
|
||||
prev = (sched_entry_t *)next->prev;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev = next;
|
||||
next = (sched_entry_t *)next->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev)
|
||||
prev->next = (void *)new_entry;
|
||||
else
|
||||
sched->entries = new_entry;
|
||||
|
||||
if (next)
|
||||
next->prev = (void *)new_entry;
|
||||
|
||||
new_entry->prev = (void *)prev;
|
||||
new_entry->next = (void *)next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int remove_sched_entry(sched_t *sched, struct timeval last, struct timeval interval)
|
||||
{
|
||||
sched_entry_t *entry;
|
||||
|
||||
if (!sched)
|
||||
return -1;
|
||||
|
||||
if (!sched->entries)
|
||||
return -1;
|
||||
|
||||
entry = sched->entries;
|
||||
while(entry)
|
||||
{
|
||||
if ((entry->last.tv_sec == last.tv_sec) && (entry->last.tv_usec = last.tv_usec) && (entry->interval.tv_sec == interval.tv_sec) && (entry->interval.tv_usec == interval.tv_usec))
|
||||
{
|
||||
if (entry->prev)
|
||||
((sched_entry_t *)(entry->prev))->next = entry->next;
|
||||
else
|
||||
sched->entries = (sched_entry_t *)entry->next;
|
||||
|
||||
if (entry->next)
|
||||
((sched_entry_t *)(entry->next))->prev = entry->prev;
|
||||
|
||||
free((void *)entry);
|
||||
break;
|
||||
}
|
||||
else
|
||||
entry = (sched_entry_t *)entry->next;
|
||||
}
|
||||
|
||||
if (entry) /* found and deleted */
|
||||
return 0;
|
||||
else /* not found */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* update an existing item with new values */
|
||||
int update_sched_entry(sched_t *sched, struct timeval old_last, struct timeval old_interval, struct timeval new_last, struct timeval new_interval)
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (!sched)
|
||||
return -1;
|
||||
|
||||
/* remove the old entry first */
|
||||
retval = remove_sched_entry(sched, old_last, old_interval);
|
||||
if (!retval)
|
||||
{
|
||||
/* add the new one */
|
||||
retval = add_sched_entry(sched, new_last, new_interval);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* get the time interval from now until the next time an item needs to be serviced */
|
||||
int sched_trigger(sched_t *sched, struct timeval **result)
|
||||
{
|
||||
int retval;
|
||||
struct timeval *result_val;
|
||||
struct timeval now;
|
||||
struct timeval next;
|
||||
|
||||
if (!sched) /* invalid parameters */
|
||||
return -1;
|
||||
|
||||
if (!sched->entries) /* no entries */
|
||||
{
|
||||
*result = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* take the minimum element in the queue and calculate its next service time */
|
||||
next.tv_sec = sched->entries->last.tv_sec + sched->entries->interval.tv_sec;
|
||||
if (sched->entries->last.tv_usec + sched->entries->interval.tv_usec <= 999999)
|
||||
next.tv_usec = sched->entries->last.tv_usec + sched->entries->interval.tv_usec;
|
||||
else
|
||||
{
|
||||
next.tv_sec++;
|
||||
next.tv_usec = sched->entries->last.tv_usec + sched->entries->interval.tv_usec - 1000000;
|
||||
}
|
||||
|
||||
/* get current time */
|
||||
retval = gettimeofday(&now,NULL);
|
||||
if (retval == -1)
|
||||
return -1;
|
||||
|
||||
/* allocate memory for the result */
|
||||
result_val = (struct timeval *)malloc(sizeof(struct timeval));
|
||||
if (!result_val)
|
||||
return -1;
|
||||
|
||||
/* subtract now from next (return zero if negative) */
|
||||
if ((next.tv_sec > now.tv_sec) || ((next.tv_sec == now.tv_sec) && (next.tv_usec >= now.tv_usec)))
|
||||
{
|
||||
result_val->tv_sec = next.tv_sec - now.tv_sec;
|
||||
if (next.tv_usec >= now.tv_usec)
|
||||
result_val->tv_usec = next.tv_usec - now.tv_usec;
|
||||
else
|
||||
{
|
||||
result_val->tv_sec--;
|
||||
result_val->tv_usec = 1000000 + next.tv_usec - now.tv_usec;
|
||||
}
|
||||
}
|
||||
else /* next service time has already passed, return a timeout of zero */
|
||||
{
|
||||
result_val->tv_sec = 0;
|
||||
result_val->tv_usec = 0;
|
||||
}
|
||||
|
||||
*result = result_val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sched_entry_geq(struct timeval last1, struct timeval interval1, struct timeval last2, struct timeval interval2)
|
||||
{
|
||||
struct timeval next1;
|
||||
struct timeval next2;
|
||||
|
||||
/* calculate next service time for entry1 */
|
||||
next1.tv_sec = last1.tv_sec + interval1.tv_sec;
|
||||
if (last1.tv_usec + interval1.tv_usec <= 999999)
|
||||
next1.tv_usec = last1.tv_usec + interval1.tv_usec;
|
||||
else
|
||||
{
|
||||
next1.tv_sec++;
|
||||
next1.tv_usec = last1.tv_usec + interval1.tv_usec - 1000000;
|
||||
}
|
||||
|
||||
/* calculate next service time for entry2 */
|
||||
next2.tv_sec = last2.tv_sec + interval2.tv_sec;
|
||||
if (last2.tv_usec + interval2.tv_usec <= 999999)
|
||||
next2.tv_usec = last2.tv_usec + interval2.tv_usec;
|
||||
else
|
||||
{
|
||||
next2.tv_sec++;
|
||||
next2.tv_usec = last2.tv_usec + interval2.tv_usec - 1000000;
|
||||
}
|
||||
|
||||
/* compare */
|
||||
if ((next1.tv_sec > next2.tv_sec) || ((next1.tv_sec == next2.tv_sec) && (next1.tv_usec >= next2.tv_usec)))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* scheduler.h
|
||||
* Scheduler
|
||||
*
|
||||
* Matej Pfajfar <mp292@cam.ac.uk>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changes :
|
||||
* $Log$
|
||||
* Revision 1.1 2002/06/26 22:45:50 arma
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.2 2002/03/28 10:49:07 badbytes
|
||||
* Renamed get_trigger() to sched_trigger().
|
||||
*
|
||||
* Revision 1.1 2002/03/28 10:36:55 badbytes
|
||||
* A generic scheduler.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SCHEDULER_H
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct timeval last;
|
||||
struct timeval interval;
|
||||
void *prev;
|
||||
void *next;
|
||||
} sched_entry_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
sched_entry_t *entries;
|
||||
} sched_t;
|
||||
|
||||
/* create a new scheduler */
|
||||
sched_t *new_sched();
|
||||
/* delete a scheduler from memory */
|
||||
void free_sched(sched_t *sched);
|
||||
|
||||
/* add a new item to the scheduler */
|
||||
int add_sched_entry(sched_t *sched, struct timeval last, struct timeval interval);
|
||||
/* remove an item from the scheduler */
|
||||
int remove_sched_entry(sched_t *sched, struct timeval last, struct timeval interval);
|
||||
/* update an existing item with new values */
|
||||
int update_sched_entry(sched_t *sched, struct timeval old_last, struct timeval old_interval, struct timeval new_last, struct timeval new_interval);
|
||||
|
||||
/* get the time interval from now until the next time an item needs to be serviced */
|
||||
int sched_trigger(sched_t *sched, struct timeval **result);
|
||||
/* compare two scheduler entries (returns 1 if entry1 >= entry2, 0 otherwise */
|
||||
int sched_entry_geq(struct timeval last1, struct timeval interval1, struct timeval last2, struct timeval interval2);
|
||||
|
||||
# define __SCHEDULER_H
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user