From fc638c7f13690b107a9d80f4e97e0cb798391638 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Wed, 26 Jan 2022 23:03:12 -0500 Subject: Initial commit; added example mp3 files and reference version. --- .gitignore | 5 +++++ mp3/Beethoven-SymphonyNo5.mp3 | Bin 0 -> 6659043 bytes mp3/DukeEllington-Caravan.mp3 | Bin 0 -> 5713920 bytes mp3/FX-Impact193.mp3 | Bin 0 -> 82382 bytes mp3/ManchurianCandidates-Breakin.mp3 | Bin 0 -> 6033240 bytes mp3/ManchurianCandidates-TwentyEightHouse.mp3 | Bin 0 -> 5700127 bytes mp3/U2-StuckInAMoment.mp3 | Bin 0 -> 4337708 bytes mp3/VanillaIce-IceIceBaby.mp3 | Bin 0 -> 4264615 bytes reference/snowcast_control | Bin 0 -> 29144 bytes reference/snowcast_listener | Bin 0 -> 21576 bytes reference/snowcast_server | Bin 0 -> 40424 bytes 11 files changed, 5 insertions(+) create mode 100644 .gitignore create mode 100644 mp3/Beethoven-SymphonyNo5.mp3 create mode 100644 mp3/DukeEllington-Caravan.mp3 create mode 100644 mp3/FX-Impact193.mp3 create mode 100644 mp3/ManchurianCandidates-Breakin.mp3 create mode 100644 mp3/ManchurianCandidates-TwentyEightHouse.mp3 create mode 100644 mp3/U2-StuckInAMoment.mp3 create mode 100644 mp3/VanillaIce-IceIceBaby.mp3 create mode 100755 reference/snowcast_control create mode 100755 reference/snowcast_listener create mode 100755 reference/snowcast_server diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fe83c75 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*~ +\#*# +*.o + +.DS_Store diff --git a/mp3/Beethoven-SymphonyNo5.mp3 b/mp3/Beethoven-SymphonyNo5.mp3 new file mode 100644 index 0000000..33fb0f9 Binary files /dev/null and b/mp3/Beethoven-SymphonyNo5.mp3 differ diff --git a/mp3/DukeEllington-Caravan.mp3 b/mp3/DukeEllington-Caravan.mp3 new file mode 100644 index 0000000..be08489 Binary files /dev/null and b/mp3/DukeEllington-Caravan.mp3 differ diff --git a/mp3/FX-Impact193.mp3 b/mp3/FX-Impact193.mp3 new file mode 100644 index 0000000..48950f0 Binary files /dev/null and b/mp3/FX-Impact193.mp3 differ diff --git a/mp3/ManchurianCandidates-Breakin.mp3 b/mp3/ManchurianCandidates-Breakin.mp3 new file mode 100644 index 0000000..d5ff1d5 Binary files /dev/null and b/mp3/ManchurianCandidates-Breakin.mp3 differ diff --git a/mp3/ManchurianCandidates-TwentyEightHouse.mp3 b/mp3/ManchurianCandidates-TwentyEightHouse.mp3 new file mode 100644 index 0000000..11a2342 Binary files /dev/null and b/mp3/ManchurianCandidates-TwentyEightHouse.mp3 differ diff --git a/mp3/U2-StuckInAMoment.mp3 b/mp3/U2-StuckInAMoment.mp3 new file mode 100644 index 0000000..0908a8c Binary files /dev/null and b/mp3/U2-StuckInAMoment.mp3 differ diff --git a/mp3/VanillaIce-IceIceBaby.mp3 b/mp3/VanillaIce-IceIceBaby.mp3 new file mode 100644 index 0000000..732d19d Binary files /dev/null and b/mp3/VanillaIce-IceIceBaby.mp3 differ diff --git a/reference/snowcast_control b/reference/snowcast_control new file mode 100755 index 0000000..fcb60c5 Binary files /dev/null and b/reference/snowcast_control differ diff --git a/reference/snowcast_listener b/reference/snowcast_listener new file mode 100755 index 0000000..ae9f62b Binary files /dev/null and b/reference/snowcast_listener differ diff --git a/reference/snowcast_server b/reference/snowcast_server new file mode 100755 index 0000000..43ce287 Binary files /dev/null and b/reference/snowcast_server differ -- cgit v1.2.3-70-g09d2 From 7f30241e409ca0f880c111948d16347e18b11cc8 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Sat, 29 Jan 2022 16:58:24 -0500 Subject: Added linked list file; updated binaries. --- reference/snowcast_control | Bin 29144 -> 14600 bytes reference/snowcast_listener | Bin 21576 -> 14496 bytes reference/snowcast_server | Bin 40424 -> 18816 bytes util/list.h | 137 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 util/list.h diff --git a/reference/snowcast_control b/reference/snowcast_control index fcb60c5..c1c7e68 100755 Binary files a/reference/snowcast_control and b/reference/snowcast_control differ diff --git a/reference/snowcast_listener b/reference/snowcast_listener index ae9f62b..ef27eda 100755 Binary files a/reference/snowcast_listener and b/reference/snowcast_listener differ diff --git a/reference/snowcast_server b/reference/snowcast_server index 43ce287..fc5f2c4 100755 Binary files a/reference/snowcast_server and b/reference/snowcast_server differ diff --git a/util/list.h b/util/list.h new file mode 100644 index 0000000..a545fb2 --- /dev/null +++ b/util/list.h @@ -0,0 +1,137 @@ +#ifndef __LIST_H__ +#define __LIST_H__ + +#include + +/* +** Generic circular doubly linked list implementation. +** +** list_t is the head of the list. +** list_link_t should be included in structures which want to be +** linked on a list_t. +** +** All of the list functions take pointers to list_t and list_link_t +** types, unless otherwise specified. +** +** list_init(list) initializes a list_t to an empty list. +** +** list_empty(list) returns 1 iff the list is empty. +** +** Insertion functions. +** list_insert_head(list, link) inserts at the front of the list. +** list_insert_tail(list, link) inserts at the end of the list. +** list_insert_before(olink, nlink) inserts nlink before olink in list. +** +** Removal functions. +** Head is list->l_next. Tail is list->l_prev. +** The following functions should only be called on non-empty lists. +** list_remove(link) removes a specific element from the list. +** list_remove_head(list) removes the first element. +** list_remove_tail(list) removes the last element. +** +** Item accessors. +** list_item(link, type, member) given a list_link_t* and the name +** of the type of structure which contains the list_link_t and +** the name of the member corresponding to the list_link_t, +** returns a pointer (of type "type*") to the item. +** +** To iterate over a list, +** +** list_link_t *link; +** for (link = list->l_next; +** link != list; link = link->l_next) +** ... +** +** Or, use the macros, which will work even if you list_remove() the +** current link: +** +** type iterator; +** list_iterate_begin(list, iterator, type, member) { +** ... use iterator ... +** } list_iterate_end; +*/ + +typedef struct llist { + struct llist *l_next; + struct llist *l_prev; +} list_t, list_link_t; + +#define list_init(list) \ + (list)->l_next = (list)->l_prev = (list); + +#define list_link_init(link) \ + (link)->l_next = (link)->l_prev = NULL; + +#define list_empty(list) \ + ((list)->l_next == (list)) + +#define list_insert_before(old, new) \ + do { \ + list_link_t *prev = (new); \ + list_link_t *next = (old); \ + prev->l_next = next; \ + prev->l_prev = next->l_prev; \ + next->l_prev->l_next = prev; \ + next->l_prev = prev; \ + } while(0) + +#define list_insert_head(list, link) \ + list_insert_before((list)->l_next, link) + +#define list_insert_tail(list, link) \ + list_insert_before(list, link) + +#define list_remove(link) \ + do { \ + list_link_t *ll = (link); \ + list_link_t *prev = ll->l_prev; \ + list_link_t *next = ll->l_next; \ + prev->l_next = next; \ + next->l_prev = prev; \ + ll->l_next = ll->l_prev = 0; \ + } while(0) + +#define list_remove_head(list) \ + list_remove((list)->l_next) + +#define list_remove_tail(list) \ + list_remove((list)->l_prev) + +#define list_item(link, type, member) \ + (type*)((char*)(link) - offsetof(type, member)) + +#define list_head(list, type, member) \ + list_item((list)->l_next, type, member) + +#define list_tail(list, type, member) \ + list_item((list)->l_prev, type, member) + +#define list_iterate_begin(list, var, type, member) \ + do { \ + list_link_t *__link; \ + list_link_t *__next; \ + for (__link = (list)->l_next; \ + __link != (list); \ + __link = __next) { \ + var = list_item(__link, type, member); \ + __next = __link->l_next; + +#define list_iterate_end() \ + } \ + } while(0) + +#define list_iterate_reverse_begin(list, var, type, member) \ + do { \ + list_link_t *__link; \ + list_link_t *__prev; \ + for (__link = (list)->l_prev; \ + __link != (list); \ + __link = __prev) { \ + var = list_item(__link, type, member); \ + __prev = __link->l_prev; + +#define list_iterate_reverse_end() \ + } \ + } while(0) + +#endif /* __LIST_H__ */ -- cgit v1.2.3-70-g09d2 From d571b197ff5c0cc43f81a8fab8e7da8fe4a01275 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Tue, 13 Sep 2022 12:26:53 -0400 Subject: Added arm64 versions of reference binaries. --- reference/arm64/snowcast_control | Bin 0 -> 1873112 bytes reference/arm64/snowcast_listener | Bin 0 -> 1544472 bytes reference/arm64/snowcast_server | Bin 0 -> 2004920 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100755 reference/arm64/snowcast_control create mode 100755 reference/arm64/snowcast_listener create mode 100755 reference/arm64/snowcast_server diff --git a/reference/arm64/snowcast_control b/reference/arm64/snowcast_control new file mode 100755 index 0000000..0f2ceaf Binary files /dev/null and b/reference/arm64/snowcast_control differ diff --git a/reference/arm64/snowcast_listener b/reference/arm64/snowcast_listener new file mode 100755 index 0000000..3991c31 Binary files /dev/null and b/reference/arm64/snowcast_listener differ diff --git a/reference/arm64/snowcast_server b/reference/arm64/snowcast_server new file mode 100755 index 0000000..587da32 Binary files /dev/null and b/reference/arm64/snowcast_server differ -- cgit v1.2.3-70-g09d2 From cf661d7df59abfaa1b998d99a6d3a647c6777abc Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Wed, 28 Sep 2022 01:40:57 -0400 Subject: Updated reference binaries. --- reference/snowcast_control | Bin 14600 -> 1815928 bytes reference/snowcast_listener | Bin 14496 -> 1491352 bytes reference/snowcast_server | Bin 18816 -> 2005080 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/reference/snowcast_control b/reference/snowcast_control index c1c7e68..f64b016 100755 Binary files a/reference/snowcast_control and b/reference/snowcast_control differ diff --git a/reference/snowcast_listener b/reference/snowcast_listener index ef27eda..34a542c 100755 Binary files a/reference/snowcast_listener and b/reference/snowcast_listener differ diff --git a/reference/snowcast_server b/reference/snowcast_server index fc5f2c4..d61d179 100755 Binary files a/reference/snowcast_server and b/reference/snowcast_server differ -- cgit v1.2.3-70-g09d2 From 6772405e1560fed367fac4f774f7d40b0b3ec6a5 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Fri, 1 Sep 2023 18:20:11 -0400 Subject: Added ARM64 reference binaries and snowcast dissector. --- reference/arm64/snowcast_control | Bin 1873112 -> 1881144 bytes reference/arm64/snowcast_listener | Bin 1544472 -> 1551576 bytes reference/arm64/snowcast_server | Bin 2004920 -> 2078616 bytes util/snowcast-dissector/README.md | 68 ++++++++++++++++++ util/snowcast-dissector/cs168_snowcast.lua | 107 +++++++++++++++++++++++++++++ 5 files changed, 175 insertions(+) create mode 100644 util/snowcast-dissector/README.md create mode 100644 util/snowcast-dissector/cs168_snowcast.lua diff --git a/reference/arm64/snowcast_control b/reference/arm64/snowcast_control index 0f2ceaf..4336ed0 100755 Binary files a/reference/arm64/snowcast_control and b/reference/arm64/snowcast_control differ diff --git a/reference/arm64/snowcast_listener b/reference/arm64/snowcast_listener index 3991c31..0ddb872 100755 Binary files a/reference/arm64/snowcast_listener and b/reference/arm64/snowcast_listener differ diff --git a/reference/arm64/snowcast_server b/reference/arm64/snowcast_server index 587da32..5d9a380 100755 Binary files a/reference/arm64/snowcast_server and b/reference/arm64/snowcast_server differ diff --git a/util/snowcast-dissector/README.md b/util/snowcast-dissector/README.md new file mode 100644 index 0000000..a62522e --- /dev/null +++ b/util/snowcast-dissector/README.md @@ -0,0 +1,68 @@ +# CS1680 Snowcast Dissector + +THis directory contains a dissector (also known as a decoder) for the Snowcast +protocol implementation for CS168. + +## Installation Instructions + +The dissector is provided as a Lua script in this directory. For security +reasons, Wireshark does not run Lua scripts when run as root--therefore, you +must ensure that you are using Wireshark as your local user, not with root or +sudo. To run wireshark as a standard user, make sure your user is added to the +`wireshark` group. If you are using the provided VM, the the vagrant user is +already in the wireshark group. However, if you are running Wireshark on your +own system, you will need to configure this yourself. + +Once you have Wireshark running as your user. Add the dissector to Wireshark, +by copying the script into your plugins directory. + +To do this: + + 1. Run wireshark as your user (**not with root or sudo**). + 2. Open Wireshark's Help menu and select "About Wireshark". + 3. In the folders tab, find the entry "Personal Lua Plugins". For example: + `~/.config/wireshark/plugins` + 4. Copy the script to this directory (if it doesn't exist, create it) and + restart wireshark + 5. Open the "About Wireshark" window again and look in the Plugins tab. You + should now see cs168_rip.lua in the list of plugins. + +## Using the dissector + +_To make sure your dissector is working, please run the Snowcast reference +binaries_ + +Wireshark will automatically invoke the Snowcast dissector when it encounters a +TCP packets on port 1680. This means that if you start the Snowcast server on +port 1680, TCP packets on port 1680 will automatically be decoded as Snowcast +commands and replies. + +To use the Snowcast dissector with other port numbers we can instruct wireshark +to interpret TCP packets on a given port as Snowcast commands and responses. +We can tell wireshark to do this using Wireshark's "User-Specified Decodes" +feature: + +1. Run your binaries and to start capturing packets. You should be capturing + packets on the loopback interface. +2. Find a TCP packet related to this assignment and select it. These packets + will have a destination and source port number. One of these port numbers + should be the port number you selected when starting up the Snowcast server. +3. Right click on the TCP packet and select "Decode As..." +4. Double click "(none)" under "current" and select CS168SNOWCAST. + +Wireshark should no update and decode the TCP packets with your specified port +number as Snowcast commands and replies. + +If you do not see Snowcast commands and replies, check your "Decode As..." rule +from step 4. If you still do not see Snowcast commands and replies, make sure +that the plugin is loaded in the help menu. + +### Disclaimer + +The steps listed above will invoke the decoder only on a single TCP port. You +should repeat the steps above each time you change TCP ports + +## Feedback + +If you have questions or encounter any issues with the decoder, please post on +EdStem or see the course staff for help. diff --git a/util/snowcast-dissector/cs168_snowcast.lua b/util/snowcast-dissector/cs168_snowcast.lua new file mode 100644 index 0000000..511aa59 --- /dev/null +++ b/util/snowcast-dissector/cs168_snowcast.lua @@ -0,0 +1,107 @@ +-- CS168 Snowcast Protocol Dissector + +snowcast_protocol = Proto("CS168Snowcast", "CS168 Snowcast Protocol") + +message = ProtoField.uint8("cs168snowcast.messsage_type", "messageType", base.DEC) + +-- HELLO fields +udp_port = ProtoField.uint16("cs168snowcast.udp_port", "udpPort", base.DEC) +-- SET_STATION fields +station_number = ProtoField.uint16("cs168snowcast.station_number", "stationNumber", base.DEC) +-- WELCOME fields +num_stations = ProtoField.uint16("cs168snowcast.num_stations", "numStations", base.DEC) +-- ANNOUNCE fields +song_name_size = ProtoField.uint8("cs168snowcast.song_name_size", "songnameSize", base.DEC) +song_name = ProtoField.string("cs168snowcast.song_name", "songname") +-- INVALID_COMMAND fields +reply_string_size = ProtoField.uint8("cs168snowcast.reply_string_size", "replyStringSize", base.DEC) +reply_string = ProtoField.string("cs168snowcast.reply_string", "replyString") + +snowcast_protocol.fields = { + message, + udp_port, + station_number, + num_stations, + song_name_size, + song_name, + reply_string_size, + reply_string +} + +function snowcast_protocol.dissector(buffer, pinfo, tree) + length = buffer:len() + if length == 0 then return end + + pinfo.cols.protocol = snowcast_protocol.name + + local subtree = tree:add(snowcast_protocol, buffer(), "Snowcast Protocol Data") + + local packet_len = buffer:reported_length_remaining() + + local message_num = buffer(0, 1):uint() + local message_name = get_message_name(message_num) + + -- Add command ID and name + subtree:add(message, buffer(0, 1)):append_text(" (" .. message_name .. ") ") + + -- Clear any existing info in the info column so the TCP stuff info isn't in the way + pinfo.cols.info = "" + + pinfo.cols.info:append("Snowcast " .. message_name) + + if message_num == 0 then + -- Handling HELLO command + local udpPort = buffer(1, 2):uint() + subtree:add(udp_port, buffer(1, 2)) + pinfo.cols.info:append(" (UDP Port: " .. udpPort .. ") ") + elseif message_num == 1 then + -- Handling SET_STATION command + local stationNumber = buffer(1, 2):uint() + subtree:add(station_number, buffer(1, 2)) + pinfo.cols.info:append(" (Station Number: " .. stationNumber .. ") ") + elseif message_num == 2 then + -- Handling WELCOME reply + local numStations = buffer(1, 2):uint() + subtree:add(num_stations, buffer(1, 2)) + pinfo.cols.info:append(" (Station Number: " .. numStations .. ") ") + elseif message_num == 3 then + -- Handling ANNOUNCE reply + local songnameSize = buffer(1, 1):uint() + subtree:add(reply_string_size, buffer(1, 1)) + + local songname = buffer(2, songnameSize):string() + subtree:add(reply_string, buffer(2, songnameSize)) + + pinfo.cols.info:append(" (Song Name [" .. songnameSize .. " bytes]: " .. songname .. ") ") + elseif message_num == 4 then + -- Handling INVALID_COMMAND reply + local replyStringSize = buffer(1, 1):uint() + subtree:add(reply_string_size, buffer(1, 1)) + + local replyString = buffer(2, replyStringSize):string() + subtree:add(reply_string, buffer(2, replyStringSize)) + + pinfo.cols.info:append(" (Reply String [" .. replyStringSize .. " bytes]: " .. replyString .. ") ") + end +end + +function get_message_name(message_num) + local message_name = "UNNOWN" + + if message_num == 0 then + message_name = "HELLO" + elseif message_num == 1 then + message_name = "SET_STATION" + elseif message_num == 2 then + message_name = "WELCOME REPLY" + elseif message_num == 3 then + message_name = "ANNOUNCE REPLY" + elseif message_num == 4 then + message_name = "INVALID_COMMAND REPLY" + end + + return message_name +end + +local tcp_port = DissectorTable.get("tcp.port") +tcp_port:add(1680, snowcast_protocol) -- cgit v1.2.3-70-g09d2 From bf66118f56a99fc3605c9f6e6044389388821499 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Mon, 11 Sep 2023 23:45:18 -0400 Subject: Added makefile for installing snowcast dissector. --- util/snowcast-dissector/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 util/snowcast-dissector/Makefile diff --git a/util/snowcast-dissector/Makefile b/util/snowcast-dissector/Makefile new file mode 100644 index 0000000..b8f5013 --- /dev/null +++ b/util/snowcast-dissector/Makefile @@ -0,0 +1,6 @@ +INSTALL=install +TARGET=~/.config/wireshark/plugins + +install: + mkdir -pv $(TARGET) + install -m644 cs168_snowcast.lua $(TARGET) -- cgit v1.2.3-70-g09d2 From bdce15783864555d7602cecbcec43c83272b36cf Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Mon, 11 Sep 2023 23:45:33 -0400 Subject: Removed list.h (moved to c-utils repo). --- util/list.h | 137 ------------------------------------------------------------ 1 file changed, 137 deletions(-) delete mode 100644 util/list.h diff --git a/util/list.h b/util/list.h deleted file mode 100644 index a545fb2..0000000 --- a/util/list.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef __LIST_H__ -#define __LIST_H__ - -#include - -/* -** Generic circular doubly linked list implementation. -** -** list_t is the head of the list. -** list_link_t should be included in structures which want to be -** linked on a list_t. -** -** All of the list functions take pointers to list_t and list_link_t -** types, unless otherwise specified. -** -** list_init(list) initializes a list_t to an empty list. -** -** list_empty(list) returns 1 iff the list is empty. -** -** Insertion functions. -** list_insert_head(list, link) inserts at the front of the list. -** list_insert_tail(list, link) inserts at the end of the list. -** list_insert_before(olink, nlink) inserts nlink before olink in list. -** -** Removal functions. -** Head is list->l_next. Tail is list->l_prev. -** The following functions should only be called on non-empty lists. -** list_remove(link) removes a specific element from the list. -** list_remove_head(list) removes the first element. -** list_remove_tail(list) removes the last element. -** -** Item accessors. -** list_item(link, type, member) given a list_link_t* and the name -** of the type of structure which contains the list_link_t and -** the name of the member corresponding to the list_link_t, -** returns a pointer (of type "type*") to the item. -** -** To iterate over a list, -** -** list_link_t *link; -** for (link = list->l_next; -** link != list; link = link->l_next) -** ... -** -** Or, use the macros, which will work even if you list_remove() the -** current link: -** -** type iterator; -** list_iterate_begin(list, iterator, type, member) { -** ... use iterator ... -** } list_iterate_end; -*/ - -typedef struct llist { - struct llist *l_next; - struct llist *l_prev; -} list_t, list_link_t; - -#define list_init(list) \ - (list)->l_next = (list)->l_prev = (list); - -#define list_link_init(link) \ - (link)->l_next = (link)->l_prev = NULL; - -#define list_empty(list) \ - ((list)->l_next == (list)) - -#define list_insert_before(old, new) \ - do { \ - list_link_t *prev = (new); \ - list_link_t *next = (old); \ - prev->l_next = next; \ - prev->l_prev = next->l_prev; \ - next->l_prev->l_next = prev; \ - next->l_prev = prev; \ - } while(0) - -#define list_insert_head(list, link) \ - list_insert_before((list)->l_next, link) - -#define list_insert_tail(list, link) \ - list_insert_before(list, link) - -#define list_remove(link) \ - do { \ - list_link_t *ll = (link); \ - list_link_t *prev = ll->l_prev; \ - list_link_t *next = ll->l_next; \ - prev->l_next = next; \ - next->l_prev = prev; \ - ll->l_next = ll->l_prev = 0; \ - } while(0) - -#define list_remove_head(list) \ - list_remove((list)->l_next) - -#define list_remove_tail(list) \ - list_remove((list)->l_prev) - -#define list_item(link, type, member) \ - (type*)((char*)(link) - offsetof(type, member)) - -#define list_head(list, type, member) \ - list_item((list)->l_next, type, member) - -#define list_tail(list, type, member) \ - list_item((list)->l_prev, type, member) - -#define list_iterate_begin(list, var, type, member) \ - do { \ - list_link_t *__link; \ - list_link_t *__next; \ - for (__link = (list)->l_next; \ - __link != (list); \ - __link = __next) { \ - var = list_item(__link, type, member); \ - __next = __link->l_next; - -#define list_iterate_end() \ - } \ - } while(0) - -#define list_iterate_reverse_begin(list, var, type, member) \ - do { \ - list_link_t *__link; \ - list_link_t *__prev; \ - for (__link = (list)->l_prev; \ - __link != (list); \ - __link = __prev) { \ - var = list_item(__link, type, member); \ - __prev = __link->l_prev; - -#define list_iterate_reverse_end() \ - } \ - } while(0) - -#endif /* __LIST_H__ */ -- cgit v1.2.3-70-g09d2 From a04193f0149c375f0d4085cade1392c85913f36c Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Tue, 12 Sep 2023 06:43:37 -0400 Subject: Updated reference binaries; added test runner. --- .gitignore | 4 ++ reference/snowcast_control | Bin 1815928 -> 1860760 bytes reference/snowcast_listener | Bin 1491352 -> 1514808 bytes reference/snowcast_server | Bin 2005080 -> 2050008 bytes util/run_tests | 171 ++++++++++++++++++++++++++++++++++++++++++++ util/tester/control_tester | Bin 0 -> 7031352 bytes util/tester/data/short_file | Bin 0 -> 20480 bytes util/tester/data/test.txt | 12 ++++ util/tester/server_tester | Bin 0 -> 7055960 bytes 9 files changed, 187 insertions(+) create mode 100755 util/run_tests create mode 100755 util/tester/control_tester create mode 100644 util/tester/data/short_file create mode 100644 util/tester/data/test.txt create mode 100755 util/tester/server_tester diff --git a/.gitignore b/.gitignore index fe83c75..440b509 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ *.o .DS_Store + +# Created by tester +/stations +/reference/stations diff --git a/reference/snowcast_control b/reference/snowcast_control index f64b016..866cead 100755 Binary files a/reference/snowcast_control and b/reference/snowcast_control differ diff --git a/reference/snowcast_listener b/reference/snowcast_listener index 34a542c..6033d3f 100755 Binary files a/reference/snowcast_listener and b/reference/snowcast_listener differ diff --git a/reference/snowcast_server b/reference/snowcast_server index d61d179..8107323 100755 Binary files a/reference/snowcast_server and b/reference/snowcast_server differ diff --git a/util/run_tests b/util/run_tests new file mode 100755 index 0000000..22f1d54 --- /dev/null +++ b/util/run_tests @@ -0,0 +1,171 @@ +#!/bin/bash +set -euo pipefail + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +TESTER_DIR=${SCRIPT_DIR}/tester +DATA_DIR=${TESTER_DIR}/data +MP3_DIR=${SCRIPT_DIR}/../mp3 + +# Set automatically +arch="`uname -m`" +platform= + +verbose=true +fail_fast=false +bin_dir=$(realpath ${SCRIPT_DIR}/..) + +__check_platform() +{ + if test -z "$platform" -a \( "$arch" = "arm64" -o "$arch" = "aarch64" \); then + platform=linux/arm64 + elif test -z "$platform"; then + platform=linux/amd64 + fi +} + +do_help() { + echo "$0 --bin-dir . server" +} + +check_exists() { + bin="$1" + if [[ ! -e ${bin} ]]; then + echo "Binary ${bin} not found! Exiting" + exit 1 + fi +} + +run_tester() { + tester_name=$1 + shift + + case $platform in + linux/amd64) + tester_path=${TESTER_DIR}/ + ;; + linux/arm64) + tester_path=${TESTER_DIR}/arm64 + ;; + *) + echo "Unsupported platform ${platform}" + exit 1 + esac + + vflag="" + if $verbose; then + vflag="-test.v" + fi + + failflag="" + if $fail_fast; then + failflag="-test.failfast" + fi + + export BIN_DIR=${bin_dir} + export MP3_DIR=$MP3_DIR + export DATA_DIR=$DATA_DIR + ${tester_path}/${tester_name} $vflag $failflag $@ +} + +do_server() { + check_exists "${bin_dir}/snowcast_server" + run_tester server_tester $@ +} + +do_control() { + check_exists "${bin_dir}/snowcast_server" + run_tester server_tester $@ +} + +do_milestone() { + do_control -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)" + do_server -test.v -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)" +} + + +do_all() { + do_server $@ + do_control $@ +} + +main() { + POSITIONAL=() + while [[ $# -gt 0 ]]; do + key=$1 + case $key in + --fail-fast|-f) + shift + fail_fast=true + ;; + --quiet|-q) + shift + verbose=false + ;; + -a|--arm|--arm64|--aarch64) + shift + if [[ ( "${arch}" == "arm64" ) || ( "${arch}" == "aarch64" ) ]]; then + platform=linux/arm64 + else + echo "$0 --arm only works on arm64 hosts (platform is ${arch})" 1>&2 + exit 1 + fi + ;; + -x|--x86-64) + shift + platform=linux/amd64 + ;; + --bin-dir) + bin_dir="$2" + shift + shift + ;; + --help) + shift + do_help + exit 0 + ;; + *) + POSITIONAL+=("$1") + shift + esac + done + set -- "${POSITIONAL[@]}" + + __check_platform + + # Default subcommand + if [[ $# == 0 ]]; then + do_all + exit 0 + fi + + # Subcommands + case $1 in + help) + do_help + exit 0 + ;; + server) + shift + do_server $@ + ;; + control) + shift + do_control $@ + ;; + milestone) + shift + do_milestone $@ + ;; + all) + shift + do_all $@ + ;; + *) + echo "Unrecognized command $1" + exit 1 + ;; + esac +} + +main $@ diff --git a/util/tester/control_tester b/util/tester/control_tester new file mode 100755 index 0000000..942e960 Binary files /dev/null and b/util/tester/control_tester differ diff --git a/util/tester/data/short_file b/util/tester/data/short_file new file mode 100644 index 0000000..cc198a1 Binary files /dev/null and b/util/tester/data/short_file differ diff --git a/util/tester/data/test.txt b/util/tester/data/test.txt new file mode 100644 index 0000000..e4f841e --- /dev/null +++ b/util/tester/data/test.txt @@ -0,0 +1,12 @@ +1234567 +1234567 +1234567 +1234567 +1234567 +1234567 +1234567 +1234567 +1234567 +1234567 +1234567 +1234567 \ No newline at end of file diff --git a/util/tester/server_tester b/util/tester/server_tester new file mode 100755 index 0000000..13063ec Binary files /dev/null and b/util/tester/server_tester differ -- cgit v1.2.3-70-g09d2 From 8a046d646df05549bbe878be27b23386cbbc2362 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Tue, 12 Sep 2023 06:50:08 -0400 Subject: Updated dissector port number. --- util/snowcast-dissector/cs168_snowcast.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/snowcast-dissector/cs168_snowcast.lua b/util/snowcast-dissector/cs168_snowcast.lua index 511aa59..5389035 100644 --- a/util/snowcast-dissector/cs168_snowcast.lua +++ b/util/snowcast-dissector/cs168_snowcast.lua @@ -104,4 +104,4 @@ function get_message_name(message_num) end local tcp_port = DissectorTable.get("tcp.port") -tcp_port:add(1680, snowcast_protocol) +tcp_port:add(16800, snowcast_protocol) -- cgit v1.2.3-70-g09d2 From 0406ad88d420daec090eb164fba29efcd87e2ee9 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Tue, 12 Sep 2023 10:59:04 -0400 Subject: Updated test help. --- util/run_tests | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/util/run_tests b/util/run_tests index 22f1d54..4dbdf4b 100755 --- a/util/run_tests +++ b/util/run_tests @@ -24,7 +24,28 @@ __check_platform() } do_help() { - echo "$0 --bin-dir . server" + cat < Date: Tue, 12 Sep 2023 11:02:30 -0400 Subject: Added stencil update binary. --- util/update_from_stencil | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 util/update_from_stencil diff --git a/util/update_from_stencil b/util/update_from_stencil new file mode 100755 index 0000000..6385b67 --- /dev/null +++ b/util/update_from_stencil @@ -0,0 +1,18 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +REPO_DIR=$(realpath ${SCRIPT_DIR}/..) + +STENCIL_REPO=http://github.com/brown-csci1680/snowcast-template + +main() { + git remote rm stencil || true + git remote add stencil $STENCIL_REPO + + git pull stencil main +} + + +main $@ -- cgit v1.2.3-70-g09d2 From 644c1822550cbf5a52515e57e0730f65326a2ac2 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Tue, 12 Sep 2023 11:06:04 -0400 Subject: Migrated dissector to install script. --- util/snowcast-dissector/Makefile | 6 ------ util/snowcast-dissector/install.sh | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 util/snowcast-dissector/Makefile create mode 100755 util/snowcast-dissector/install.sh diff --git a/util/snowcast-dissector/Makefile b/util/snowcast-dissector/Makefile deleted file mode 100644 index b8f5013..0000000 --- a/util/snowcast-dissector/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -INSTALL=install -TARGET=~/.config/wireshark/plugins - -install: - mkdir -pv $(TARGET) - install -m644 cs168_snowcast.lua $(TARGET) diff --git a/util/snowcast-dissector/install.sh b/util/snowcast-dissector/install.sh new file mode 100755 index 0000000..efd2341 --- /dev/null +++ b/util/snowcast-dissector/install.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +TARGET=~/.config/wireshark/plugins + +main() { + mkdir -pv ${TARGET} + install -v -m644 ${SCRIPT_DIR}/cs168_snowcast.lua ${TARGET} +} + +main $@ -- cgit v1.2.3-70-g09d2 From a69685e131b9568759883c881f86c75501751827 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Tue, 12 Sep 2023 11:10:49 -0400 Subject: Added arm64 tester binaries. --- util/tester/arm64/control_tester | Bin 0 -> 6742776 bytes util/tester/arm64/server_tester | Bin 0 -> 6808312 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100755 util/tester/arm64/control_tester create mode 100755 util/tester/arm64/server_tester diff --git a/util/tester/arm64/control_tester b/util/tester/arm64/control_tester new file mode 100755 index 0000000..5eebce7 Binary files /dev/null and b/util/tester/arm64/control_tester differ diff --git a/util/tester/arm64/server_tester b/util/tester/arm64/server_tester new file mode 100755 index 0000000..6694cfe Binary files /dev/null and b/util/tester/arm64/server_tester differ -- cgit v1.2.3-70-g09d2 From 3ee5497694b5262a5e856095415fbcfbda339645 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Thu, 14 Sep 2023 11:05:53 -0400 Subject: run_tests: Fixed issue where control tests would actually run server tests. --- util/run_tests | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/run_tests b/util/run_tests index 4dbdf4b..e24d1a2 100755 --- a/util/run_tests +++ b/util/run_tests @@ -94,12 +94,12 @@ do_server() { } do_control() { - check_exists "${bin_dir}/snowcast_server" - run_tester server_tester $@ + check_exists "${bin_dir}/snowcast_control" + run_tester control_tester $@ } do_milestone() { - do_control -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)" + do_control -test.v -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)" do_server -test.v -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)" } -- cgit v1.2.3-70-g09d2 From d9db29de5f7d8c39eb8793ef2af6f0c46a16c322 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Thu, 14 Sep 2023 13:24:26 -0400 Subject: Fixed quoting on dissector install script. --- util/snowcast-dissector/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/snowcast-dissector/install.sh b/util/snowcast-dissector/install.sh index efd2341..caba8b6 100755 --- a/util/snowcast-dissector/install.sh +++ b/util/snowcast-dissector/install.sh @@ -7,8 +7,8 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) TARGET=~/.config/wireshark/plugins main() { - mkdir -pv ${TARGET} - install -v -m644 ${SCRIPT_DIR}/cs168_snowcast.lua ${TARGET} + mkdir -pv "${TARGET}" + install -v -m644 "${SCRIPT_DIR}/cs168_snowcast.lua" "${TARGET}" } main $@ -- cgit v1.2.3-70-g09d2 From 30c83f74a45b9d333aa5334fdb7ef052bac2179c Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Thu, 14 Sep 2023 13:52:49 -0400 Subject: Added .gitattributes. --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6d5975c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Force unix newlines on all platforms +* text eol=lf -- cgit v1.2.3-70-g09d2 From d4bd9e050d2b73174fd54b075ed57e366e649ba1 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Mon, 18 Sep 2023 18:38:20 -0400 Subject: Updated .gitattributes. --- .gitattributes | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 6d5975c..c3e4d96 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,4 @@ # Force unix newlines on all platforms -* text eol=lf +util/update_from_stencil text eol=lf +util/run_tests text eol=lf +*.sh text eol=lf -- cgit v1.2.3-70-g09d2 From 3846745c2e1a932b7f38976d4199a4a119583c67 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Mon, 18 Sep 2023 19:19:23 -0400 Subject: Updated arm64 tester binaries. --- util/tester/arm64/control_tester | Bin 6742776 -> 6742776 bytes util/tester/arm64/server_tester | Bin 6808312 -> 6808312 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/util/tester/arm64/control_tester b/util/tester/arm64/control_tester index 5eebce7..ef56521 100755 Binary files a/util/tester/arm64/control_tester and b/util/tester/arm64/control_tester differ diff --git a/util/tester/arm64/server_tester b/util/tester/arm64/server_tester index 6694cfe..d900a1f 100755 Binary files a/util/tester/arm64/server_tester and b/util/tester/arm64/server_tester differ -- cgit v1.2.3-70-g09d2 From cde5d96b412963fb348760baf895d6910fc06df4 Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Mon, 18 Sep 2023 19:23:05 -0400 Subject: Updated x86 tester binaries. --- util/tester/control_tester | Bin 7031352 -> 7029336 bytes util/tester/server_tester | Bin 7055960 -> 7053912 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/util/tester/control_tester b/util/tester/control_tester index 942e960..854d3c6 100755 Binary files a/util/tester/control_tester and b/util/tester/control_tester differ diff --git a/util/tester/server_tester b/util/tester/server_tester index 13063ec..7ea880c 100755 Binary files a/util/tester/server_tester and b/util/tester/server_tester differ -- cgit v1.2.3-70-g09d2 From c2348702491e5ea65e64b1ab7d2f51c5bad1562b Mon Sep 17 00:00:00 2001 From: Nicholas DeMarinis Date: Mon, 18 Sep 2023 19:29:49 -0400 Subject: run_tests: Updated to ensure all test suites are run. --- util/run_tests | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/run_tests b/util/run_tests index e24d1a2..64bbb1e 100755 --- a/util/run_tests +++ b/util/run_tests @@ -99,13 +99,13 @@ do_control() { } do_milestone() { - do_control -test.v -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)" + do_control -test.v -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)" || true do_server -test.v -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)" } do_all() { - do_server $@ + do_server $@ || true do_control $@ } -- cgit v1.2.3-70-g09d2