aboutsummaryrefslogtreecommitdiff
path: root/src/rcon.h
blob: 0d518d00df4682d9aab4c10e55cb1a331b81cf21 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * src/rcon.h
 * (c) 2020 Jonas Gunz <himself@jonasgunz.de>
 * License: MIT
*/

/*
 * Length 	int 	Length of remainder of packet
 * Request ID 	int 	Client-generated ID
 * Type 	int 	3 for login, 2 to run a command, 0 for a multi-packet response
 * Payload 	byte[] 	ASCII text
 * 2-byte pad 	byte^2 	Two null bytes
 *
 * sizeof int: 4B
 * */

#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#define RCON_LOGIN	3
#define RCON_LOLGINFAIL	-1
#define RCON_COMMAND	2
#define RCON_RESPONSE	0

#define RCON_RECV_PKGSIZE 4110
#define RCON_SEND_PKGSIZE 1460

typedef struct rcon_packet_s {
	int32_t length;
	int32_t id;
	int32_t type;
	char*	payload;
	uint32_t payload_len;
} rcon_packet_t;

int rcon_parse_packet ( rcon_packet_t* _packet, char* _buffer, uint32_t _len );

int rcon_construct_packet ( char* _buffer, uint32_t _len, rcon_packet_t* _packet );

char* rcon_strerror ( int _errno );