#ifndef CORE_NETWORK_H #define CORE_NETWORK_H #include #include /* Easy access to ip fields */ typedef union { struct in_addr inaddr; struct{ unsigned char b4,b3,b2,b1; /* read ip as b1.b2.b3.b4 */ } bytes; } ip_t; /* Describe the current network connection --> All values are in "host order"! <-- */ typedef struct network_s{ unsigned char connected:1; /* 0/1 */ unsigned char wifi_ok:1; int local_sock; /* In config file */ unsigned short local_port; unsigned short serv_base_port; unsigned short serv_real_port; // = serv_base_port + pad_number -1; ip_t serv_ip; } network_t; /* Write ip text into buffer returns 1 ok 0 failed */ extern unsigned char network_ip2str(char* buffer, int size, ip_t ip); /* Init defaults network values */ extern void network_init(network_t* n); /* Connect wifi Return: 1 OK 0 Error */ extern int network_connect(network_t* n); /* Disconnect wifi */ extern void network_disconnect(network_t* n); /* Send a message */ extern void network_send_msg(network_t* n, void* msg, int msglen); /* Process xml atoms */ extern int network_process_xml(void* elem, char* tag, char* content); /* Write xml atoms */ extern void network_write_xml(network_t* n, FILE* out); #endif /* CORE_NETWORK_H */