UFO: Alien Invasion
|
Go to the source code of this file.
Typedefs | |
typedef void | stream_onclose_func () |
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 | |
bool | 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) More... | |
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. More... | |
bool | NET_ResolvNode (const char *node, char *buf, size_t bufLength) |
void | NET_Init (void) |
void | NET_Shutdown (void) |
void | NET_Wait (int timeout) |
struct net_stream * | NET_Connect (const char *node, const char *service, stream_onclose_func *onclose) |
Try to connect to a given host on a given port. More... | |
struct net_stream * | NET_ConnectToLoopBack (stream_onclose_func *onclose) |
void | NET_StreamEnqueue (struct net_stream *s, const char *data, int len) |
Enqueue a network message into a stream. More... | |
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, bool appendPort) |
const char * | NET_StreamToString (struct net_stream *s) |
Returns the numerical representation of a net_stream . More... | |
bool | NET_StreamIsLoopback (struct net_stream *s) |
void | NET_StreamFree (struct net_stream *s) |
Call NET_StreamFree to dump the whole thing right now. More... | |
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. More... | |
void | NET_StreamSetCallback (struct net_stream *s, stream_callback_func *func) |
dbuffer * | NET_ReadMsg (struct net_stream *s) |
Reads messages from the network channel and adds them to the dbuffer where you can use the NET_Read* functions to get the values in the correct order. More... | |
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, | ||
stream_onclose_func * | onclose | ||
) |
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 |
[in] | onclose | The callback that is called on closing the returned stream. This is useful if you hold the pointer for the returned stream anywhere else and would like to get notified once this pointer is invalid. |
Definition at line 644 of file net.cpp.
References AI_ADDRCONFIG, AI_NUMERICSERV, Com_Printf(), index, cvar_s::integer, NET_DoConnect(), NET_StreamGetFree(), and OBJZERO.
Referenced by CL_Connect(), GAME_GetImportData(), and Irc_Net_Connect().
struct net_stream* NET_ConnectToLoopBack | ( | stream_onclose_func * | onclose | ) |
[in] | onclose | The callback that is called on closing the returned stream. This is useful if you hold the pointer for the returned stream anywhere else and would like to get notified once this pointer is invalid. |
Definition at line 681 of file net.cpp.
References Com_Printf(), net_stream::func, net_stream::inbound, net_stream::loopback, net_stream::loopback_peer, NET_StreamGetFree(), NET_StreamNew(), net_stream::onclose, net_stream::outbound, 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 1159 of file net.cpp.
References Com_Error(), ERR_DROP, datagram_socket::family, and NET_DatagramSend().
Referenced by GAME_GetImportData().
void NET_DatagramSend | ( | struct datagram_socket * | s, |
const char * | buf, | ||
int | len, | ||
struct sockaddr * | to | ||
) |
Definition at line 1135 of file net.cpp.
References datagram::addr, datagram_socket::addrlen, com_networkPool, len, datagram::len, Mem_PoolAllocType, Mem_PoolAllocTypeN, 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 1182 of file net.cpp.
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 GAME_GetImportData(), and SV_Shutdown().
struct datagram_socket* NET_DatagramSocketNew | ( | const char * | node, |
const char * | service, | ||
datagram_callback_func * | func | ||
) |
Opens a datagram socket (UDP)
[in] | node | The numeric address to resolv (might be nullptr) |
[in] | service | The port number |
[in] | func | Callback function for data handling |
Definition at line 1102 of file net.cpp.
References AI_ADDRCONFIG, AI_NUMERICSERV, Com_Printf(), datagram_socket::func, cvar_s::integer, NET_DatagramSocketDoNew(), and OBJZERO.
Referenced by GAME_GetImportData(), and SV_InitGame().
Definition at line 305 of file net.cpp.
References Cmd_AddCommand(), Com_Error(), Com_Printf(), CVAR_ARCHIVE, Cvar_Get(), ERR_FATAL, i, MAX_DATAGRAM_SOCKETS, MAX_STREAMS, maxfd, NET_ShowStreams_f(), netMutex, read_fds, and write_fds.
Referenced by Qcommon_Init(), and TEST_Init().
dbuffer* NET_ReadMsg | ( | struct net_stream * | s | ) |
Reads messages from the network channel and adds them to the dbuffer where you can use the NET_Read* functions to get the values in the correct order.
Definition at line 774 of file net.cpp.
References dbuffer::add(), len, LittleLong, NET_StreamDequeue(), NET_StreamGetLength(), NET_StreamPeek(), netMutex, and v.
Referenced by CL_ReadPackets(), GAME_GetImportData(), and SV_ReadPacket().
bool NET_ResolvNode | ( | const char * | node, |
char * | buf, | ||
size_t | bufLength | ||
) |
Definition at line 1229 of file net.cpp.
References NET_AddrinfoToString(), and NET_GetAddrinfoForNode().
Referenced by HTTP_ResolvURL(), and TEST_F().
Definition at line 337 of file net.cpp.
References netMutex.
Referenced by Qcommon_Shutdown(), GenericTest::TearDownTestCase(), FootStepTest::TearDownTestCase(), MapDefStatsTest::TearDownTestCase(), MapDefTest::TearDownTestCase(), MapDefMassRMATest::TearDownTestCase(), InventoryTest::TearDownTestCase(), and TEST_Shutdown().
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 1212 of file net.cpp.
References datagram_socket::addrlen, Com_Printf(), and Q_strncpyz().
Referenced by GAME_GetImportData().
int NET_StreamDequeue | ( | struct net_stream * | s, |
char * | data, | ||
int | len | ||
) |
Definition at line 760 of file net.cpp.
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 719 of file net.cpp.
References dbuffer::add(), net_stream::closed, net_stream::finished, INVALID_SOCKET, net_stream::loopback_peer, loopback_ready, netMutex, net_stream::outbound, 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 832 of file net.cpp.
References dbuffer_len, net_stream::finished, net_stream::inbound, INVALID_SOCKET, net_stream::loopback_peer, NET_StreamClose(), netMutex, net_stream::outbound, 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 817 of file net.cpp.
References net_stream::finished, and NET_StreamClose().
Referenced by GAME_GetImportData(), Irc_Net_Connect(), Irc_Net_Disconnect(), NET_StreamNew(), and SV_ReadPacket().
void* NET_StreamGetData | ( | struct net_stream * | s | ) |
Definition at line 800 of file net.cpp.
References net_stream::data.
Referenced by GAME_GetImportData(), and SV_ReadPacket().
bool NET_StreamIsLoopback | ( | struct net_stream * | s | ) |
Definition at line 910 of file net.cpp.
References net_stream::loopback.
Referenced by CL_ConnectionlessPacket(), and NET_StreamPeerToName().
const char* NET_StreamPeerToName | ( | struct net_stream * | s, |
char * | dst, | ||
int | len, | ||
bool | 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 872 of file net.cpp.
References net_stream::addrlen, Com_Printf(), Com_sprintf(), NET_StreamIsLoopback(), Q_strncpyz(), and net_stream::socket.
Referenced by GAME_GetImportData(), NET_ShowStreams_f(), NET_StreamToString(), NET_Wait(), SV_ConnectionlessPacket(), SV_Status_f(), SVC_BucketForAddress(), SVC_DirectConnect(), and SVC_RemoteCommand().
void NET_StreamSetCallback | ( | struct net_stream * | s, |
stream_callback_func * | func | ||
) |
Definition at line 903 of file net.cpp.
References net_stream::func.
Referenced by GAME_GetImportData().
void NET_StreamSetData | ( | struct net_stream * | s, |
void * | data | ||
) |
Definition at line 805 of file net.cpp.
References net_stream::data.
Referenced by GAME_GetImportData(), and SVC_DirectConnect().
const char* NET_StreamToString | ( | struct net_stream * | s | ) |
Returns the numerical representation of a net_stream
.
Definition at line 859 of file net.cpp.
References NET_StreamPeerToName().
Referenced by SVC_Info(), SVC_Status(), and SVC_TeamInfo().
Definition at line 423 of file net.cpp.
References dbuffer::add(), datagram::addr, datagram_socket::addrlen, Com_DPrintf(), Com_Printf(), dbuffer_len, DEBUG_SERVER, do_accept(), net_stream::finished, net_stream::func, datagram_socket::func, dbuffer::get(), i, net_stream::inbound, INVALID_SOCKET, len, datagram::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, netMutex, netStringError, datagram::next, net_stream::outbound, datagram_socket::queue, datagram_socket::queue_tail, read_fds, net_stream::ready, dbuffer::remove(), server_socket, net_stream::socket, datagram_socket::socket, Sys_Sleep(), and write_fds.
Referenced by CL_Disconnect(), Com_Error(), Com_Quit(), Qcommon_Frame(), and SV_FinalMessage().
bool 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 nullptr we are in single player mode |
[in] | func | The server callback function to read the packets |
Definition at line 990 of file net.cpp.
References Com_Printf(), INVALID_SOCKET, NET_DoStartServer(), NET_GetAddrinfoForNode(), server_func, server_running, and server_socket.
Referenced by SV_InitGame().
Definition at line 1026 of file net.cpp.
References INVALID_SOCKET, netCloseSocket, read_fds, server_func, server_running, and server_socket.
Referenced by SV_Shutdown().