Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WorkInProgress/francinum/centralized_phones/callstation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Phone registration flow (Post-Roundstart):
return
switch(lowertext(signal.data["command"]))
if("ping_reply")// A reply to our ping!
if(signal.data[PACKET_NETCLASS] != "PNET_SIPSERVER") //Not who we care about!
if(signal.data[LEGACY_PACKET_NETCLASS] != "PNET_SIPSERVER") //Not who we care about!
return
register_with_server(signal.data["s_addr"])// It's a server, link!
if("sip_adopt")
Expand Down
17 changes: 17 additions & 0 deletions code/__DEFINES/computer4_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@

// See proc/peripheral_input
#define PERIPHERAL_CMD_RECEIVE_PACKET "receive_packet"
#define PERIPHERAL_CMD_RECEIVE_PDP_PACKET "receive_pdp_packet"
#define PERIPHERAL_CMD_SCAN_CARD "scan_card"

// Shell command macros
#define SHELL_CMD_HELP_ERROR 1 //! Could not find a command to display information about
#define SHELL_CMD_HELP_GENERIC 2 //! Generated generic help information
#define SHELL_CMD_HELP_COMMAND 3 //! Generated information about a command


// MedTrak menus
#define MEDTRAK_MENU_HOME 1
#define MEDTRAK_MENU_INDEX 2
Expand All @@ -20,13 +27,23 @@
// ITS THREE IN THE MOOOOORNIN' AND YOOUUU'RE EATING ALONE
#define DIRECTMAN_MENU_NEW_DIRECTIVE 5

// packMAN shit
#define PACKMAN_MODE_UNDEFINED 0
#define PACKMAN_MODE_CLIENT 1
#define PACKMAN_MODE_SERVER 2

// Wireless card incoming filter modes
#define WIRELESS_FILTER_PROMISC 0 //! Forward all packets
#define WIRELESS_FILTER_NETADDR 1 //! Forward only bcast/unicast matched GPRS packets
#define WIRELESS_FILTER_ID_TAGS 2 //! id_tag based filtering, for non-GPRS Control.

#define WIRELESS_FILTER_MODEMAX 2 //! Max of WIRELESS_FILTER_* Defines.

// PDP BindPort return values

#define PDP_BIND_FAILED_CATASTROPHIC 1 //! What the fuck did you do???
#define PDP_BIND_FAILED_CONFLICT 2 //! Port already bound?

// ThinkDOS //
// Constants
#define THINKDOS_MAX_COMMANDS 3 //! The maximum amount of commands
Expand Down
43 changes: 38 additions & 5 deletions code/__DEFINES/packetnet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,33 @@
// not honestly thrilled with having these be defines but kapu wants it that way
// I believe every coder is empowered with a right to footgun by our lord Dennis Ritchie

//* HEADER FIELDS *//
/// The version of the packet.
#define PKT_HEAD_VERSION "version"
/// Source (sender) address of a packet
#define PACKET_SOURCE_ADDRESS "s_addr"
#define PKT_HEAD_SOURCE_ADDRESS "s_addr"
/// Destination (receiver) address of a packet
#define PACKET_DESTINATION_ADDRESS "d_addr"
/// Command (type) of a packet
#define PACKET_CMD "command"
#define PKT_HEAD_DEST_ADDRESS "d_addr"
/// Network Class of a device, used as part of ping replies.
#define PACKET_NETCLASS "netclass"
#define PKT_HEAD_NETCLASS "netclass"

#define PKT_HEAD_SOURCE_PORT "sourceport"
#define PKT_HEAD_DEST_PORT "destport"

#define PKT_HEAD_PROTOCOL "proto"
#define PKT_PROTOCOL_PDP "pdp"

#define PKT_PAYLOAD "payload"

//* PAYLOAD FIELDS*//
/// Command (type) of a packet
#define PKT_ARG_CMD "command"

// Legacy fields. Do not use.
#define LEGACY_PACKET_SOURCE_ADDRESS PKT_HEAD_SOURCE_ADDRESS
#define LEGACY_PACKET_DESTINATION_ADDRESS PKT_HEAD_DEST_ADDRESS
#define LEGACY_PACKET_NETCLASS PKT_HEAD_NETCLASS
#define LEGACY_PACKET_COMMAND PKT_ARG_CMD

// Pagers
/// Packet arg for pager types
Expand Down Expand Up @@ -104,3 +123,17 @@
#define MAGIC_DATA_INVIOLABLE ALL

#define PACKET_STRING_FILE "packetnet.json"


// -----
// PDP Port Allocations

// Kapu insisted these be defines "to not be confusing"
#define PDP_BIND_EPHEMERAL_PORT -1
#define PDP_FREE_ALL_PORTS -1

#define PDP_MAX_PORT 65535 //! Maximum PDP Port number

#define PDP_EPHEMERAL_START 49152 //! Start of PDP Ephemeral Range, used for outgoing client connections.

#define PDP_PORT_NETTEST 28910
12 changes: 12 additions & 0 deletions code/__HELPERS/packetnet.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// Returns the data field for a packet.
/proc/packetv2(source_addr, dest_addr, source_port, dest_port, netclass, protocol, list/payload) as /list
. = list(
PKT_HEAD_VERSION = 2,
PKT_HEAD_SOURCE_ADDRESS = source_addr,
PKT_HEAD_DEST_ADDRESS = dest_addr,
PKT_HEAD_SOURCE_PORT = source_port,
PKT_HEAD_DEST_PORT = dest_port,
PKT_HEAD_NETCLASS = netclass,
PKT_HEAD_PROTOCOL = protocol,
PKT_PAYLOAD = payload,
)
7 changes: 6 additions & 1 deletion code/game/communications.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ GLOBAL_LIST_INIT(freq2icon, list(
//If range is null, or 0, signal is TRULY global (skips z_level checks) (Be careful with this.)
//If range > 0, only post to devices on the same z_level and within range
//Use range = -1, to restrain to the same z_level without limiting range
/datum/radio_frequency/proc/post_signal(datum/signal/signal, filter = null as text|null, range = null as num|null)
/datum/radio_frequency/post_signal(datum/signal/signal, filter = null as text|null, range = null as num|null)
if(!istype(signal))
CRASH("LEGACY POST SIGNAL SHIT")

Expand Down Expand Up @@ -194,6 +194,11 @@ GLOBAL_LIST_INIT(freq2icon, list(
//SHOULD_CALL_PARENT(TRUE)
. = TRUE


/datum/proc/post_signal(datum/signal/signal)
CRASH("Invoked base datum post_signal handler. Did something call parent?")


/datum/signal
/// The author/sender of this packet.
/// This atom will be skipped during packet send.
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/announcement_system.dm
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)

for(var/next_addr in targets)
var/datum/signal/outgoing = create_signal(next_addr, list(
PACKET_CMD = NETCMD_PDAMESSAGE,
LEGACY_PACKET_COMMAND = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = "Security Department Update",
"message" = "Officer [officer.real_name] has been assigned to your department, [department].",
Expand All @@ -244,7 +244,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
break //No RF card to send to.
var/message = "You have been fined [fine_amount] marks for '[cite_message]'. Fines may be paid at security."
var/datum/signal/outgoing = create_signal(rfcard.hardware_id, list(
PACKET_CMD = NETCMD_PDAMESSAGE,
LEGACY_PACKET_COMMAND = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = "Security Citation",
"message" = message,
Expand All @@ -257,7 +257,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
/obj/machinery/announcement_system/proc/mass_pda_message(list/recipients, message, reason)
for(var/next_addr in recipients)
var/datum/signal/outgoing = create_signal(next_addr, list(
PACKET_CMD = NETCMD_PDAMESSAGE,
LEGACY_PACKET_COMMAND = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = reason,
"message" = message,
Expand All @@ -270,7 +270,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
/// A helper proc for sending an announcement to a single PDA.
/obj/machinery/announcement_system/proc/pda_message(recipient, message, reason)
var/datum/signal/outgoing = create_signal(recipient, list(
PACKET_CMD = NETCMD_PDAMESSAGE,
LEGACY_PACKET_COMMAND = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = reason,
"message" = message,
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/buttons_radio.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/button/radio, 24)

var/datum/radio_frequency/radio_connection = SSpackets.return_frequency(frequency)
var/datum/signal/signal = new(src, list(
PACKET_SOURCE_ADDRESS = net_id,
PACKET_NETCLASS = NETCLASS_BUTTON,
LEGACY_PACKET_SOURCE_ADDRESS = net_id,
LEGACY_PACKET_NETCLASS = NETCLASS_BUTTON,
"tag" = id_tag,
))
radio_connection.post_signal(signal)
Expand Down
16 changes: 8 additions & 8 deletions code/game/machinery/datanet/_networked.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
if(!datagram || !destination_id)
return //Unfortunately /dev/null isn't network-scale.
var/list/sig_data = datagram.Copy()
sig_data[PACKET_SOURCE_ADDRESS] = src.net_id
sig_data[PACKET_DESTINATION_ADDRESS] = destination_id
sig_data[PKT_HEAD_SOURCE_ADDRESS] = src.net_id
sig_data[PKT_HEAD_DEST_ADDRESS] = destination_id
return new /datum/signal(src, sig_data, TRANSMISSION_WIRE)


/// Send a signal from a ref. Data sent in signals must be dereferenced.
/// If you're sending a forged source address (You should have a good reason for this...) set `preserve_s_addr = TRUE
///
/// NONE OF THE ABOVE IS TRUE IF YOU ARE `machinery/power`, AS THEY DEAL DIRECTLY WITH SSPACKETS INSTEAD OF ABSTRACTED TERMINALS
/obj/machinery/proc/post_signal(datum/signal/sending_signal, preserve_s_addr = FALSE)
/obj/machinery/post_signal(datum/signal/sending_signal, preserve_s_addr = FALSE)
if(isnull(netjack) || isnull(sending_signal)) //nullcheck for sanic speed
return //You need a pipe and something to send down it, though.
if(!preserve_s_addr)
sending_signal.data[PACKET_SOURCE_ADDRESS] = src.net_id
sending_signal.data[PKT_HEAD_SOURCE_ADDRESS] = src.net_id
sending_signal.transmission_method = TRANSMISSION_WIRE
sending_signal.author = WEAKREF(src) // Override the sending signal author.
src.netjack.post_signal(sending_signal)
Expand All @@ -31,16 +31,16 @@
if(isnull(signal))
return
var/sigdat = signal.data //cache for sanic speed this joke is getting old.
if(sigdat[PACKET_DESTINATION_ADDRESS] != src.net_id)//This packet doesn't belong to us directly
if(sigdat[PACKET_DESTINATION_ADDRESS] == NET_ADDRESS_PING)// But it could be a ping, if so, reply
if(sigdat[PKT_HEAD_DEST_ADDRESS] != src.net_id)//This packet doesn't belong to us directly
if(sigdat[PKT_HEAD_DEST_ADDRESS] == NET_ADDRESS_PING)// But it could be a ping, if so, reply
var/tmp_filter = sigdat["filter"]
if(!isnull(tmp_filter) && tmp_filter != net_class)
return RECEIVE_SIGNAL_FINISHED
//Blame kapu for how stupid this looks :3
var/payload = list(PACKET_CMD=NET_COMMAND_PING_REPLY,PACKET_NETCLASS=src.net_class)
var/payload = list(PKT_ARG_CMD=NET_COMMAND_PING_REPLY,PKT_HEAD_NETCLASS=src.net_class)
if(ping_addition)
payload += ping_addition
post_signal(create_signal(sigdat[PACKET_SOURCE_ADDRESS],payload))
post_signal(create_signal(sigdat[PKT_HEAD_SOURCE_ADDRESS],payload))
return RECEIVE_SIGNAL_FINISHED//regardless, return 1 so that machines don't process packets not intended for them.
return RECEIVE_SIGNAL_CONTINUE // We are the designated recipient of this packet, we need to handle it.

Expand Down
20 changes: 10 additions & 10 deletions code/game/machinery/datanet/p2p_phones/_p2p_phones.dm
Original file line number Diff line number Diff line change
Expand Up @@ -231,27 +231,27 @@
if(. == RECEIVE_SIGNAL_FINISHED)//Handled by default.
return
//Ping response handled in parent.
switch(signal.data[PACKET_CMD])
switch(signal.data[LEGACY_PACKET_COMMAND])
if(NET_COMMAND_PING_REPLY)//Add new phone to database
if(signal.data[PACKET_NETCLASS] == NETCLASS_P2P_PHONE) //Another phone!
discovered_phones[signal.data[PACKET_SOURCE_ADDRESS]]=signal.data["user_id"]
if(signal.data[LEGACY_PACKET_NETCLASS] == NETCLASS_P2P_PHONE) //Another phone!
discovered_phones[signal.data[LEGACY_PACKET_SOURCE_ADDRESS]]=signal.data["user_id"]
return RECEIVE_SIGNAL_FINISHED
if("tel_ring")//Incoming ring
if(active_caller || handset_state == HANDSET_OFFHOOK)//We're either calling, or about to call, Just tell them to fuck off.
post_signal(create_signal(signal.data[PACKET_SOURCE_ADDRESS],list(PACKET_CMD="tel_busy"))) //Busy signal, Reject call.
post_signal(create_signal(signal.data[LEGACY_PACKET_SOURCE_ADDRESS],list(LEGACY_PACKET_COMMAND="tel_busy"))) //Busy signal, Reject call.
return RECEIVE_SIGNAL_FINISHED
receive_call(list(signal.data[PACKET_SOURCE_ADDRESS],signal.data["caller_id"]))
receive_call(list(signal.data[LEGACY_PACKET_SOURCE_ADDRESS],signal.data["caller_id"]))
return RECEIVE_SIGNAL_FINISHED
if("tel_ready")//Remote side pickup
if(active_caller && signal.data[PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
if(active_caller && signal.data[LEGACY_PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
call_connected()
return RECEIVE_SIGNAL_FINISHED
if("tel_busy")//Answering station busy
if(active_caller && signal.data[PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
if(active_caller && signal.data[LEGACY_PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
fuck_off_im_busy()
return RECEIVE_SIGNAL_FINISHED
if("tel_hup")//Remote side hangup
if(active_caller && signal.data[PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
if(active_caller && signal.data[LEGACY_PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
switch(state)
if(STATE_ANSWER)
drop_call()// Call never connected, just reset.
Expand Down Expand Up @@ -588,8 +588,8 @@
//Bundle up what we care about.
var/datum/signal/v_signal = new(src, null, TRANSMISSION_WIRE)
v_signal.has_magic_data = MAGIC_DATA_INVIOLABLE //We're sending a virtual speaker. This packet MUST be discarded.
v_signal.data[PACKET_SOURCE_ADDRESS] = null //(Set by post_signal), Just setting it to null means it's always first in the list.
v_signal.data[PACKET_DESTINATION_ADDRESS] = callstation.active_caller[CALLER_NETID]
v_signal.data[LEGACY_PACKET_SOURCE_ADDRESS] = null //(Set by post_signal), Just setting it to null means it's always first in the list.
v_signal.data[LEGACY_PACKET_DESTINATION_ADDRESS] = callstation.active_caller[CALLER_NETID]
v_signal.data["command"] = "tel_voicedata"
v_signal.data["virtualspeaker"] = v_speaker //This is a REAL REFERENCE. Packet MUST be discarded.
v_signal.data["message"] = message
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Data Networks, or: Why the OSI Model is for Pussies


## Important Variables

### Data

These are the basic entries in a signal's data list, which are required for standard network transport.

`s_addr` - Source Address, the ID of the machine that transmitted the packet.
Expand All @@ -14,8 +14,9 @@ Example:

```json
{
"s_addr":00000001, // We are being sent by device 1
"d_addr":00000002, // intended for device 2
"command":"do_thing", // and we want them to "do_thing"
"other_fields":"Are implimentation specific."
"PKT_HEAD_SOURCE_ADDR": 00000001, // We are being sent by device 1
"PKT_HEAD_DEST_ADDR": 00000002, // intended for device 2
"command": "do_thing", // and we want them to "do_thing"
"other_fields": "Are implimentation specific."
}
```
17 changes: 17 additions & 0 deletions code/game/machinery/datanet/packetv2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```json
{
"PKT_VERSION": 2,
"PKT_HEAD_SOURCE_ADDR": 00000001, // We are being sent by device 1
"PKT_HEAD_DEST_ADDR": 00000002, // intended for device 2.
"PKT_HEAD_SOURCE_PORT": 1, // The port the packet was broadcast from.
"PKT_HEAD_DEST_PORT": 320, // The port the packet is destined for. This is often a fixed number based on the usage.
"PKT_HEAD_NETCLASS": "NETCLASS_ADAPTER", // The type of device describing the source.
"PKT_HEAD_PROTOCOL": "PKT_PROTOCOL_PDP", // The protocol describing the exchange format.
"PKT_PAYLOAD": {
"PKT_ARG_CMD": "keepalive", // A command to give to the recieving machine, using payload as parameters.
// Any misc. data not specified by the format.
"impl. specific value": "true",
"impl. specific value 2": 27
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
master = null
. = ..()

/datum/computer/file/embedded_program/proc/post_signal(datum/signal/signal, comm_line)
/datum/computer/file/embedded_program/post_signal(datum/signal/signal, comm_line)
SHOULD_CALL_PARENT(FALSE) // This is more of a relay than anything else.
if(master)
master.post_signal(signal, comm_line)
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/telecomms/machines/message_server.dm
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ TYPEINFO_DEF(/obj/machinery/blackbox_recorder)
if(calibrating) // If we're calibrating, just return, the fancy part of us isn't ready yet.
return
var/list/sig_data = signal.data //cachemere sweater
switch(signal.data[PACKET_CMD])
switch(signal.data[LEGACY_PACKET_COMMAND])
if(NETCMD_PDAMESSAGE)
var/datum/data_pda_message/log_unit = new(sig_data[PACKET_DESTINATION_ADDRESS], sig_data[PACKET_SOURCE_ADDRESS], sig_data["message"])
var/datum/data_pda_message/log_unit = new(sig_data[LEGACY_PACKET_DESTINATION_ADDRESS], sig_data[LEGACY_PACKET_SOURCE_ADDRESS], sig_data["message"])
pda_msgs += log_unit
return RECEIVE_SIGNAL_FINISHED
else
Expand All @@ -171,7 +171,7 @@ TYPEINFO_DEF(/obj/machinery/blackbox_recorder)
if(isnull(sending_signal)) //nullcheck for sanic speed
return //You need a pipe and something to send down it, though.
if(!preserve_s_addr)
sending_signal.data[PACKET_SOURCE_ADDRESS] = src.net_id
sending_signal.data[LEGACY_PACKET_SOURCE_ADDRESS] = src.net_id
sending_signal.transmission_method = TRANSMISSION_RADIO
sending_signal.author = WEAKREF(src) // Override the sending signal author.

Expand Down
4 changes: 2 additions & 2 deletions code/modules/computer4/computer4.dm
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ TYPEINFO_DEF(/obj/machinery/computer4)
if(!is_operational)
return

for(var/datum/c4_file/terminal_program/program as anything in operating_system?.processing_programs)
program.peripheral_input(invoker, command, packet)
// Operating system can be null here if the computer is mid-reboot.
operating_system?.peripheral_input(invoker, command, packet)

/obj/machinery/computer4/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src)
Expand Down
Loading
Loading