aboutsummaryrefslogtreecommitdiff
path: root/protocol.h
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-09-23 23:10:12 -0400
committersotech117 <michael_foiani@brown.edu>2023-09-23 23:10:12 -0400
commitc055294629f1c3bb8843c65ce5ebff15efc94b7b (patch)
treea22057b62674feb4fe3a243b8cf61688a36f5747 /protocol.h
parent773f64c74c222d20cfb1183fcc235f429ce5370f (diff)
implement extra credit
Diffstat (limited to 'protocol.h')
-rw-r--r--protocol.h31
1 files changed, 17 insertions, 14 deletions
diff --git a/protocol.h b/protocol.h
index aeeaa54..33ffb07 100644
--- a/protocol.h
+++ b/protocol.h
@@ -2,40 +2,43 @@
// client to server messages (commands)
-struct Command {
- uint8_t commandType;
- uint16_t number;
-} __attribute__((packed));
-
struct Hello {
- uint8_t commandType;
+ uint8_t commandType; // 0
uint16_t udpPort;
} __attribute__((packed));
struct SetStation {
- uint8_t commandType;
+ uint8_t commandType; // 1
uint16_t stationNumber;
} __attribute__((packed));
+struct ListStations {
+ uint8_t commandType; // 5
+} __attribute__((packed));
+
// server to client message (replies)
struct Welcome {
- uint8_t replyType;
+ uint8_t replyType; // 2
uint16_t numStations;
} __attribute__((packed));
-struct Reply {
- uint8_t replyType;
- uint8_t stringSize;
-} reply_t __attribute__((packed));
struct Announce {
- uint8_t replyType;
+ uint8_t replyType; // 3
uint8_t songnameSize;
char *songname;
} __attribute__((packed));
+
struct InvalidCommand {
- uint8_t replyType;
+ uint8_t replyType; // 4
uint8_t replyStringSize;
char *replyString;
} __attribute__((packed));
+struct StationInfo {
+ uint8_t replyType; // 6
+ uint8_t infoStringSize;
+ char *infoString;
+} __attribute__((packed));
+
+
int send_all(int sock, char *buf, int *len);
int recv_all(int sock, char *buf, int *len);