diff options
| author | auric <auric@japegames.com> | 2026-02-21 11:08:36 -0600 |
|---|---|---|
| committer | auric <auric@japegames.com> | 2026-02-21 11:08:36 -0600 |
| commit | 0d706ae72ceefd74053ad6cb0900ecce6cf1f085 (patch) | |
| tree | 6faf7d3919182b8838a6ae69ad1a2a0fac468740 /src/console/rcon.h | |
Add Umbrella 0.1.5
Diffstat (limited to 'src/console/rcon.h')
| -rw-r--r-- | src/console/rcon.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/console/rcon.h b/src/console/rcon.h new file mode 100644 index 0000000..ffcbde7 --- /dev/null +++ b/src/console/rcon.h @@ -0,0 +1,39 @@ +#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 */ |
