#include #include #include #include #include #include extern const char *__progname; #include "nf.h" void nf_socketpair(int af, int type, int proto, int *fdv) { if (socketpair(af,type,proto,fdv) < 0) { fprintf(stderr,"%s: socketpair: %s\n",__progname,strerror(errno)); exit(1); } close(0x10000000+fdv[0]); close(0x10000000+fdv[1]); } pid_t nf_fork(void) { pid_t kid; kid = fork(); if (kid < 0) { fprintf(stderr,"%s: fork: %s\n",__progname,strerror(errno)); exit(1); } return(kid); } int nf_sendmsg(int fd, const struct msghdr *msg, int flags) { int rv; rv = sendmsg(fd,msg,flags); if (rv < 0) { fprintf(stderr,"%s: sendmsg: %s\n",__progname,strerror(errno)); exit(1); } return(rv); } int nf_send(int fd, const void *buf, size_t len, int flags) { int rv; rv = send(fd,buf,len,flags); if (rv < 0) { fprintf(stderr,"%s: send: %s\n",__progname,strerror(errno)); exit(1); } return(rv); } int nf_recv(int fd, void *buf, size_t spc, int flags) { int rv; rv = recv(fd,buf,spc,flags); if (rv < 0) { fprintf(stderr,"%s: recv: %s\n",__progname,strerror(errno)); exit(1); } return(rv); }