Go to the source code of this file.
Typedefs | |
typedef void | stream_callback_func (struct net_stream *s) |
typedef void | datagram_callback_func (struct datagram_socket *s, const char *buf, int len, struct sockaddr *from) |
Functions | |
qboolean | SV_Start (const char *node, const char *service, stream_callback_func *func) |
void | SV_Stop (void) |
struct datagram_socket * | NET_DatagramSocketNew (const char *node, const char *service, datagram_callback_func *datagram_func) |
Opens a datagram socket (UDP). | |
void | NET_DatagramSend (struct datagram_socket *s, const char *buf, int len, struct sockaddr *to) |
void | NET_DatagramBroadcast (struct datagram_socket *s, const char *buf, int len, int port) |
void | NET_DatagramSocketClose (struct datagram_socket *s) |
void | NET_SockaddrToStrings (struct datagram_socket *s, struct sockaddr *addr, char *node, size_t nodelen, char *service, size_t servicelen) |
Convert sockaddr to string. | |
void | NET_Init (void) |
void | NET_Shutdown (void) |
void | NET_Wait (int timeout) |
struct net_stream * | NET_Connect (const char *node, const char *service) |
Try to connect to a given host on a given port. | |
struct net_stream * | NET_ConnectToLoopBack (void) |
void | NET_StreamEnqueue (struct net_stream *s, const char *data, int len) |
Enqueue a network message into a stream. | |
qboolean | NET_StreamIsClosed (struct net_stream *s) |
int | NET_StreamGetLength (struct net_stream *s) |
int | NET_StreamPeek (struct net_stream *s, char *data, int len) |
Returns the length of the waiting inbound buffer. | |
int | NET_StreamDequeue (struct net_stream *s, char *data, int len) |
void * | NET_StreamGetData (struct net_stream *s) |
void | NET_StreamSetData (struct net_stream *s, void *data) |
const char * | NET_StreamPeerToName (struct net_stream *s, char *dst, int len, qboolean appendPort) |
qboolean | NET_StreamIsLoopback (struct net_stream *s) |
void | NET_StreamFree (struct net_stream *s) |
Call NET_StreamFree to dump the whole thing right now. | |
void | NET_StreamFinished (struct net_stream *s) |
Call NET_StreamFinished to mark the stream as uninteresting, but to finish sending any data in the buffer. The stream will appear closed after this call, and at some unspecified point in the future s will become an invalid pointer, so it should not be further referenced. | |
void | NET_StreamSetCallback (struct net_stream *s, stream_callback_func *func) |
Definition in file net.h.
typedef void datagram_callback_func(struct datagram_socket *s, const char *buf, int len, struct sockaddr *from) |
typedef void stream_callback_func(struct net_stream *s) |
struct net_stream* NET_Connect | ( | const char * | node, | |
const char * | service | |||
) | [read] |
Try to connect to a given host on a given port.
[in] | node | The host to connect to |
[in] | service | The port to connect to |
Definition at line 622 of file net.c.
References AI_ADDRCONFIG, AI_NUMERICSERV, Com_Printf(), net_stream::index, cvar_s::integer, NET_DoConnect(), and NET_StreamGetFree().
Referenced by CL_Connect(), CL_PingServer(), CL_Rcon_f(), CL_ServerInfo_f(), and Irc_Net_Connect().
struct net_stream* NET_ConnectToLoopBack | ( | void | ) | [read] |
Definition at line 659 of file net.c.
References Com_Printf(), net_stream::func, net_stream::inbound, net_stream::loopback, net_stream::loopback_peer, NET_StreamGetFree(), NET_StreamNew(), new_dbuffer(), net_stream::outbound, qtrue, server_func, and server_running.
Referenced by CL_Connect().
void NET_DatagramBroadcast | ( | struct datagram_socket * | s, | |
const char * | buf, | |||
int | len, | |||
int | port | |||
) |
Definition at line 1098 of file net.c.
References Com_Error(), ERR_DROP, datagram_socket::family, and NET_DatagramSend().
Referenced by CL_PingServers_f().
void NET_DatagramSend | ( | struct datagram_socket * | s, | |
const char * | buf, | |||
int | len, | |||
struct sockaddr * | to | |||
) |
Definition at line 1073 of file net.c.
References datagram::addr, datagram_socket::addrlen, datagram::len, Mem_PoolAlloc, datagram::msg, datagram::next, datagram_socket::queue_tail, datagram_socket::socket, and write_fds.
Referenced by NET_DatagramBroadcast(), and SV_DiscoveryCallback().
void NET_DatagramSocketClose | ( | struct datagram_socket * | s | ) |
Definition at line 1121 of file net.c.
References datagram::addr, datagram_socket::index, Mem_Free, datagram::msg, netCloseSocket, datagram::next, datagram_socket::queue, read_fds, datagram_socket::socket, and write_fds.
Referenced by CL_Connect(), and SV_Shutdown().
struct datagram_socket* NET_DatagramSocketNew | ( | const char * | node, | |
const char * | service, | |||
datagram_callback_func * | func | |||
) | [read] |
Opens a datagram socket (UDP).
[in] | node | The numeric address to resolv (might be NULL) |
[in] | service | The port number |
[in] | func | Callback function for data handling |
Definition at line 1038 of file net.c.
References AI_ADDRCONFIG, AI_NUMERICSERV, Com_Printf(), datagram_socket::func, cvar_s::integer, NET_DatagramSocketDoNew(), and qfalse.
Referenced by CL_PingServers_f(), and SV_InitGame().
void NET_Init | ( | void | ) |
Definition at line 287 of file net.c.
References Cmd_AddCommand(), Com_Error(), Com_Printf(), CVAR_ARCHIVE, Cvar_Get(), dbuffer_init(), ERR_FATAL, i, MAX_DATAGRAM_SOCKETS, MAX_STREAMS, maxfd, NET_ShowStreams_f(), read_fds, and write_fds.
Referenced by Qcommon_Init().
void NET_Shutdown | ( | void | ) |
void NET_SockaddrToStrings | ( | struct datagram_socket * | s, | |
struct sockaddr * | addr, | |||
char * | node, | |||
size_t | nodelen, | |||
char * | service, | |||
size_t | servicelen | |||
) |
Convert sockaddr to string.
[in] | s | The datagram socket type to get the addrlen from |
[in] | addr | The socket address to convert into a string |
[out] | node | The target node name buffer |
[in] | nodelen | The length of the node name buffer |
[out] | service | The target service name buffer |
[in] | servicelen | The length of the service name buffer |
Definition at line 1151 of file net.c.
References datagram_socket::addrlen, Com_Printf(), and Q_strncpyz().
Referenced by CL_ServerListDiscoveryCallback().
int NET_StreamDequeue | ( | struct net_stream * | s, | |
char * | data, | |||
int | len | |||
) |
Definition at line 745 of file net.c.
References dbuffer_extract(), net_stream::finished, and net_stream::inbound.
Referenced by Irc_Proto_PollServerMsg(), and NET_ReadMsg().
void NET_StreamEnqueue | ( | struct net_stream * | s, | |
const char * | data, | |||
int | len | |||
) |
Enqueue a network message into a stream.
Definition at line 699 of file net.c.
References net_stream::closed, dbuffer_add(), net_stream::finished, net_stream::loopback_peer, loopback_ready, net_stream::outbound, qtrue, net_stream::ready, net_stream::socket, and write_fds.
Referenced by Irc_Net_Send(), NET_OOB_Printf(), NET_WriteConstMsg(), and NET_WriteMsg().
void NET_StreamFinished | ( | struct net_stream * | s | ) |
Call NET_StreamFinished to mark the stream as uninteresting, but to finish sending any data in the buffer. The stream will appear closed after this call, and at some unspecified point in the future s will become an invalid pointer, so it should not be further referenced.
Definition at line 785 of file net.c.
References dbuffer_len, net_stream::finished, free_dbuffer(), net_stream::inbound, net_stream::loopback_peer, NET_StreamClose(), net_stream::outbound, qtrue, read_fds, and net_stream::socket.
Referenced by CL_Disconnect(), SV_DropClient(), and SV_FinalMessage().
void NET_StreamFree | ( | struct net_stream * | s | ) |
Call NET_StreamFree to dump the whole thing right now.
Definition at line 770 of file net.c.
References net_stream::finished, NET_StreamClose(), and qtrue.
Referenced by CL_PingServerCallback(), CL_RconCallback(), CL_ServerInfoCallback(), Irc_Net_Connect(), Irc_Net_Disconnect(), NET_StreamNew(), and SV_ReadPacket().
void* NET_StreamGetData | ( | struct net_stream * | s | ) |
Definition at line 753 of file net.c.
References net_stream::data.
Referenced by CL_PingServerCallback(), and SV_ReadPacket().
int NET_StreamGetLength | ( | struct net_stream * | s | ) |
Definition at line 721 of file net.c.
References dbuffer_len, and net_stream::inbound.
Referenced by NET_ReadMsg(), and NET_Wait().
qboolean NET_StreamIsClosed | ( | struct net_stream * | s | ) |
Definition at line 716 of file net.c.
References net_stream::closed, net_stream::finished, and qtrue.
qboolean NET_StreamIsLoopback | ( | struct net_stream * | s | ) |
Definition at line 853 of file net.c.
References net_stream::loopback.
Referenced by CL_ConnectionlessPacket(), and NET_StreamPeerToName().
int NET_StreamPeek | ( | struct net_stream * | s, | |
char * | data, | |||
int | len | |||
) |
Returns the length of the waiting inbound buffer.
Definition at line 730 of file net.c.
References net_stream::closed, dbuffer_get(), dbuffer_len, net_stream::finished, and net_stream::inbound.
Referenced by NET_ReadMsg().
const char* NET_StreamPeerToName | ( | struct net_stream * | s, | |
char * | dst, | |||
int | len, | |||
qboolean | appendPort | |||
) |
[in] | s | The network stream to get the name for |
[out] | dst | The target buffer to store the ip and port in |
[in] | len | The length of the target buffer |
[in] | appendPort | Also append the port number to the target buffer |
Definition at line 814 of file net.c.
References net_stream::addrlen, Com_Printf(), Com_sprintf(), NET_StreamIsLoopback(), Q_strncpyz(), and net_stream::socket.
Referenced by CL_ServerInfoCallback(), NET_ShowStreams_f(), NET_Wait(), SV_ConnectionlessPacket(), SV_Status_f(), SVC_DirectConnect(), and SVC_RemoteCommand().
void NET_StreamSetCallback | ( | struct net_stream * | s, | |
stream_callback_func * | func | |||
) |
Definition at line 846 of file net.c.
References net_stream::func.
Referenced by CL_PingServer(), CL_Rcon_f(), and CL_ServerInfo_f().
void NET_StreamSetData | ( | struct net_stream * | s, | |
void * | data | |||
) |
Definition at line 758 of file net.c.
References net_stream::data.
Referenced by CL_PingServer(), and SVC_DirectConnect().
void NET_Wait | ( | int | timeout | ) |
Definition at line 407 of file net.c.
References datagram::addr, datagram_socket::addrlen, Com_DPrintf(), Com_Printf(), dbuffer_add(), dbuffer_get(), dbuffer_len, dbuffer_remove(), DEBUG_SERVER, do_accept(), errno, net_stream::finished, datagram_socket::func, net_stream::func, i, net_stream::inbound, INVALID_SOCKET, datagram::len, len, net_stream::loopback, net_stream::loopback_peer, loopback_ready, MAX_DATAGRAM_SOCKETS, MAX_STREAMS, maxfd, Mem_Free, datagram::msg, NET_StreamClose(), NET_StreamGetLength(), NET_StreamPeerToName(), netError, netStringError, datagram::next, net_stream::outbound, qfalse, qtrue, datagram_socket::queue, datagram_socket::queue_tail, read_fds, net_stream::ready, server_socket, datagram_socket::socket, net_stream::socket, Sys_Sleep(), and write_fds.
Referenced by CL_Disconnect(), Com_Error(), Com_Quit(), Qcommon_Frame(), and SV_FinalMessage().
qboolean SV_Start | ( | const char * | node, | |
const char * | service, | |||
stream_callback_func * | func | |||
) |
[in] | node | The node to start the server with |
[in] | service | If this is NULL we are in single player mode |
[in] | func | The server callback function to read the packets |
Definition at line 912 of file net.c.
References AI_ADDRCONFIG, AI_NUMERICSERV, Com_Printf(), cvar_s::integer, INVALID_SOCKET, NET_DoStartServer(), qfalse, qtrue, server_func, server_running, and server_socket.
Referenced by SV_InitGame().
void SV_Stop | ( | void | ) |
Definition at line 961 of file net.c.
References INVALID_SOCKET, netCloseSocket, qfalse, read_fds, server_func, server_running, and server_socket.
Referenced by SV_Shutdown().