struct dh_if *dh;
struct hash_if *hash;
- uint32_t setup_retries; /* How many times to send setup packets */
- uint32_t setup_timeout; /* Initial timeout for setup packets */
- uint32_t wait_timeout; /* How long to wait if setup unsuccessful */
- uint32_t key_lifetime; /* How long a key lasts once set up */
- uint32_t key_renegotiate_time; /* If we see traffic (or a keepalive)
+ int32_t setup_retries; /* How many times to send setup packets */
+ int32_t setup_timeout; /* Initial timeout for setup packets */
+ int32_t wait_timeout; /* How long to wait if setup unsuccessful */
+ int32_t key_lifetime; /* How long a key lasts once set up */
+ int32_t key_renegotiate_time; /* If we see traffic (or a keepalive)
after this time, initiate a new
key exchange */
bool_t keepalive; /* Send keepalives to detect peer failure (not yet
implemented) */
uint8_t *setupsig; /* Expected signature of incoming MSG1 packets */
- uint32_t setupsiglen; /* Allows us to discard packets quickly if
- they are not for us */
+ int32_t setupsiglen; /* Allows us to discard packets quickly if
+ they are not for us */
bool_t setup_priority; /* Do we have precedence if both sites emit
message 1 simultaneously? */
uint32_t log_events;
uint8_t localN[NONCELEN]; /* Nonces for key exchange */
uint8_t remoteN[NONCELEN];
struct buffer_if buffer; /* Current outgoing key exchange packet */
- uint32_t retries; /* Number of retries remaining */
+ int32_t retries; /* Number of retries remaining */
uint64_t timeout; /* Timeout for current state */
uint8_t *dhsecret;
uint8_t *sharedsecret;
static void slog(struct site *st, uint32_t event, cstring_t msg, ...)
{
va_list ap;
- uint8_t buf[240];
+ char buf[240];
uint32_t class;
va_start(ap,msg);
uint8_t *hashstart;
uint32_t dest;
uint32_t source;
- uint32_t remlen;
+ int32_t remlen;
uint8_t *remote;
- uint32_t loclen;
+ int32_t loclen;
uint8_t *local;
uint8_t *nR;
uint8_t *nL;
- uint32_t pklen;
+ int32_t pklen;
uint8_t *pk;
- uint32_t hashlen;
- uint32_t siglen;
+ int32_t hashlen;
+ int32_t siglen;
uint8_t *sig;
};
int *timeout_io)
{
if (timeout) {
- uint64_t offset=timeout-*now;
+ int64_t offset=timeout-*now;
+ if (offset<0) offset=0;
if (offset>INT_MAX) offset=INT_MAX;
if (*timeout_io<0 || offset<*timeout_io)
*timeout_io=offset;
sprintf(st->tunname,"%s<->%s",st->localname,st->remotename);
/* The information we expect to see in incoming messages of type 1 */
+ /* fixme: lots of unchecked overflows here, but the results are only
+ corrupted packets rather than undefined behaviour */
st->setupsiglen=strlen(st->remotename)+strlen(st->localname)+8;
st->setupsig=safe_malloc(st->setupsiglen,"site_apply");
put_uint32(st->setupsig+0,LABEL_MSG1);
return new_closure(&st->cl);
}
-init_module site_module;
void site_module(dict_t *dict)
{
add_closure(dict,"site",site_apply);