#ifndef NET_PROXY_H #define NET_PROXY_H #include #include #include "trans.h" #define TSNIF_NP_PORT (5555) enum { TSNIF_NP_UDP_CLIENT = 0x1, TSNIF_NP_UDP_SERVER = 0x2, TSNIF_NP_TCP_CLIENT = 0x4, TSNIF_NP_TCP_SERVER = 0x8, }; enum { TSNIF_NP_PROT_UDP, TSNIF_NP_PROT_TCP, TSNIF_NP_PROT_MAX, }; #define TSNIF_NP_CLIENT (TSNIF_NP_UDP_CLIENT | TSNIF_NP_TCP_CLIENT) #define TSNIF_NP_SERVER (TSNIF_NP_UDP_SERVER | TSNIF_NP_TCP_SERVER) #define TSNIF_NP_UDP (TSNIF_NP_UDP_CLIENT | TSNIF_NP_UDP_SERVER) #define TSNIF_NP_TCP (TSNIF_NP_TCP_CLIENT | TSNIF_NP_TCP_SERVER) struct tsnif_np_args { struct sockaddr_in sa; int flags; }; struct tsnif_udp_client { struct tsnif_term *term; struct sockaddr_in sa; int connected; }; struct tsnif_np_handle { /* udp properties */ int fd_udp; struct tsnif_udp_client udp_client; /* tcp properties */ int fd_tcp; struct tsnif_np_args *args; }; #define TSNIF_NP_FLAGS(h) (h->args->flags) struct tsnif_np_msg { struct trans_msg msg; char data[0]; }; struct tsnif_handle; typedef int(*init_server_t)(struct tsnif_handle*, struct tsnif_np_args *args); typedef int(*init_client_t)(struct tsnif_handle*, struct tsnif_np_args *args); typedef int(*close_t)(struct tsnif_handle*); typedef int(*send_t)(struct tsnif_handle*, struct trans_msg *msg); typedef int(*process_t)(struct tsnif_handle*); struct tsnif_np_prot { init_server_t init_server; init_client_t init_client; close_t close; send_t send; process_t process; }; int tsnif_np_init(struct tsnif_handle *h, struct tsnif_np_args *np); int tsnif_np_fd(struct tsnif_handle *h, fd_set *set); int tsnif_np_process(struct tsnif_handle *h, fd_set *set); int tsnif_np_close(struct tsnif_handle *h); int tsnif_np_send_client(struct tsnif_handle *h, struct trans_msg *msg); int tsnif_np_send_server(struct tsnif_handle *h, struct trans_msg *msg); int tsnif_np_args(struct tsnif_np_args *args, int flag, char *host); int tsnif_np_dispatch(struct tsnif_handle *h, struct trans_msg *msg); #endif /* NET_PROXY_H */