aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorjustanothercatgirl <sotov2070@gmail.com>2024-06-30 23:54:36 +0300
committerjustanothercatgirl <sotov2070@gmail.com>2024-06-30 23:54:36 +0300
commit0cd383b2c444936dc2290c850c02a0cae11187cd (patch)
tree85805bb2de7b9b942c7de9bba430f6275ede01bf /include
parentb9251a3c950e75f0d69d5799da42d06dd3e41a63 (diff)
Updated C headers library
Diffstat (limited to 'include')
m---------include/c_headers0
-rw-r--r--include/packet.c5
-rw-r--r--include/packet.h25
3 files changed, 11 insertions, 19 deletions
diff --git a/include/c_headers b/include/c_headers
-Subproject aeaf84ff54a7921195cda875492b7a22f8b0a94
+Subproject ebad5ad23dc6893b0fb75ba04aa961a25a532b5
diff --git a/include/packet.c b/include/packet.c
index db20a12..5f551de 100644
--- a/include/packet.c
+++ b/include/packet.c
@@ -5,8 +5,3 @@ unsigned int system_packet_checksum(struct kv_system_packet *packet) {
(packet->operation_id | (177013 << 10));
}
-int __user_cmp(const void* a, const void* b) {
- struct user *_a = (struct user*)a,
- *_b = (struct user*)b;
- return _a->id - _b->id;
-}
diff --git a/include/packet.h b/include/packet.h
index 224469e..4e73040 100644
--- a/include/packet.h
+++ b/include/packet.h
@@ -1,6 +1,7 @@
#ifndef KV_PACKET_H
#define KV_PACKET_H
+
#define KV_PACKET_SIZE 512
#ifdef DEBUG
@@ -11,29 +12,25 @@
#endif
enum system_operation {
- do_nothing = 0,
- join_channel = -1,
- leave_channel = -2,
- acknowledgement = -4,
-};
-struct user {
- unsigned int ip;
- unsigned short port;
- int id;
-};
-struct channel_handle {
- int sockfd;
- struct user* users;
+ keepalive = (int) 0x80000000, // -2^31
+ join_channel, // 1 - 2^31
+ leave_channel, // 2 - 2^31
+ acknowledgement, // 3 - 2^31
};
+
struct kv_packet {
int id;
unsigned char data[KV_PACKET_SIZE - sizeof(unsigned int)];
};
struct kv_system_packet {
+ // as in system_operation enum.
int operation_id;
+ // could be ignored
int user_id;
+ // calculated with system_packet_checksum function
unsigned int checksum;
- unsigned char sentinel[KV_PACKET_SIZE - 4 * sizeof(int) - sizeof(short)];
+
+ unsigned char sentinel[KV_PACKET_SIZE - 3 * sizeof(int)];
};
unsigned int system_packet_checksum(struct kv_system_packet *packet);