42 lines
1.0 KiB
C
42 lines
1.0 KiB
C
/**
|
|
* Copyright (c) 2025 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "error/error.h"
|
|
|
|
typedef struct packet_s packet_t;
|
|
|
|
typedef enum {
|
|
PACKET_DISCONNECT_REASON_UNKNOWN = 0,
|
|
PACKET_DISCONNECT_REASON_INVALID_VERSION = 1,
|
|
PACKET_DISCONNECT_REASON_MALFORMED_PACKET = 2,
|
|
PACKET_DISCONNECT_REASON_SERVER_FULL = 3,
|
|
PACKET_DISCONNECT_REASON_SERVER_SHUTDOWN = 4,
|
|
} packetdisconnectreason_t;
|
|
|
|
typedef struct {
|
|
packetdisconnectreason_t reason;
|
|
} packetdisconnect_t;
|
|
|
|
/**
|
|
* Creates a disconnect packet.
|
|
*
|
|
* @param packet Pointer to the packet structure to initialize.
|
|
* @param reason The reason for the disconnect.
|
|
*/
|
|
void packetDisconnectCreate(
|
|
packet_t *packet,
|
|
const packetdisconnectreason_t reason
|
|
);
|
|
|
|
/**
|
|
* Handles a disconnect packet received FROM a server INTO a client.
|
|
*
|
|
* @param packet Pointer to the packet structure to handle.
|
|
* @return ERROR_OK on success, or an error code on failure.
|
|
*/
|
|
errorret_t packetDisconnectClient(packet_t *packet); |