extern int sys_cmd(const char *file, const char *argc, ...);
+extern uint64_t now_global;
+extern struct timeval tv_now_global;
+
+static const uint64_t *const now = &now_global;
+static const struct timeval *const tv_now = &tv_now_global;
+
+/* "now" is current program time, in milliseconds. It is derived
+ from tv_now. Both are provided by the event loop. */
+
/***** END of utility functions *****/
/***** SCHEDULING support */
-/* "now" is current program time, in milliseconds. It is derived
- (once) from tv_now. If nfds_io is insufficient for your needs, set
- it to the required number and return ERANGE. timeout is in milliseconds;
- if it is too high then lower it. It starts at -1 (==infinite) */
+/* If nfds_io is insufficient for your needs, set it to the required
+ number and return ERANGE. timeout is in milliseconds; if it is too
+ high then lower it. It starts at -1 (==infinite) */
typedef int beforepoll_fn(void *st, struct pollfd *fds, int *nfds_io,
- int *timeout_io, const struct timeval *tv_now,
- uint64_t *now);
-typedef void afterpoll_fn(void *st, struct pollfd *fds, int nfds,
- const struct timeval *tv_now, uint64_t *now);
+ int *timeout_io);
+typedef void afterpoll_fn(void *st, struct pollfd *fds, int nfds);
/* Register interest in the main loop of the program. Before a call
to poll() your supplied beforepoll function will be called. After
/* 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;
/* 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 */
/***** END of log functions *****/
+#define STRING2(x) #x
+#define STRING(x) STRING2(x)
+
+#define FILLZERO(obj) (memset(&(obj),0,sizeof((obj))))
+
#endif /* secnet_h */