Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions code/__DEFINES/computer4_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@
#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?
23 changes: 23 additions & 0 deletions code/__DEFINES/packetnet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
/// Network Class of a device, used as part of ping replies.
#define PACKET_NETCLASS "netclass"

#define PACKET_ARG_PROTOCOL "proto"
#define PACKET_ARG_PROTOCOL_PDP "pdp"

// Pagers
/// Packet arg for pager types
#define PACKET_ARG_PAGER_CLASS "pager_class"
Expand Down Expand Up @@ -103,3 +106,23 @@
#define MAGIC_DATA_INVIOLABLE ALL

#define PACKET_STRING_FILE "packetnet.json"

// -----
// PDP Protocol Fields
// These are partially duplicates of above but Deal With It.

#define PDP_SOURCE_ADDRESS PACKET_SOURCE_ADDRESS
#define PDP_DESTINATION_ADDRESS PACKET_DESTINATION_ADDRESS

#define PDP_SOURCE_PORT "s_port"
#define PDP_DESTINATION_PORT "d_port"

/// PDP Payload Data. Is a list.
#define PDP_PAYLOAD_DATA "payload"


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

#define PDP_MAX_PORT 65535 //! Maximum PDP Port number
#define PDP_EPHEMERAL_START 64000 //! Start of PDP Ephemeral Range, used for outgoing client connections.
81 changes: 81 additions & 0 deletions code/modules/computer4/data/socket.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Ported Datagram Protocol Socket
*/

#define PDP_SOCKET_QUEUE_DEPTH 50
/// 'Real' insert position, subject to BYOND Listism.
#define PDP_S_HEAD_REAL (head_pointer+1)
/// 'Real' read position, subject to BYOND Listism.
#define PDP_S_TAIL_REAL (tail_pointer+1)

#if PDP_SOCKET_QUEUE_DEPTH < 3
#error PDP_SOCKET_QUEUE_DEPTH is too short. If you trigger this, good fucking job:tm:
#endif

/datum/pdp_socket
/// Next Hop datum we send our packets to, Usually an operating system, but may be a physical network device.
var/datum/outgoing_datum
/// 'Owner' that registered for this socket. Used to assure ownership.
var/datum/owner
/// PDP Port the socket is bound to, Packets being sent out of this socket will have their source port set to this.
var/bound_port


/// Packet ring buffer
VAR_PRIVATE/list/packet_buffer
/// Insertion point, Incremented on packet receive. Will drop instead if =tail_pointer-1
/// Do not use directly, Must add 1 to account for list jank
VAR_PRIVATE/head_pointer
/// Read pointer, Incremented on packet read, Will not increment if there is no packet to read.
VAR_PRIVATE/tail_pointer

/datum/pdp_socket/New(bound_port, outgoing_datum, owner)
if(!bound_port)
stack_trace("Created a PDP socket without a port number?")

src.bound_port = bound_port
src.outgoing_datum = outgoing_datum
src.owner = owner
packet_buffer = new /list(PDP_SOCKET_QUEUE_DEPTH)
head_pointer = 0
tail_pointer = 0

/// Place received packet into ringqueue. Returns TRUE if inserted, FALSE if dropped due to full queue.
// No lohi I am not implimenting DSCP. Right now, at least. Maybe later.
/datum/pdp_socket/proc/enqueue(datum/signal/packet)
if(((head_pointer + 1) % PDP_SOCKET_QUEUE_DEPTH) == tail_pointer)
return FALSE //Ring full, Drop the packet.
packet_buffer[PDP_S_HEAD_REAL] = packet
head_pointer = (head_pointer+1) % PDP_SOCKET_QUEUE_DEPTH
return TRUE

/// Get next signal in queue, or null if queue is dry.
/datum/pdp_socket/proc/pop()
. = packet_buffer[PDP_S_TAIL_REAL]
if(!.)
return null
tail_pointer = (tail_pointer+1) % PDP_SOCKET_QUEUE_DEPTH
//return .

#undef PDP_SOCKET_QUEUE_DEPTH
#undef PDP_S_HEAD_REAL
#undef PDP_S_TAIL_REAL

/// Send a PDP payload packet to the destionation port and address.
/datum/pdp_socket/proc/send_data(d_address, d_port, list/payload)
// Packets come out of this preeetty skeletonized, Higher layers above this are expected to fill out some remaining details
// Such as source address.

var/list/packet_data = list(
PACKET_ARG_PROTOCOL = PACKET_ARG_PROTOCOL_PDP,

PDP_DESTINATION_ADDRESS = d_address,
PDP_DESTINATION_PORT = d_port,

//Source address set at NIC
PDP_SOURCE_PORT = bound_port,

PDP_PAYLOAD_DATA = payload
)

var/datum/signal/packet = new(null, packet_data)
5 changes: 4 additions & 1 deletion code/modules/computer4/data/terminal/medtrak/medtrak.dm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
/// Getter for the log file. This isn't kept as a ref because I don't want to manage the ref. :)
/datum/c4_file/terminal_program/medtrak/proc/get_log_file()
RETURN_TYPE(/datum/c4_file/text)
var/datum/c4_file/folder/log_dir = get_os().get_log_folder()

// Sue me. Come up with a better way to do this that doesn't demand dead procs on the OS basetype.
// (Suggestion: Move medtrak and such to a thinkdos-specific subtype of terminal_program) (t_prog/dos/medtrak)
var/datum/c4_file/folder/log_dir = get_os():get_log_folder()
if(!log_dir)
return null

Expand Down
237 changes: 0 additions & 237 deletions code/modules/computer4/data/terminal/operating_system.dm

This file was deleted.

Loading
Loading