Files
RN-Praxis2/dht.h
T
2025-01-11 03:09:29 +01:00

31 lines
735 B
C

#ifndef DHT_H
#define DHT_H
#include <netinet/in.h>
#include "http.h"
#define NODE_IP_MAX_SIZE 16
extern int server_socket_udp;
typedef struct __attribute__((packed)){
uint8_t message_type;
uint16_t hash_id;
uint16_t node_id;
struct in_addr node_ip;
uint16_t node_port;
}lookup_request;
void lookup_request_init(lookup_request*, uint8_t message_type, uint16_t node_id, in_addr_t node_ip, uint16_t node_port, uint16_t hash_id);
void build_lookup_request(lookup_request*);
void extract_lookup_request(lookup_request*);
int call_network(lookup_request*, in_addr_t, uint16_t);
void clone_lookup_request(lookup_request* dest, lookup_request* source);
void print_lookup_request(lookup_request*);
#endif //DHT_H