recreate y_socket_t repo
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#ifndef __Y_NODE_T_H__C
|
||||
#define __Y_NODE_T_H__C
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
//#include "y_socket_t/y_socket_t.h"
|
||||
#include "list_t/list_t.h"
|
||||
|
||||
|
||||
typedef struct y_node_t{
|
||||
//char *id;
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t addr_len;
|
||||
} y_NODE_T;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GENERATE_LIST_ALL(y_NODE_T)
|
||||
|
||||
void init_len_y_NODE_T(y_NODE_T *node);
|
||||
void init_len_list_y_NODE_T(struct main_list_y_NODE_T *listNodes);
|
||||
|
||||
int y_NODE_T_cmp(y_NODE_T nodeA, y_NODE_T nodeB);
|
||||
|
||||
struct list_y_NODE_T * search_node_in_list_y_NODE_T(struct main_list_y_NODE_T *listNodes, y_NODE_T node);
|
||||
|
||||
#endif /* __Y_NODE_T_H__C */
|
||||
@@ -0,0 +1,52 @@
|
||||
#ifndef Y_SOCKET_T_H__C
|
||||
#define Y_SOCKET_T_H__C
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
//#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
//#include <fcntl.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
#include "y_socket_t/y_node_t.h"
|
||||
|
||||
#define BUF_SIZE 500
|
||||
|
||||
#define type4
|
||||
#define type6 6
|
||||
|
||||
enum ipVersions{
|
||||
v4,v6,nbIpVersion
|
||||
};
|
||||
|
||||
extern const int af_array[nbIpVersion];//={AF_INET, AF_INET6};
|
||||
|
||||
struct y_socket_t{
|
||||
struct pollfd fds[nbIpVersion];
|
||||
char * port;
|
||||
struct main_list_y_NODE_T nodes;
|
||||
|
||||
};
|
||||
|
||||
struct y_socket_t * y_socket_create(char * port);
|
||||
|
||||
void y_socket_free(struct y_socket_t *socket);
|
||||
|
||||
// type = nothing if v4, 6 if v6
|
||||
#define GET_IN_type_ADDR(PointerSockAddr,type) \
|
||||
((struct sockaddr_in##type *)(PointerSockAddr))->sin##type##_addr.s##type##_addr
|
||||
|
||||
|
||||
|
||||
#endif /* Y_SOCKET_T_H__C */
|
||||
Reference in New Issue
Block a user