16 #include "../../stdafx.h" 17 #include "../../debug.h" 21 #include "../../safeguards.h" 26 struct Library *SocketBase = NULL;
35 #if defined(__MORPHOS__) || defined(__AMIGA__) 40 DEBUG(net, 3,
"[core] loading bsd socket library");
41 SocketBase = OpenLibrary(
"bsdsocket.library", 4);
42 if (SocketBase == NULL) {
43 DEBUG(net, 0,
"[core] can't open bsdsocket.library version 4, network unavailable");
47 #if defined(__AMIGA__) 49 TimerPort = CreateMsgPort();
50 if (TimerPort != NULL) {
51 TimerRequest = (
struct timerequest*)CreateIORequest(TimerPort,
sizeof(
struct timerequest);
52 if (TimerRequest != NULL) {
53 if (OpenDevice(
"timer.device", UNIT_MICROHZ, (
struct IORequest*)TimerRequest, 0) == 0) {
54 TimerBase = TimerRequest->tr_node.io_Device;
55 if (TimerBase == NULL) {
57 DEBUG(net, 0,
"[core] can't initialize timer, network unavailable");
70 DEBUG(net, 3,
"[core] loading windows socket library");
71 if (WSAStartup(MAKEWORD(2, 0), &wsa) != 0) {
72 DEBUG(net, 0,
"[core] WSAStartup failed, network unavailable");
86 #if defined(__MORPHOS__) || defined(__AMIGA__) 88 #if defined(__AMIGA__) 89 if (TimerBase != NULL) CloseDevice((
struct IORequest*)TimerRequest);
90 if (TimerRequest != NULL) DeleteIORequest(TimerRequest);
91 if (TimerPort != NULL) DeleteMsgPort(TimerPort);
94 if (SocketBase != NULL) CloseLibrary(SocketBase);
112 for (j = 0; j <
sizeof(grf->
md5sum); j++) {
126 for (j = 0; j <
sizeof(grf->
md5sum); j++) {
Internal entity of a packet.
Network stuff has many things that needs to be included and/or implemented by default.
uint32 Recv_uint32()
Read a 32 bits integer from the packet.
bool NetworkCoreInitialize()
Initializes the network core (as that is needed for some platforms.
void Send_uint8(uint8 data)
Package a 8 bits integer in the packet.
void Send_uint32(uint32 data)
Package a 32 bits integer in the packet.
Basic data to distinguish a GRF.
void NetworkCoreShutdown()
Shuts down the network core (as that is needed for some platforms.
#define DEBUG(name, level,...)
Output a line of debugging information.
uint8 Recv_uint8()
Read a 8 bits integer from the packet.
Basic functions to create, fill and read packets.
uint32 grfid
GRF ID (defined by Action 0x08)
void ReceiveGRFIdentifier(Packet *p, GRFIdentifier *grf)
Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet.
uint8 md5sum[16]
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF) ...
void SendGRFIdentifier(Packet *p, const GRFIdentifier *grf)
Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet.