X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fivac.git;a=blobdiff_plain;f=src%2Fnetwork.h;fp=src%2Fnetwork.h;h=0000000000000000000000000000000000000000;hp=079cea387df6e8cef3cca6113638105deed90702;hb=21a073b6e9d464f3f11dfb290d27341bb4a203b6;hpb=40031b2d692a7b83e437535045ece6c58f8bf31e diff --git a/src/network.h b/src/network.h deleted file mode 100644 index 079cea3..0000000 --- a/src/network.h +++ /dev/null @@ -1,87 +0,0 @@ -/* network.h -- network headers */ - -#ifndef NETWORK_H -#define NETWORK_H - -/* includes */ -#include -#include -#include -#include -#include -#include - -/* net specific includes */ -#include -#include - -/* defines */ -#define MAX_CONNECTIONS 32 -#define MAX_NIC_DEVICE 32 - -#define IP_DIGITS 16 -#define C_IN_USE (1<<0) -#define C_INFO_A (1<<1) -#define C_SOCKET (1<<2) -#define C_ESTABL (1<<3) -#define C_HANGUP (1<<4) - -#define SEND_N_MAX 128 - -#define N_SUCCESS 1 -#define N_ERROR -1 -#define N_E_IN_USE -2 -#define N_E_NO_INFO -3 -#define N_E_CLOSE -4 -#define N_E_CONNECT -5 -#define N_E_NC -6 -#define N_E_ACCEPT -7 -#define N_E_MAXC -8 - -#define N_UDP_WRONG_SENDER -9 - -#define MAX_LISTEN_QUEUE 32 - -/* net specific variables */ -typedef struct s_connection { - int fd; - char ip[IP_DIGITS]; - in_port_t port; - unsigned char status; - unsigned short cap; /* capabilities */ -} t_connection; - -typedef struct s_net { - int l_fd; /* fd for tcp conn */ - int l_udp_fd; /* fd for udp data receive */ - int s_udp_fd; /* fd for udp data send */ - in_port_t l_port; /* tcp port */ - int l_udp_port; /* udp listen port */ - unsigned short cap; - /* limited connections by now -- replaced by list management later */ - int c_count; - t_connection connection[MAX_CONNECTIONS]; - unsigned int sendmask; /* 32 bits for maximum of 32 connections */ - char nic[MAX_NIC_DEVICE]; -} t_net; - -/* function prototypes */ -int network_init(t_net *net); -int network_shutdown(t_net *net); -int network_set_listen_port(t_net *net,in_port_t port); -int network_manage_connection(t_net *net); -int network_connect(t_net *net,int channel); -int network_close(t_net *net,int channel); -int network_close_all(t_net *net); -int network_set_connection_info(t_net *net,int channel,char *ip,int port); -int network_select(t_net *net,int channel); -int network_deselect(t_net *net,int channel); -int network_manage_incoming(t_net *net); -int network_send(int fd,unsigned char *data,int datasize); -int network_receive(int fd,unsigned char *data,int datasize); -int network_udp_listen_init(t_net *net); -int network_udp_receive(t_net *net,int channel, unsigned char *data,int count); -int network_udp_send(t_net *net,int channel, unsigned char *data,int size); -int network_udp_shutdown(t_net *net); - -#endif