mirror of
https://github.com/Tiiffi/mcrcon.git
synced 2025-10-27 11:21:07 -04:00
Compare commits
2 Commits
4488127350
...
427fd206ca
| Author | SHA1 | Date | |
|---|---|---|---|
| 427fd206ca | |||
| 1a4010cbba |
31
mcrcon.c
31
mcrcon.c
@ -57,11 +57,16 @@
|
||||
#define RCON_AUTH_RESPONSE 2
|
||||
#define RCON_PID 0xBADC0DE
|
||||
|
||||
#define DATA_BUFFSIZE 4096
|
||||
/* NOTE: This is confusing. What is the real max packet size?
|
||||
* Are null bytes included? Are both null bytes included?
|
||||
* Perhaps payload end indicator is uin16_t with zero value?
|
||||
*/
|
||||
#define DATA_BUFFSIZE 4098 // 2 bytes extra over 4096
|
||||
#define MAX_PACKET_SIZE 4106
|
||||
#define MIN_PACKET_SIZE 10
|
||||
|
||||
// rcon packet structure
|
||||
// rcon packet structure,
|
||||
// NOTE(Tiiffi): Alignment problem!
|
||||
typedef struct _rc_packet {
|
||||
int32_t size;
|
||||
int32_t id;
|
||||
@ -69,7 +74,29 @@ typedef struct _rc_packet {
|
||||
char data[DATA_BUFFSIZE];
|
||||
// ignoring string2 for now
|
||||
} rc_packet;
|
||||
// __attribute__((packed))
|
||||
|
||||
/* TODO(Tiiffi):
|
||||
*
|
||||
* Correct packet structure is propably something like this:
|
||||
*
|
||||
* +---------------------------+
|
||||
* | Size (4 bytes, int) | Total packet size (excluding this field)
|
||||
* +---------------------------+
|
||||
* | ID (4 bytes, int) |
|
||||
* +---------------------------+
|
||||
* | Type (4 bytes, int) |
|
||||
* +---------------------------+
|
||||
* | Payload (variable length) | Command or response string (up to 4096 bytes)
|
||||
* | (null-terminated string) |
|
||||
* +---------------------------+
|
||||
* | Null Terminator (2 bytes, | 16-bit integer set to zero (0x0000)
|
||||
* | 16-bit int) | Could be also interpreted as two null bytes
|
||||
* +---------------------------+
|
||||
*
|
||||
* Maximum size 4110 including size field, 4106 excluding size field.
|
||||
* Take care with the aligment!
|
||||
*/
|
||||
|
||||
// ===================================
|
||||
// FUNCTION DEFINITIONS
|
||||
|
||||
Reference in New Issue
Block a user