summaryrefslogtreecommitdiff
path: root/src/console/rcon.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/console/rcon.h')
-rw-r--r--src/console/rcon.h39
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 */