mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
Document the NQ udp driver code.
This commit is contained in:
parent
50341d0972
commit
bc62988524
1 changed files with 159 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
net_udp.h
|
||||
|
||||
@description@
|
||||
NetQuake UDP lan driver.
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
|
@ -36,24 +36,167 @@
|
|||
*/
|
||||
//@{
|
||||
|
||||
int UDP_Init (void);
|
||||
/** Initialize the UDP network interface.
|
||||
|
||||
Opens a single control socket.
|
||||
|
||||
\return The control socket or -1 on failure.
|
||||
*/
|
||||
|
||||
int UDP_Init (void);
|
||||
|
||||
/** Shutdown the UDP network interface.
|
||||
*/
|
||||
void UDP_Shutdown (void);
|
||||
|
||||
/** Open or close the accept socket.
|
||||
|
||||
Sets net_acceptsocket to the socket number or -1.
|
||||
|
||||
\param state True to open the socket, false to close it.
|
||||
*/
|
||||
void UDP_Listen (qboolean state);
|
||||
int UDP_OpenSocket (int port);
|
||||
int UDP_CloseSocket (int socket);
|
||||
int UDP_Connect (int socket, struct qsockaddr *addr);
|
||||
int UDP_CheckNewConnections (void);
|
||||
int UDP_Read (int socket, byte *buf, int len, struct qsockaddr *addr);
|
||||
int UDP_Write (int socket, byte *buf, int len, struct qsockaddr *addr);
|
||||
int UDP_Broadcast (int socket, byte *buf, int len);
|
||||
|
||||
/** Open a single socket on the specified port.
|
||||
|
||||
If \p port is 0, then use the operating system default.
|
||||
|
||||
\param port The port on which to open the socket.
|
||||
\return The socket number or -1 on failure.
|
||||
*/
|
||||
int UDP_OpenSocket (int port);
|
||||
|
||||
/** Close a socket.
|
||||
|
||||
\param socket The socket to close.
|
||||
\return 0 for success, -1 for failure.
|
||||
*/
|
||||
int UDP_CloseSocket (int socket);
|
||||
|
||||
/** Does very little.
|
||||
|
||||
\param socket The socket on which to do very little.
|
||||
\param addr The address to which very little will be done.
|
||||
\return 0
|
||||
*/
|
||||
int UDP_Connect (int socket, struct qsockaddr *addr);
|
||||
|
||||
/** Check for incoming packets on the accept socket.
|
||||
|
||||
Checks if any packets are available on net_acceptsocket.
|
||||
*/
|
||||
int UDP_CheckNewConnections (void);
|
||||
|
||||
/** Read a packet from the specified socket.
|
||||
|
||||
\param socket The socket from which the packet will be read.
|
||||
\param buf The buffer into which the packet will be read.
|
||||
\param len The maximum number of bytes to read.
|
||||
\param[out] addr The address from which the packet originated.
|
||||
\return The number of bytes read or -1 on error.
|
||||
*/
|
||||
int UDP_Read (int socket, byte *buf, int len, struct qsockaddr *addr);
|
||||
|
||||
/** Send a packet via the specified socket to the specified address.
|
||||
|
||||
\param socket The socket via which the packet will be sent.
|
||||
\param buf The packet data to be sent.
|
||||
\param len The number of bytes in the packet.
|
||||
\param addr The addres to which the packet will be sent.
|
||||
\return The number of bytes sent or -1 on error.
|
||||
*/
|
||||
int UDP_Write (int socket, byte *buf, int len, struct qsockaddr *addr);
|
||||
|
||||
/** Broadcast a packet via the specified socket.
|
||||
|
||||
\warning It is a fatal error to use more than one socket for
|
||||
broadcasting.
|
||||
|
||||
\param socket The socket via which the packet will be broadcast.
|
||||
\param buf The packet data to be sent.
|
||||
\param len The number of bytes in the packet.
|
||||
\return The number of bytes sent or -1 on error.
|
||||
*/
|
||||
int UDP_Broadcast (int socket, byte *buf, int len);
|
||||
|
||||
/** Convert an address to a string.
|
||||
|
||||
Include the port number in the string.
|
||||
|
||||
\warning The return value is a pointer to a static buffer. The returned
|
||||
string must be saved if mixing calls with different addresses.
|
||||
|
||||
\param addr The address to convert.
|
||||
\return The address in human readable form.
|
||||
*/
|
||||
const char *UDP_AddrToString (struct qsockaddr *addr);
|
||||
int UDP_StringToAddr (const char *string, struct qsockaddr *addr);
|
||||
int UDP_GetSocketAddr (int socket, struct qsockaddr *addr);
|
||||
int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name);
|
||||
int UDP_GetAddrFromName (const char *name, struct qsockaddr *addr);
|
||||
int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2);
|
||||
int UDP_GetSocketPort (struct qsockaddr *addr);
|
||||
int UDP_SetSocketPort (struct qsockaddr *addr, int port);
|
||||
|
||||
/** Convert a human readable address to a quake address.
|
||||
|
||||
Parses a.b.c.d:p style addresses.
|
||||
|
||||
\param[in] string The human readable address to be converted.
|
||||
\param[out] addr The resulting address of the conversion.
|
||||
\return 0
|
||||
*/
|
||||
int UDP_StringToAddr (const char *string, struct qsockaddr *addr);
|
||||
|
||||
/** Retrieve the address to which the socket is bound.
|
||||
|
||||
\param socket The socket for which the address will be retrieved.
|
||||
\param[out] addr The address to which the socket is bound.
|
||||
\return 0
|
||||
*/
|
||||
int UDP_GetSocketAddr (int socket, struct qsockaddr *addr);
|
||||
|
||||
/** Convert an address to a hostname.
|
||||
|
||||
\param[in] addr The address to covert.
|
||||
\param[out] name Output buffer for the hostname.
|
||||
|
||||
\bug No checking is done on the size of the buffer, and uses strcpy.
|
||||
*/
|
||||
int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name);
|
||||
|
||||
/** Convert a human readable address to a quake address.
|
||||
|
||||
Accepts both host names (full or partial) and numeric form.
|
||||
|
||||
The port address can be specified when using a numeric address.
|
||||
|
||||
Numeric addresses can be partial: unspecified portions are filled out
|
||||
using the network address of the socket.
|
||||
|
||||
\param name The human readable address to be converted.
|
||||
\param addr The resulting address of the conversion.
|
||||
\return 0 if the conversion is successful, otherwise -1.
|
||||
*/
|
||||
int UDP_GetAddrFromName (const char *name, struct qsockaddr *addr);
|
||||
|
||||
/** Compare two network addresses.
|
||||
|
||||
Compare the port number too.
|
||||
|
||||
\param addr1 The first address to compare.
|
||||
\param addr2 The second address to compare.
|
||||
\return True of the addresses match, otherwise false.
|
||||
*/
|
||||
int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2);
|
||||
|
||||
/** Get the port number from the socket address.
|
||||
|
||||
\param addr The socket address from which to retrieve the port number.
|
||||
\return The port number.
|
||||
*/
|
||||
int UDP_GetSocketPort (struct qsockaddr *addr);
|
||||
|
||||
/** Set the port number of the socket address.
|
||||
|
||||
\param addr The socket address which to will have its port number set.
|
||||
\param port The port number to which the socket address will be set.
|
||||
\return 0
|
||||
*/
|
||||
int UDP_SetSocketPort (struct qsockaddr *addr, int port);
|
||||
|
||||
//@}
|
||||
|
||||
|
|
Loading…
Reference in a new issue