More work on TCP, still not usable
[tpg/acess2.git] / Modules / IPStack / udp.c
1 /*
2  * Acess2 IP Stack
3  * - UDP Handling
4  */
5 #include "ipstack.h"
6 #include "udp.h"
7
8 // === PROTOTYPES ===
9 void    UDP_Initialise();
10 void    UDP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buffer);
11 // --- Channel
12 tVFS_Node       *UDP_Channel_Init(tInterface *Interface);
13 Uint64  UDP_Channel_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
14 Uint64  UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
15  int    UDP_Channel_IOCtl(tVFS_Node *Node, int ID, void *Data);
16 void    UDP_Channel_Close(tVFS_Node *Node);
17
18 // === GLOBALS ===
19
20 // === CODE ===
21 /**
22  * \fn void TCP_Initialise()
23  * \brief Initialise the TCP Layer
24  */
25 void UDP_Initialise()
26 {
27         IPv4_RegisterCallback(IP4PROT_UDP, UDP_GetPacket);
28 }
29
30 /**
31  * \fn void UDP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buffer)
32  * \brief Handles a packet from the IP Layer
33  */
34 void UDP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buffer)
35 {
36         tUDPHeader      *hdr = Buffer;
37         
38         Log("[UDP  ] hdr->SourcePort = %i", ntohs(hdr->SourcePort));
39         Log("[UDP  ] hdr->DestPort = %i", ntohs(hdr->DestPort));
40         Log("[UDP  ] hdr->Length = %i", ntohs(hdr->Length));
41         Log("[UDP  ] hdr->Checksum = 0x%x", ntohs(hdr->Checksum));
42 }

UCC git Repository :: git.ucc.asn.au