Rev | Line | |
---|
[457] | 1 | #pragma once
|
---|
| 2 |
|
---|
| 3 | #include <stdlib.h>
|
---|
| 4 | #include <stdio.h>
|
---|
| 5 | #define DDrStartupMessage printf
|
---|
| 6 |
|
---|
| 7 | #include <string.h>
|
---|
| 8 | #include <stdbool.h>
|
---|
| 9 | #include <stdint.h>
|
---|
| 10 |
|
---|
[460] | 11 | #define thread __thread
|
---|
| 12 |
|
---|
[457] | 13 | #ifdef WIN32
|
---|
| 14 | #include <winsock2.h>
|
---|
| 15 | #include "Flatline_Win32.h"
|
---|
| 16 | #else
|
---|
| 17 | #include <sys/ioctl.h>
|
---|
| 18 | #include <sys/types.h>
|
---|
| 19 | #include <sys/socket.h>
|
---|
| 20 | #include <unistd.h>
|
---|
| 21 | #include <stropts.h>
|
---|
| 22 | #include <arpa/inet.h>
|
---|
| 23 | #include <netinet/in.h>
|
---|
| 24 |
|
---|
| 25 | #define NetPlatform_Initalize() /* */
|
---|
| 26 | #define NetPlatform_Shutdown() /* */
|
---|
| 27 | #define closesocket close
|
---|
| 28 | #define ioctlsocket ioctl
|
---|
| 29 | #endif
|
---|
| 30 |
|
---|
[460] | 31 | #define pad1_size (sizeof(int64_t) - sizeof(short))
|
---|
| 32 | #define pad2_size (128 - (sizeof(short) + pad1_size + sizeof(int64_t)))
|
---|
| 33 |
|
---|
| 34 | typedef struct {
|
---|
| 35 | short ss_family;
|
---|
| 36 | char pad1[pad1_size];
|
---|
| 37 | uint64_t pad64;
|
---|
| 38 | char pad2[pad2_size];
|
---|
| 39 | } sockaddr_storage;
|
---|
| 40 |
|
---|
[457] | 41 | typedef struct sockaddr sockaddr;
|
---|
| 42 | typedef struct sockaddr_in sockaddr_in;
|
---|
[483] | 43 | typedef sockaddr_storage sockaddr_in6;
|
---|
[457] | 44 |
|
---|
[460] | 45 | bool NetUDPServer_Listen(uint16_t port, bool (*packet_callback)(char* data, int datalen, int from));
|
---|
[483] | 46 | bool NetUDPServer_Send(sockaddr* address, char* data, int datalen);
|
---|
[459] | 47 |
|
---|
| 48 | int NetUDPSocket_Create(uint16_t port);
|
---|
[483] | 49 | bool NetUDPSocket_Send(int socket, const sockaddr* address, const char* data, int datalen);
|
---|
[459] | 50 | void NetUDPSocket_Close(int sock);
|
---|
| 51 |
|
---|
[460] | 52 | typedef struct {
|
---|
| 53 | char signature[8];
|
---|
| 54 | uint16_t protocol_version;
|
---|
| 55 | char data[0];
|
---|
| 56 | } handshake_packet;
|
---|
| 57 |
|
---|
| 58 | typedef struct {
|
---|
| 59 | char country[2];
|
---|
| 60 | char name[256];
|
---|
| 61 | } connect_send; //signature="CONNECT\0"
|
---|
| 62 |
|
---|
| 63 | typedef struct {
|
---|
| 64 | char name[256];
|
---|
| 65 | uint32_t numplayers; //signature="STATUS\0\0"
|
---|
| 66 | } status_recv;
|
---|
| 67 |
|
---|
| 68 |
|
---|
[483] | 69 | bool FLrServer_PacketCallback(char* data, int datalen, int from);
|
---|
| 70 | bool FLrServer_Run();
|
---|
Note:
See
TracBrowser
for help on using the repository browser.