9 #include <sys/utsname.h>
21 typedef void mes_functype(struct mechdata
**md_r
, int *maxprefix_io
, int *maxsuffix_io
);
22 typedef void mds_functype(struct mechdata
**md_r
);
24 typedef void menc_functype(struct mechdata
*md
, struct buffer
*);
25 typedef const char *mdec_functype(struct mechdata
*md
, struct buffer
*);
29 mes_functype
*encsetup
;
30 mds_functype
*decsetup
;
31 menc_functype
*encode
;
32 mdec_functype
*decode
;
35 extern const struct mechanism
*const mechanismlists
[];
37 /* setup function may call getarg_xxx functions and then
38 * reads/writes key material to/from fd
40 * setup_in function may increase maxprefix and maxsuffix
41 * code functions modify buffer in place
42 * decode function returns message to print
45 const char *getarg_string(void);
46 unsigned long getarg_ulong(void);
48 #define PROGRAM "udptunnel-forwarder"
49 extern char programid
[];
51 void *buf_append(struct buffer
*buf
, size_t amount
);
52 void *buf_prepend(struct buffer
*buf
, size_t amount
);
53 void *buf_unappend(struct buffer
*buf
, size_t amount
); /* may give 0 */
54 void *buf_unprepend(struct buffer
*buf
, size_t amount
); /* may give 0 */
56 void sysfail(const char *msg
);
57 void fail(const char *msg
);
58 void sysdiag(const char *msg
);
59 void diag(const char *msg
);
61 extern const char *const *argv
;
64 void *xmalloc(size_t sz
);
65 void get_random(void *ptr
, size_t sz
);
66 void random_key(void *ptr
, size_t sz
);
67 void write_must(int fd
, const void *p_in
, int sz
, const char *what
);
68 void read_must(int fd
, void *p_in
, int sz
, const char *what
);
70 void arg_assert_fail(const char *msg
);
71 #define arg_assert(v) (v ? (void)0 : arg_assert_fail(#v))
73 #define XMALLOC(variable) ((variable)= xmalloc(sizeof(*(variable))))
75 #define BUF_UNSOMEEND(var,buf,sz,whichend) \
76 do { var= whichend(buf,sz); if (!var) return "message truncated"; } while(0)
77 #define BUF_UNAPPEND(var,buf,sz) BUF_UNSOMEEND(var,buf,sz,buf_unappend)
78 #define BUF_UNPREPEND(var,buf,sz) BUF_UNSOMEEND(var,buf,sz,buf_unprepend)
80 #define STANDARD_MECHANISMLIST(mechstring,filename) \
81 const struct mechanism mechlist_##filename []= { \
82 STANDARD_MECHANISM(mechstring,filename) \
86 #define STANDARD_MECHANISM(mechstring,mechname) \
87 { mechstring, mes_##mechname, mds_##mechname, menc_##mechname, mdec_##mechname },