#ifndef NETWORK_H #define NETWORK_H #include #include #include #include #include #include #include #include #include typedef struct packet packet; typedef struct cmd cmd; typedef struct cmd_header cmd_header; struct cmd_header { uint32_t size; /* Size of command, in bytes, including command header. */ uint16_t magic; /* Magic Number. Must always be 0x1488. */ uint16_t id; /* Command ID. */ }; struct cmd { cmd_header header; /* Command Header. */ uint8_t data[]; /* Command data. */ }; struct packet { uint32_t size; /* Size of packet, in bytes. */ cmd cmd; /* Command. */ }; extern const char *addr_to_str(struct sockaddr *sa, socklen_t len); extern struct sockaddr *get_sock_addr(int socket); extern int create_socket(struct sockaddr *sa, size_t sock_len); #endif