X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=secnet.h;h=809b3a75eb608af6c25cfbe8694aa1cd05fe5051;hb=a15faeb2b12e9cc0e3d1352cf4c233fc61c51c1c;hp=9cc22059ad0272e189a4b54d3b5a505d67b7e71f;hpb=90a39563035b70196da9c5bdc7c17a63b64449b0;p=secnet.git diff --git a/secnet.h b/secnet.h index 9cc2205..809b3a7 100644 --- a/secnet.h +++ b/secnet.h @@ -303,16 +303,28 @@ struct rsaprivkey_if { /* COMM interface */ +struct comm_addr { + /* This struct is pure data; in particular comm's clients may + freely copy it. */ + /* Everyone is also guaranteed that all padding is set to zero, ie + that comm_addrs referring to semantically identical peers will + compare equal with memcmp. Anyone who constructs a comm_addr + must start by memsetting it with FILLZERO, or some + equivalent. */ + struct comm_if *comm; + struct sockaddr_in sin; +}; + /* Return True if the packet was processed, and shouldn't be passed to any other potential receivers. */ typedef bool_t comm_notify_fn(void *state, struct buffer_if *buf, - struct sockaddr_in *source); + const struct comm_addr *source); typedef void comm_request_notify_fn(void *commst, void *nst, comm_notify_fn *fn); typedef void comm_release_notify_fn(void *commst, void *nst, comm_notify_fn *fn); typedef bool_t comm_sendmsg_fn(void *commst, struct buffer_if *buf, - struct sockaddr_in *dest); + const struct comm_addr *dest); struct comm_if { void *st; int32_t min_start_pad; @@ -438,7 +450,7 @@ struct dh_if { /* HASH interface */ typedef void *hash_init_fn(void); -typedef void hash_update_fn(void *st, uint8_t const *buf, int32_t len); +typedef void hash_update_fn(void *st, const void *buf, int32_t len); typedef void hash_final_fn(void *st, uint8_t *digest); struct hash_if { int32_t len; /* Hash output length in bytes */ @@ -495,4 +507,9 @@ extern void log_from_fd(int fd, cstring_t prefix, struct log_if *log); /***** END of log functions *****/ +#define STRING2(x) #x +#define STRING(x) STRING2(x) + +#define FILLZERO(obj) (memset(&(obj),0,sizeof((obj)))) + #endif /* secnet_h */