Modules/IPStack - Fixed compile warning
[tpg/acess2.git] / Modules / IPStack / udp.c
index c75aab0..2cf7692 100644 (file)
 void   UDP_Initialise();
 void   UDP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buffer);
 void   UDP_Unreachable(tInterface *Interface, int Code, void *Address, int Length, void *Buffer);
-void   UDP_SendPacketTo(tUDPChannel *Channel, int AddrType, void *Address, Uint16 Port, void *Data, size_t Length);
+void   UDP_SendPacketTo(tUDPChannel *Channel, int AddrType, const void *Address, Uint16 Port, const void *Data, size_t Length);
 // --- Client Channels
 tVFS_Node      *UDP_Channel_Init(tInterface *Interface);
 Uint64 UDP_Channel_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
  int   UDP_Channel_IOCtl(tVFS_Node *Node, int ID, void *Data);
 void   UDP_Channel_Close(tVFS_Node *Node);
 // --- Helpers
@@ -25,6 +25,12 @@ Uint16       UDP_int_AllocatePort();
 void   UDP_int_FreePort(Uint16 Port);
 
 // === GLOBALS ===
+tVFS_NodeType  gUDP_NodeType = {
+       .Read = UDP_Channel_Read,
+       .Write = UDP_Channel_Write,
+       .IOCtl = UDP_Channel_IOCtl,
+       .Close = UDP_Channel_Close
+};
 tMutex glUDP_Channels;
 tUDPChannel    *gpUDP_Channels;
 
@@ -135,7 +141,7 @@ void UDP_Unreachable(tInterface *Interface, int Code, void *Address, int Length,
  * \param Data Packet data
  * \param Length       Length in bytes of packet data
  */
-void UDP_SendPacketTo(tUDPChannel *Channel, int AddrType, void *Address, Uint16 Port, void *Data, size_t Length)
+void UDP_SendPacketTo(tUDPChannel *Channel, int AddrType, const void *Address, Uint16 Port, const void *Data, size_t Length)
 {
        tUDPHeader      *hdr;
 
@@ -169,10 +175,7 @@ tVFS_Node *UDP_Channel_Init(tInterface *Interface)
        new->Node.ImplPtr = new;
        new->Node.NumACLs = 1;
        new->Node.ACLs = &gVFS_ACL_EveryoneRW;
-       new->Node.Read = UDP_Channel_Read;
-       new->Node.Write = UDP_Channel_Write;
-       new->Node.IOCtl = UDP_Channel_IOCtl;
-       new->Node.Close = UDP_Channel_Close;
+       new->Node.Type = &gUDP_NodeType;
        
        Mutex_Acquire(&glUDP_Channels);
        new->Next = gpUDP_Channels;
@@ -244,18 +247,18 @@ Uint64 UDP_Channel_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buf
 /**
  * \brief Write to the channel file (send a packet)
  */
-Uint64 UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
 {
        tUDPChannel     *chan = Node->ImplPtr;
-       tUDPEndpoint    *ep;
-       void    *data;
+       const tUDPEndpoint      *ep;
+       const void      *data;
         int    ofs;
        if(chan->LocalPort == 0)        return 0;
        
        ep = Buffer;    
        ofs = 2 + 2 + IPStack_GetAddressSize( ep->AddrType );
 
-       data = (char*)Buffer + ofs;
+       data = (const char *)Buffer + ofs;
 
        UDP_SendPacketTo(chan, ep->AddrType, &ep->Addr, ep->Port, data, (size_t)Length - ofs);
        

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