aboutsummaryrefslogtreecommitdiff
path: root/protocol.h
blob: b038901e9b02a83844de6c5203a3fc62979b1463 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdint.h>  // Provides uint8_t, int8_t, etc.

// client to server messages (commands)

struct Command {
    uint8_t commandType;
    u_int16_t number;
} __attribute__((packed));

struct Hello {
    uint8_t commandType;
    uint16_t udpPort;
} __attribute__((packed));
struct SetStation {
    uint8_t commandType;
    uint16_t stationNumber;
} __attribute__((packed));

// server to client message (replies)
struct Welcome {
    uint8_t replyType;
    uint16_t numStations;
} __attribute__((packed));

struct Reply {
    uint8_t replyType;
    uint8_t stringSize;
    char *string;
} __attribute__((packed));
struct Announce {
    uint8_t replyType;
    uint8_t songnameSize;
    char *songname;
} __attribute__((packed));
struct InvalidCommand {
    uint8_t replyType;
    uint8_t replyStringSize;
    char *replyString;
} __attribute__((packed));