-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
40 lines (30 loc) · 1.09 KB
/
utils.h
File metadata and controls
40 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef _UTILS_H
#define _UTILS_H
#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <ngtcp2/ngtcp2.h>
#include <openssl/rand.h>
char *format_hex(const uint8_t *s, size_t len);
int resolve_and_connect(const char *host, const char *port,
struct sockaddr *local_addr, size_t *local_addrlen,
struct sockaddr *remote_addr, size_t *remote_addrlen);
int resolve_and_bind(const char *host, const char *port,
struct sockaddr *local_addr, size_t *local_addrlen);
uint64_t timestamp(void);
void log_printf(void *user_data, const char *fmt, ...);
ssize_t recv_packet(int fd, uint8_t *data, size_t data_size,
struct sockaddr *remote_addr, size_t *remote_addrlen);
ssize_t send_packet(int fd, const uint8_t *data, size_t data_size,
struct sockaddr *remote_addr, size_t remote_addrlen);
int gen_random_cid(ngtcp2_cid *cid);
int get_ip_port(struct sockaddr_storage *addr, char *ip, uint16_t *port);
#endif