struct dict *parent;
struct searchlist *search;
struct entry *entries;
- uint32_t size;
+ int32_t size;
};
static struct atomlist *atoms=NULL;
return "**unknown**";
}
-static void ptree_indent(uint32_t amount)
+static void ptree_indent(int amount)
{
- uint32_t i;
+ int i;
for (i=0; i<amount; i++) printf(" . ");
}
return NULL;
}
-uint32_t list_length(list_t *a)
+int32_t list_length(list_t *a)
{
- uint32_t l=0;
+ int32_t l=0;
list_t *i;
for (i=a; i; i=i->next) { assert(l < INT_MAX); l++; }
return l;
return list_append_list(list,l);
}
-item_t *list_elem(list_t *l, uint32_t index)
+item_t *list_elem(list_t *l, int32_t index)
{
if (!l) return NULL;
if (index==0) return l->item;
struct include_stack_item include_stack[MAX_INCLUDE_DEPTH];
int include_stack_ptr=0;
-uint32_t config_lineno=0;
+int config_lineno=0;
cstring_t config_file="xxx";
static struct p_node *leafnode(uint32_t type)
};
extern cstring_t config_file;
-extern uint32_t config_lineno;
+extern int config_lineno;
extern int yynerrs;
/* Keys in dictionaries are 'atoms', which are constructed from strings
MP_INT p,g; /* prime modulus and generator */
};
-static string_t dh_makepublic(void *sst, uint8_t *secret, uint32_t secretlen)
+static string_t dh_makepublic(void *sst, uint8_t *secret, int32_t secretlen)
{
struct dh *st=sst;
string_t r;
}
static dh_makeshared_fn dh_makeshared;
-static void dh_makeshared(void *sst, uint8_t *secret, uint32_t secretlen,
+static void dh_makeshared(void *sst, uint8_t *secret, int32_t secretlen,
cstring_t rempublic, uint8_t *sharedsecret,
- uint32_t buflen)
+ int32_t buflen)
{
struct dh *st=sst;
MP_INT a, b, c;
bool_t (*packy_par_gen)(struct site *st);
void hacky_par_end(int *ok,
- uint32_t retries, uint32_t timeout,
+ int32_t retries, uint32_t timeout,
bool_t (*send_msg)(struct site *st), struct site *st) {
int i;
int hacky_par_start_failnow(void) { return 0; }
int hacky_par_mid_failnow(void) { return 0; }
void hacky_par_end(int *ok,
- uint32_t retries, uint32_t timeout,
+ int32_t retries, uint32_t timeout,
bool_t (*send_msg)(struct site *st), struct site *st) { }
#endif /*HACKY_PARALLEL...else*/
int hacky_par_start_failnow(void);
int hacky_par_mid_failnow(void);
void hacky_par_end(int *ok,
- uint32_t retries, uint32_t timeout,
+ int32_t retries, uint32_t timeout,
bool_t (*send_msg)(struct site *st), struct site *st);
#endif /* hackympzpar_h */
free(a);
}
-static void subnet_list_set_len(struct subnet_list *a, uint32_t l)
+static void subnet_list_set_len(struct subnet_list *a, int32_t l)
{
struct subnet *nd;
- uint32_t na;
+ int32_t na;
if (l>a->alloc) {
assert(a->alloc < (int)(INT_MAX/sizeof(*nd))-EXTEND_ALLOC_BY);
a->entries=l;
}
-void subnet_list_append(struct subnet_list *a, uint32_t prefix, uint32_t len)
+void subnet_list_append(struct subnet_list *a, uint32_t prefix, int len)
{
struct subnet *sn;
assert(a->entries < INT_MAX);
#ifdef DEBUG
static void ipset_dump(struct ipset *a, string_t name)
{
- uint32_t i;
+ int32_t i;
printf("%s: ",name);
for (i=0; i<a->l; i++) {
struct ipset *ipset_from_subnet_list(struct subnet_list *l)
{
struct ipset *r, *a, *b;
- uint32_t i;
+ int32_t i;
r=ipset_new();
for (i=0; i<l->entries; i++) {
return r;
}
-static void ipset_set_len(struct ipset *a, uint32_t l)
+static void ipset_set_len(struct ipset *a, int32_t l)
{
struct iprange *nd;
- uint32_t na;
+ int32_t na;
if (l>a->a) {
assert(a->a < INT_MAX-EXTEND_ALLOC_BY);
{
struct ipset *c;
struct iprange r;
- uint32_t ia,ib;
+ int32_t ia,ib;
c=ipset_new();
ia=0; ib=0;
{
struct ipset *r;
struct iprange ra, rb;
- uint32_t ia,ib;
+ int32_t ia,ib;
r=ipset_new();
ia=0; ib=0;
struct ipset *r;
struct iprange n;
int64_t pre;
- uint32_t i,lo,hi;
+ int32_t i;
+ uint32_t lo,hi;
r=ipset_new();
pre=-1;
bool_t ipset_contains_addr(struct ipset *a, uint32_t addr)
{
- uint32_t i;
+ int32_t i;
struct iprange r;
for (i=0; i<a->l; i++) {
{
struct subnet_list *r;
int64_t a,b,lobit,himask,lomask;
- int32_t bits;
- uint32_t i;
+ int bits;
+ int32_t i;
r=subnet_list_new();
for (i=0; i<is->l; i++) {
{
struct subnet s;
uint32_t a, b, c, d, n;
- uint32_t match;
+ int match;
cstring_t in;
*invert=False;
uint32_t string_item_to_ipaddr(item_t *i, cstring_t desc)
{
uint32_t a, b, c, d;
- uint32_t match;
+ int match;
/* i is not guaranteed to be a string */
if (i->type!=t_string) {
struct subnet {
uint32_t prefix;
uint32_t mask;
- uint32_t len;
+ int len;
};
struct subnet_list {
- uint32_t entries;
- uint32_t alloc;
+ int32_t entries;
+ int32_t alloc;
struct subnet *list;
};
};
struct ipset {
- uint32_t l; /* Number of entries in list */
- uint32_t a; /* Allocated space in list */
+ int32_t l; /* Number of entries in list */
+ int32_t a; /* Allocated space in list */
struct iprange *d;
};
extern struct subnet_list *subnet_list_new(void);
extern void subnet_list_free(struct subnet_list *a);
-extern void subnet_list_append(struct subnet_list *a, uint32_t prefix,
- uint32_t len);
+extern void subnet_list_append(struct subnet_list *a, uint32_t prefix, int len);
static inline bool_t subnet_match(struct subnet s, uint32_t address)
{
FILE *dest=stdout;
#define MESSAGE_BUFLEN 1023
static char buff[MESSAGE_BUFLEN+1]={0,};
- uint32_t bp;
+ size_t bp;
char *nlp;
if (secnet_is_daemon) {
#ifdef WORDS_BIGENDIAN
static void
-byteSwap(uint32_t *buf, unsigned words)
+byteSwap(uint32_t *buf, int words)
{
md5byte *p = (md5byte *)buf;
return ctx;
}
-static void md5_update(void *sst, uint8_t const *buf, uint32_t len)
+static void md5_update(void *sst, uint8_t const *buf, int32_t len)
{
struct MD5Context *ctx=sst;
#define ICMP_CODE_TTL_EXCEEDED 0
/* Generic IP checksum routine */
-static inline uint16_t ip_csum(uint8_t *iph,uint32_t count)
+static inline uint16_t ip_csum(uint8_t *iph,int32_t count)
{
register uint32_t sum=0;
* By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by
* Arnt Gulbrandsen.
*/
-static inline uint16_t ip_fast_csum(uint8_t *iph, uint32_t ihl) {
+static inline uint16_t ip_fast_csum(uint8_t *iph, int32_t ihl) {
uint32_t sum;
__asm__ __volatile__(
return sum;
}
#else
-static inline uint16_t ip_fast_csum(uint8_t *iph, uint32_t ihl)
+static inline uint16_t ip_fast_csum(uint8_t *iph, int32_t ihl)
{
+ assert(ihl < INT_MAX/4);
return ip_csum(iph,ihl*4);
}
#endif
/* Fill in the ICMP checksum field correctly */
static void netlink_icmp_csum(struct icmphdr *h)
{
- uint32_t len;
+ int32_t len;
len=ntohs(h->iph.tot_len)-(4*h->iph.ihl);
h->check=0;
static bool_t netlink_check(struct netlink *st, struct buffer_if *buf)
{
struct iphdr *iph=(struct iphdr *)buf->start;
- uint32_t len;
+ int32_t len;
if (iph->ihl < 5 || iph->version != 4) return False;
if (buf->size < iph->ihl*4) return False;
static void netlink_output_subnets(struct netlink *st, uint32_t loglevel,
struct subnet_list *snets)
{
- uint32_t i;
+ int32_t i;
string_t net;
for (i=0; i<snets->entries; i++) {
{
struct netlink *st=sst;
struct netlink_client *c;
- uint32_t i;
+ int32_t i;
/* All the networks serviced by the various tunnels should now
* have been registered. We build a routing table by sorting the
return True;
}
-static void netlink_inst_set_mtu(void *sst, uint32_t new_mtu)
+static void netlink_inst_set_mtu(void *sst, int32_t new_mtu)
{
struct netlink_client *c=sst;
}
static void netlink_inst_reg(void *sst, netlink_deliver_fn *deliver,
- void *dst, uint32_t max_start_pad,
- uint32_t max_end_pad)
+ void *dst, int32_t max_start_pad,
+ int32_t max_end_pad)
{
struct netlink_client *c=sst;
struct netlink *st=c->nst;
struct netlink_client *c;
string_t name;
struct ipset *networks;
- uint32_t options,priority,mtu;
+ uint32_t options,priority;
+ int32_t mtu;
list_t *l;
name=dict_read_string(dict, "name", True, st->name, loc);
void *dst;
string_t name;
uint32_t link_quality;
- uint32_t mtu;
+ int32_t mtu;
uint32_t options;
uint32_t outcount;
bool_t up; /* Should these routes exist in the kernel? */
closure_t cl;
void *dst; /* Pointer to host interface state */
cstring_t name;
- uint32_t max_start_pad;
- uint32_t max_end_pad;
+ int32_t max_start_pad;
+ int32_t max_end_pad;
struct ipset *networks; /* Local networks */
struct subnet_list *subnets; /* Same as networks, for display */
struct ipset *remote_networks; /* Allowable remote networks */
uint32_t secnet_address; /* our own address, or the address of the
other end of a point-to-point link */
bool_t ptp;
- uint32_t mtu;
+ int32_t mtu;
struct netlink_client *clients; /* Linked list of clients */
struct netlink_client **routes; /* Array of clients, sorted by priority */
- uint32_t n_clients;
+ int32_t n_clients;
netlink_deliver_fn *deliver_to_host; /* Provided by driver */
netlink_route_fn *set_routes; /* Provided by driver */
struct buffer_if icmp; /* Buffer for assembly of outgoing ICMP */
};
static random_fn random_generate;
-static bool_t random_generate(void *data, uint32_t bytes, uint8_t *buff)
+static bool_t random_generate(void *data, int32_t bytes, uint8_t *buff)
{
struct rgen_data *st=data;
int r;
static const char *hexchars="0123456789abcdef";
-static string_t rsa_sign(void *sst, uint8_t *data, uint32_t datalen)
+static string_t rsa_sign(void *sst, uint8_t *data, int32_t datalen)
{
struct rsapriv *st=sst;
MP_INT a, b, u, v, tmp, tmp2;
}
static rsa_checksig_fn rsa_sig_check;
-static bool_t rsa_sig_check(void *sst, uint8_t *data, uint32_t datalen,
+static bool_t rsa_sig_check(void *sst, uint8_t *data, int32_t datalen,
cstring_t signature)
{
struct rsapub *st=sst;
beforepoll_fn *before;
afterpoll_fn *after;
void *state;
- uint32_t max_nfds;
- uint32_t nfds;
+ int32_t max_nfds;
+ int32_t nfds;
cstring_t desc;
struct poll_interest *next;
};
static struct poll_interest *reg=NULL;
-static uint32_t total_nfds=10;
+static int32_t total_nfds=10;
static bool_t finished=False;
}
void register_for_poll(void *st, beforepoll_fn *before,
- afterpoll_fn *after, uint32_t max_nfds, cstring_t desc)
+ afterpoll_fn *after, int32_t max_nfds, cstring_t desc)
{
struct poll_interest *i;
/* Configuration file location, for error-reporting */
struct cloc {
cstring_t file;
- uint32_t line;
+ int line;
};
/* Modules export closures, which can be invoked from the configuration file.
/* List-manipulation functions */
extern list_t *list_new(void);
-extern uint32_t list_length(list_t *a);
+extern int32_t list_length(list_t *a);
extern list_t *list_append(list_t *a, item_t *i);
extern list_t *list_append_list(list_t *a, list_t *b);
/* Returns an item from the list (index starts at 0), or NULL */
-extern item_t *list_elem(list_t *l, uint32_t index);
+extern item_t *list_elem(list_t *l, int32_t index);
/* Convenience functions */
extern list_t *new_closure(closure_t *cl);
structures you may require - you can always ask for more in
*nfds_io. */
extern void register_for_poll(void *st, beforepoll_fn *before,
- afterpoll_fn *after, uint32_t max_nfds,
+ afterpoll_fn *after, int32_t max_nfds,
cstring_t desc);
/***** END of scheduling support */
/* RANDOMSRC interface */
/* Return some random data. Returns TRUE for success. */
-typedef bool_t random_fn(void *st, uint32_t bytes, uint8_t *buff);
+typedef bool_t random_fn(void *st, int32_t bytes, uint8_t *buff);
struct random_if {
void *st;
/* RSAPUBKEY interface */
-typedef bool_t rsa_checksig_fn(void *st, uint8_t *data, uint32_t datalen,
+typedef bool_t rsa_checksig_fn(void *st, uint8_t *data, int32_t datalen,
cstring_t signature);
struct rsapubkey_if {
void *st;
/* RSAPRIVKEY interface */
-typedef string_t rsa_makesig_fn(void *st, uint8_t *data, uint32_t datalen);
+typedef string_t rsa_makesig_fn(void *st, uint8_t *data, int32_t datalen);
struct rsaprivkey_if {
void *st;
rsa_makesig_fn *sign;
struct sockaddr_in *dest);
struct comm_if {
void *st;
- uint32_t min_start_pad;
- uint32_t min_end_pad;
+ int32_t min_start_pad;
+ int32_t min_end_pad;
comm_request_notify_fn *request_notify;
comm_release_notify_fn *release_notify;
comm_sendmsg_fn *sendmsg;
particular key material) have a different C type. */
typedef struct transform_inst_if *transform_createinstance_fn(void *st);
-typedef bool_t transform_setkey_fn(void *st, uint8_t *key, uint32_t keylen);
+typedef bool_t transform_setkey_fn(void *st, uint8_t *key, int32_t keylen);
typedef void transform_delkey_fn(void *st);
typedef void transform_destroyinstance_fn(void *st);
/* Returns 0 for 'all is well', any other value for a problem */
struct transform_if {
void *st;
- uint32_t max_start_pad;
- uint32_t max_end_pad;
- uint32_t keylen;
+ int32_t max_start_pad; /* these three are all <<< INT_MAX */
+ int32_t max_end_pad;
+ int32_t keylen;
transform_createinstance_fn *create;
};
#define MAXIMUM_LINK_QUALITY 3
typedef void netlink_link_quality_fn(void *st, uint32_t quality);
typedef void netlink_register_fn(void *st, netlink_deliver_fn *deliver,
- void *dst, uint32_t max_start_pad,
- uint32_t max_end_pad);
+ void *dst, int32_t max_start_pad,
+ int32_t max_end_pad);
typedef void netlink_output_config_fn(void *st, struct buffer_if *buf);
typedef bool_t netlink_check_config_fn(void *st, struct buffer_if *buf);
-typedef void netlink_set_mtu_fn(void *st, uint32_t new_mtu);
+typedef void netlink_set_mtu_fn(void *st, int32_t new_mtu);
struct netlink_if {
void *st;
netlink_register_fn *reg;
/* Returns public key as a malloced hex string */
typedef string_t dh_makepublic_fn(void *st, uint8_t *secret,
- uint32_t secretlen);
+ int32_t secretlen);
/* Fills buffer (up to buflen) with shared secret */
typedef void dh_makeshared_fn(void *st, uint8_t *secret,
- uint32_t secretlen, cstring_t rempublic,
- uint8_t *sharedsecret, uint32_t buflen);
+ int32_t secretlen, cstring_t rempublic,
+ uint8_t *sharedsecret, int32_t buflen);
struct dh_if {
void *st;
- uint32_t len; /* Approximate size of modulus in bytes */
+ int32_t len; /* Approximate size of modulus in bytes */
dh_makepublic_fn *makepublic;
dh_makeshared_fn *makeshared;
};
/* HASH interface */
typedef void *hash_init_fn(void);
-typedef void hash_update_fn(void *st, uint8_t const *buf, uint32_t len);
+typedef void hash_update_fn(void *st, uint8_t const *buf, int32_t len);
typedef void hash_final_fn(void *st, uint8_t *digest);
struct hash_if {
- uint32_t len; /* Hash output length in bytes */
+ int32_t len; /* Hash output length in bytes */
hash_init_fn *init;
hash_update_fn *update;
hash_final_fn *final;
struct cloc loc; /* Where we were defined */
uint8_t *base;
uint8_t *start;
- uint32_t size; /* Size of buffer contents */
- uint32_t len; /* Total length allocated at base */
+ int32_t size; /* Size of buffer contents */
+ int32_t len; /* Total length allocated at base */
};
/***** LOG functions *****/
void serpent_makekey(struct keyInstance *key, int keyLen,
uint8_t *keyMaterial)
{
- uint32_t i,j;
+ int i;
+ uint32_t j;
uint32_t w[132],k[132];
for(i=0; i<keyLen/32; i++)
return ctx;
}
-static void sha1_update(void *sst, uint8_t const *buf, uint32_t len)
+static void sha1_update(void *sst, uint8_t const *buf, int32_t len)
{
SHA1_CTX *ctx=sst;
struct dh_if *dh;
struct hash_if *hash;
- uint32_t setup_retries; /* How many times to send setup packets */
+ int32_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 */
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 *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;
};
{
uint8_t txbuf[DEFAULT_BUFSIZE];
uint8_t *i;
- uint32_t j=0;
+ int32_t j=0;
BUF_ASSERT_USED(buf);
#define PKCS5_MASK 15
-static bool_t transform_setkey(void *sst, uint8_t *key, uint32_t keylen)
+static bool_t transform_setkey(void *sst, uint8_t *key, int32_t keylen)
{
struct transform_inst *ti=sst;
{
struct transform_inst *ti=sst;
uint8_t *padp;
- unsigned padlen;
+ int padlen;
int i;
uint32_t seqnum, skew;
uint8_t iv[16];
struct tun *st=sst;
string_t network, mask, secnetaddr;
struct subnet_list *nets;
- uint32_t i;
+ int32_t i;
int fd=-1;
if (routes->up == routes->kup) return False;
}
/* Convert a MP_INT into a buffer; return length; truncate if necessary */
-uint32_t write_mpbin(MP_INT *a, uint8_t *buffer, uint32_t buflen)
+int32_t write_mpbin(MP_INT *a, uint8_t *buffer, int32_t buflen)
{
char *hb;
int i,j,l;
};
void buffer_assert_free(struct buffer_if *buffer, cstring_t file,
- uint32_t line)
+ int line)
{
if (!buffer->free) {
fatal("BUF_ASSERT_FREE, %s line %d, owned by %s",
}
void buffer_assert_used(struct buffer_if *buffer, cstring_t file,
- uint32_t line)
+ int line)
{
if (buffer->free) {
fatal("BUF_ASSERT_USED, %s line %d, last owned by %s",
}
}
-void buffer_init(struct buffer_if *buffer, uint32_t max_start_pad)
+void buffer_init(struct buffer_if *buffer, int32_t max_start_pad)
{
buffer->start=buffer->base+max_start_pad;
buffer->size=0;
}
-void *buf_append(struct buffer_if *buf, uint32_t amount) {
+void *buf_append(struct buffer_if *buf, int32_t amount) {
void *p;
assert(buf->size <= buf->len - amount);
p=buf->start + buf->size;
return p;
}
-void *buf_prepend(struct buffer_if *buf, uint32_t amount) {
+void *buf_prepend(struct buffer_if *buf, int32_t amount) {
assert(amount <= buf->start - buf->base);
buf->size+=amount;
return buf->start-=amount;
}
-void *buf_unappend(struct buffer_if *buf, uint32_t amount) {
+void *buf_unappend(struct buffer_if *buf, int32_t amount) {
if (buf->size < amount) return 0;
return buf->start+(buf->size-=amount);
}
-void *buf_unprepend(struct buffer_if *buf, uint32_t amount) {
+void *buf_unprepend(struct buffer_if *buf, int32_t amount) {
void *p;
p=buf->start;
buf->start+=amount;
network byte order. */
void buf_append_string(struct buffer_if *buf, cstring_t s)
{
- uint16_t len;
+ size_t len;
len=strlen(s);
/* fixme: if string is longer than 65535, result is a corrupted packet */
memcpy(buf_append(buf,len),s,len);
}
-void buffer_new(struct buffer_if *buf, uint32_t len)
+void buffer_new(struct buffer_if *buf, int32_t len)
{
buf->free=True;
buf->owner=NULL;
#define BUF_FREE(buf) do { (buf)->free=True; } while(0)
extern void buffer_assert_free(struct buffer_if *buffer, cstring_t file,
- uint32_t line);
+ int line);
extern void buffer_assert_used(struct buffer_if *buffer, cstring_t file,
- uint32_t line);
-extern void buffer_new(struct buffer_if *buffer, uint32_t len);
-extern void buffer_init(struct buffer_if *buffer, uint32_t max_start_pad);
-extern void *buf_append(struct buffer_if *buf, uint32_t amount);
-extern void *buf_prepend(struct buffer_if *buf, uint32_t amount);
-extern void *buf_unappend(struct buffer_if *buf, uint32_t amount);
-extern void *buf_unprepend(struct buffer_if *buf, uint32_t amount);
+ int line);
+extern void buffer_new(struct buffer_if *buffer, int32_t len);
+extern void buffer_init(struct buffer_if *buffer, int32_t max_start_pad);
+extern void *buf_append(struct buffer_if *buf, int32_t amount);
+extern void *buf_prepend(struct buffer_if *buf, int32_t amount);
+extern void *buf_unappend(struct buffer_if *buf, int32_t amount);
+extern void *buf_unprepend(struct buffer_if *buf, int32_t amount);
extern void buf_append_string(struct buffer_if *buf, cstring_t s);
extern char *write_mpstring(MP_INT *a);
-extern uint32_t write_mpbin(MP_INT *a, uint8_t *buffer, uint32_t buflen);
+extern int32_t write_mpbin(MP_INT *a, uint8_t *buffer, int32_t buflen);
extern struct log_if *init_log(list_t *loglist);