X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=blobdiff_plain;f=comm-common.h;h=4aa644a47e46102a28202bc5bca138219e891a08;hp=aa757e1eee851ab52240fab32f0ad4ab4b06581d;hb=94ca562bb14422940ff1986ce8dfca87c222cb59;hpb=32654a316b5925914f5e5f481971d47f9728edab diff --git a/comm-common.h b/comm-common.h index aa757e1..4aa644a 100644 --- a/comm-common.h +++ b/comm-common.h @@ -34,7 +34,7 @@ bool_t comm_notify(struct comm_notify_list *notify, struct buffer_if *buf, void comm_apply(struct commcommon *cc, void *st); #define COMM_APPLY(st,cc,prefix,desc,loc) \ - (st)=safe_malloc(sizeof(*(st)), desc "_apply"); \ + NEW(st); \ (cc)->loc=loc; \ (cc)->cl.description=desc; \ (cc)->ops.sendmsg=prefix##sendmsg; \ @@ -77,6 +77,7 @@ struct udpsocks { /* private for udp_socks_* */ struct udpcommon *uc; /* link to parent, for cfg, notify list, etc. */ struct poll_interest *interest; + const char *desc; }; struct udpcommon { @@ -89,25 +90,31 @@ struct udpcommon { bool_t udp_make_socket(struct udpcommon *uc, struct udpsock *us, int failmsgclass); - /* Fills in us->fd. Logs any errors with lg_[v]perror. */ + /* Caller should have filled in ->addr. Fills in us->fd, + ->experienced; updates ->addr. Logs any errors with lg_[v]perror. */ +bool_t udp_import_socket(struct udpcommon *uc, struct udpsock *us, + int failmsgclass, int fd); + /* Like udp_make_socket, but caller provides fd. fd is not closed + on error */ void udp_destroy_socket(struct udpcommon *uc, struct udpsock *us); /* Idempotent. No errors are possible. */ const char *af_name(int af); void udp_sock_experienced(struct log_if *lg, struct udpcommon *uc, - const char *socksdesc, struct udpsock *us, - bool_t recvsend, int af /* 0 means any */, + struct udpsocks *socks, struct udpsock *us, + const union iaddr *dest, int af /* 0 means any */, int r, int errnoval); -void udp_socks_register(struct udpcommon *uc, struct udpsocks *socks); +void udp_socks_register(struct udpcommon *uc, struct udpsocks *socks, + const char *desc); void udp_socks_deregister(struct udpcommon *uc, struct udpsocks *socks); void udp_socks_childpersist(struct udpcommon *uc, struct udpsocks *socks); #define UDP_APPLY_STANDARD(st,uc,desc) \ (uc)->use_proxy=False; \ (uc)->authbind=dict_read_string(d,"authbind",False,"udp",(uc)->cc.loc); \ - (uc)->port=dict_read_number(d,"port",True,"udp",(uc)->cc.loc,0) + (uc)->port=dict_read_number(d,"port",False,"udp",(uc)->cc.loc,0) /* void UDP_APPLY_STANDARD(SOMETHING *st, struct udpcommon *uc, * const char *desc); * // Expects in scope: dict_t *d=...; as from COMM_APPLY_STANDARD