#ifndef UMBRELLA_RCON_H #define UMBRELLA_RCON_H /* * Valve RCON protocol implementation. * https://developer.valvesoftware.com/wiki/Source_RCON_Protocol * * RCON uses a simple TCP framing: * [int32 size][int32 id][int32 type][string body][null][null] * * Types: * SERVERDATA_AUTH = 3 * SERVERDATA_AUTH_RESPONSE = 2 * SERVERDATA_EXECCOMMAND = 2 (same value as AUTH_RESPONSE — context-dependent) * SERVERDATA_RESPONSE_VALUE = 0 */ #define RCON_AUTH_REQUEST 3 #define RCON_AUTH_RESPONSE 2 #define RCON_EXEC_REQUEST 2 #define RCON_EXEC_RESPONSE 0 /* * rcon_exec: connect to an RCON server, authenticate, run a command, * collect the response, and disconnect. * * host - server hostname or IP * port - RCON port (usually 27015) * password - RCON password * command - command string to execute * response - output buffer * resp_len - size of response buffer * * Returns 0 on success, -1 on failure. */ int rcon_exec(const char *host, int port, const char *password, const char *command, char *response, int resp_len); #endif /* UMBRELLA_RCON_H */