summaryrefslogtreecommitdiff
path: root/src/client/binding.h
blob: ea02c980b5b4b6ab8bbe3b8a3917c09990e800a4 (plain)
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
#pragma once

#include "../packet/packet.h"
#include "addr.h"

#include <netinet/in.h>

typedef enum {
    UDP,
    TCP
} BindingType;

typedef struct {
    BindingType type;
    union {
        struct {
            UdpSocket udp;
            SocketAddr clientaddr;
        } udp;
        TcpStream tcp;
    } sock;
} Connection;

bool create_request(BindingType type, SocketAddr* addr, Connection* request);
bool request_packet(Connection* request, Packet* in, Packet* out);
void free_request(Connection* connection);