aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
m---------include/c_headers0
-rw-r--r--include/kv.h1
-rw-r--r--include/packet.c24
-rw-r--r--include/packet.h25
4 files changed, 33 insertions, 17 deletions
diff --git a/include/c_headers b/include/c_headers
-Subproject 8989b7dc005af7960aa66fd99b197a3b0b7a4fb
+Subproject ff8ab43201e5c862003d9353016409c13691562
diff --git a/include/kv.h b/include/kv.h
index ff28ce3..52f27b5 100644
--- a/include/kv.h
+++ b/include/kv.h
@@ -5,3 +5,4 @@
#define KV_SERVER_ADDRESS_INT ((95 << 24) | (164 << 16) | (2 << 8) | (199 << 0))
#endif // JUSTANOTHERCATGIRL_KV_H
+/* vim: set ts=8 noet: */
diff --git a/include/packet.c b/include/packet.c
index a523285..45ebcd1 100644
--- a/include/packet.c
+++ b/include/packet.c
@@ -1,14 +1,17 @@
#include "packet.h"
-i64 const commd_size_lookup[64] = {[CMD_CREATE] = sizeof(struct commd_create),
- [CMD_DELETE] = sizeof(struct commd_delete),
- [CMD_JOIN] = sizeof(struct commd_join),
- [CMD_LEAVE] = sizeof(struct commd_leave),
- [CMD_REGISTER] = sizeof(struct commd_register),
- [CMD_UNREGISTER] = sizeof(struct commd_unregister),
- [CMD_GET_PORT] = sizeof(struct commd_get_port),
- [CMD_GET_CHANNELS] = 0, // You can not get a sizeof(void)
- 0};
+i64 const commd_size_lookup[64] = {
+ [CMD_CREATE] = sizeof(struct commd_create),
+ [CMD_DELETE] = sizeof(struct commd_delete),
+ [CMD_JOIN] = sizeof(struct commd_join),
+ [CMD_LEAVE] = sizeof(struct commd_leave),
+ [CMD_REGISTER] = sizeof(struct commd_register),
+ [CMD_UNREGISTER] = sizeof(struct commd_unregister),
+ [CMD_GET_PORT] = sizeof(struct commd_get_port),
+ [CMD_GET_CHANNELS] = 0, // You can not get a sizeof(void)
+ [CMD_LAST] = -1,
+ 0
+};
u32 system_packet_checksum(struct kv_system_packet *packet)
{
@@ -61,6 +64,9 @@ const char *kv_strerror(enum commd_error e)
return "Not implemented";
case ERR_DO_IT_YOURSELF:
return "You should not have recieved this error. This is either server or network fault";
+ case ERR_TYPE:
+ return "No such command";
}
return "Unknown error";
}
+/* vim: set ts=8 noet: */
diff --git a/include/packet.h b/include/packet.h
index f1b1e60..01c006e 100644
--- a/include/packet.h
+++ b/include/packet.h
@@ -15,6 +15,9 @@
#define KV_PACKET_SIZE 512
+// These macros became obsolete due to log.h header in c_headers
+// TODO: remove
+/*
#ifdef DBG
# define DEBUGF(fmt, ...) fprintf(stderr, "DEBUG: %s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
# define DEBUG(msg) fprintf(stderr, "DEBUG: %s:%d:%s(): " msg, __FILE__, __LINE__, __func__)
@@ -24,6 +27,7 @@
# define DEBUG(fmt)
# define WHERE
#endif
+*/
#ifdef __clang__
# pragma GCC diagnostic ignored "-Wnullability-extension" // SHUT UP I'VE ALREADY PUT IT BEHIND A MACRO
# define NONNULL _Nonnull
@@ -33,6 +37,7 @@
# define NULLABLE
#endif
+
#include <arpa/inet.h>
#include <stddef.h>
#include <rstypes.h>
@@ -76,14 +81,14 @@ u32 system_packet_checksum(struct kv_system_packet *packet);
u8 is_system_packet(struct kv_packet *p);
enum permissions {
- perm_none = 0,
- perm_register_user = 1 << 1,
- perm_unregister_user = 1 << 2,
- perm_add_channel = 1 << 3,
- perm_unadd_channel = 1 << 4,
- perm_join_user = 1 << 5,
- perm_kick_user = 1 << 6,
- perm_admin = 0x7FFFFFFF,
+ PERM_NONE = 0,
+ PERM_REGISTER_USER = 1 << 1,
+ PERM_UNREGISTER_USER = 1 << 2,
+ PERM_ADD_CHANNEL = 1 << 3,
+ PERM_UNADD_CHANNEL = 1 << 4,
+ PERM_JOIN_USER = 1 << 5,
+ PERM_KICK_USER = 1 << 6,
+ PERM_ADMIN = 0x7FFFFFFF,
};
enum commd_error {
@@ -93,6 +98,8 @@ enum commd_error {
ERR_SERV,
// Error in parameters (e.g. nonexistant UID)
ERR_PARAM,
+ // The command does not exist
+ ERR_TYPE,
// Invalid parameters (e.g. not enough params)
ERR_INVAL,
// Access violation
@@ -125,6 +132,7 @@ enum commd_type {
CMD_UNREGISTER,
CMD_GET_PORT,
CMD_GET_CHANNELS,
+ CMD_LAST,
};
// Somehow, this is pretty similar to linux sockaddr.
struct commd {
@@ -192,3 +200,4 @@ u64 ntoh64(u64 a);
const char* kv_strerror(enum commd_error e);
#endif // KV_PACKET_H
+/* vim: set ts=8 noet: */