QuakeForge  0.7.2.210-815cf
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
NetQuake network support.

Modules

 NetQuake lan drivers.
 
 NetQuake network drivers.
 

Data Structures

struct  _PollProcedure
 
struct  hostcache_t
 
struct  netadr_t
 
struct  qsocket_s
 

Macros

#define HOSTCACHESIZE   8
 
#define MAX_NET_DRIVERS   8
 
#define NET_DATAGRAMSIZE   (MAX_DATAGRAM + NET_HEADERSIZE)
 
#define NET_HEADERSIZE   (2 * sizeof(unsigned int))
 
#define NET_MAXMESSAGE   32000
 
#define NET_NAMELEN   64
 
#define NET_PROTOCOL_VERSION   3
 

Typedefs

typedef struct _PollProcedure PollProcedure
 
typedef struct qsocket_s qsocket_t
 

Functions

qboolean NET_CanSendMessage (qsocket_t *sock)
 Check if a message can be sent to the connection. More...
 
struct qsocket_sNET_CheckNewConnections (void)
 Check for new connections. More...
 
void NET_Close (struct qsocket_s *sock)
 Close a connection. More...
 
struct qsocket_sNET_Connect (const char *host)
 Connect to a host. More...
 
void NET_FreeQSocket (qsocket_t *sock)
 Destroy a qsocket. More...
 
int NET_GetMessage (struct qsocket_s *sock)
 Read a single message from the connection into net_message. More...
 
void NET_Init (void)
 Initialize the networking sub-system. More...
 
qsocket_tNET_NewQSocket (void)
 Create and initialize a new qsocket. More...
 
void NET_Poll (void)
 Run any current poll procedures. More...
 
int NET_SendMessage (struct qsocket_s *sock, sizebuf_t *data)
 Send a single reliable message to the connection. More...
 
int NET_SendToAll (sizebuf_t *data, double blocktime)
 Send a reliable message to all attached clients. More...
 
int NET_SendUnreliableMessage (struct qsocket_s *sock, sizebuf_t *data)
 Send a single unreliable message to the connection. More...
 
void NET_Shutdown (void)
 Shutdown the networking sub-system. More...
 
void SchedulePollProcedure (PollProcedure *pp, double timeOffset)
 Schedule a poll procedure to run. More...
 
double SetNetTime (void)
 Cache the system time for the network sub-system. More...
 

Variables

int DEFAULTnet_hostport
 
hostcache_t hostcache [HOSTCACHESIZE]
 
int hostCacheCount
 
struct cvar_shostname
 
char my_tcpip_address [NET_NAMELEN]
 
int net_activeconnections
 
int net_driverlevel
 
int net_hostport
 
struct msg_snet_message
 
double net_time
 
qboolean slistInProgress
 
qboolean slistLocal
 
qboolean slistSilent
 
qboolean tcpipAvailable
 
QFilevcrFile
 

NetHeader flags

#define NETFLAG_LENGTH_MASK   0x0000ffff
 
#define NETFLAG_DATA   0x00010000
 
#define NETFLAG_ACK   0x00020000
 
#define NETFLAG_NAK   0x00040000
 
#define NETFLAG_EOM   0x00080000
 
#define NETFLAG_UNRELIABLE   0x00100000
 
#define NETFLAG_CTL   0x80000000
 

Connection Protocol

This is the network info/connection protocol.

It is used to find Quake servers, get info about them, and connect to them. Once connected, the Quake game protocol (documented elsewhere) is used.

General notes:

Note
There are two address forms used. The short form is just a port number. The address that goes along with the port is defined as "whatever address you receive this reponse from". This lets us use the host OS to solve the problem of multiple host addresses (possibly with no routing between them); the host will use the right address when we reply to the inbound connection request. The long from is a full address and port in a string. It is used for returning the address of a server that is not running locally.
#define CCREQ_CONNECT   0x01
 Connect Request: More...
 
#define CCREQ_SERVER_INFO   0x02
 Connect Request: More...
 
#define CCREQ_PLAYER_INFO   0x03
 Connect Request: More...
 
#define CCREQ_RULE_INFO   0x04
 Connect Request: More...
 
#define CCREP_ACCEPT   0x81
 Connect Reply: More...
 
#define CCREP_REJECT   0x82
 Connect Reply: More...
 
#define CCREP_SERVER_INFO   0x83
 Connect Reply: More...
 
#define CCREP_PLAYER_INFO   0x84
 Connect Reply: More...
 
#define CCREP_RULE_INFO   0x85
 Connect Reply: More...
 

socket management

qsocket_tnet_activeSockets
 
qsocket_tnet_freeSockets
 
int net_numsockets
 

message statistics

int messagesSent
 
int messagesReceived
 
int unreliableMessagesSent
 
int unreliableMessagesReceived
 

Detailed Description

Macro Definition Documentation

#define CCREP_ACCEPT   0x81

Connect Reply:

  • long port The port which the client is to use for further communication.
#define CCREP_PLAYER_INFO   0x84

Connect Reply:

  • byte player_number
  • string name
  • long colors
  • long frags
  • long connect_time
  • string address
#define CCREP_REJECT   0x82

Connect Reply:

  • string reason
#define CCREP_RULE_INFO   0x85

Connect Reply:

  • string rule
  • string value
#define CCREP_SERVER_INFO   0x83

Connect Reply:

  • string server_address
  • string host_name
  • string level_name
  • byte current_players
  • byte max_players
  • byte protocol_version NET_PROTOCOL_VERSION
#define CCREQ_CONNECT   0x01

Connect Request:

  • string game_name "QUAKE"
  • byte net_protocol_version NET_PROTOCOL_VERSION
Note
game_name is currently always "QUAKE", but is there so this same protocol can be used for future games as well
#define CCREQ_PLAYER_INFO   0x03

Connect Request:

  • byte player_number
#define CCREQ_RULE_INFO   0x04

Connect Request:

  • string rule
#define CCREQ_SERVER_INFO   0x02

Connect Request:

  • string game_name "QUAKE"
  • byte net_protocol_version NET_PROTOCOL_VERSION
Note
game_name is currently always "QUAKE", but is there so this same protocol can be used for future games as well
#define HOSTCACHESIZE   8
#define MAX_NET_DRIVERS   8
#define NET_DATAGRAMSIZE   (MAX_DATAGRAM + NET_HEADERSIZE)
#define NET_HEADERSIZE   (2 * sizeof(unsigned int))
#define NET_MAXMESSAGE   32000
#define NET_NAMELEN   64
#define NET_PROTOCOL_VERSION   3
#define NETFLAG_ACK   0x00020000
#define NETFLAG_CTL   0x80000000
#define NETFLAG_DATA   0x00010000
#define NETFLAG_EOM   0x00080000
#define NETFLAG_LENGTH_MASK   0x0000ffff
#define NETFLAG_NAK   0x00040000
#define NETFLAG_UNRELIABLE   0x00100000

Typedef Documentation

typedef struct _PollProcedure PollProcedure
typedef struct qsocket_s qsocket_t

Function Documentation

qboolean NET_CanSendMessage ( qsocket_t sock)

Check if a message can be sent to the connection.

Parameters
sockThe qsocket representing the connection.
Returns
True if the message can be sent.
struct qsocket_s* NET_CheckNewConnections ( void  )

Check for new connections.

Returns
Pointer to the qsocket for the new connection if there is one, otherwise null.
void NET_Close ( struct qsocket_s sock)

Close a connection.

If a dead connection is returned by a get or send function, this function should be called when it is convenient.

Server calls when a client is kicked off for a game related misbehavior like an illegal protocal conversation. Client calls when disconnecting from a server.

A netcon_t number will not be reused until this function is called for it

Parameters
sockThe qsocket representing the connection.
struct qsocket_s* NET_Connect ( const char *  host)

Connect to a host.

Parameters
hostThe name of the host to which will be connected.
Returns
Pointer to the qsocket representing the connection, or null if unable to connect.
void NET_FreeQSocket ( qsocket_t sock)

Destroy a qsocket.

Parameters
sockThe qsocket representing the connection.
int NET_GetMessage ( struct qsocket_s sock)

Read a single message from the connection into net_message.

If there is a complete message, return it in net_message.

Parameters
sockThe qsocket representing the connection.
Returns
0 if no data is waiting.
1 if a message was received.
-1 if the connection died.
void NET_Init ( void  )

Initialize the networking sub-system.

qsocket_t* NET_NewQSocket ( void  )

Create and initialize a new qsocket.

Called by drivers when a new communications endpoint is required. The sequence and buffer fields will be filled in properly.

Returns
The qsocket representing the connection.
void NET_Poll ( void  )

Run any current poll procedures.

int NET_SendMessage ( struct qsocket_s sock,
sizebuf_t data 
)

Send a single reliable message to the connection.

Try to send a complete length+message unit over the reliable stream.

Parameters
sockThe qsocket representing the connection.
dataThe message to send.
Returns
0 if the message connot be delivered reliably, but the connection is still considered valid
1 if the message was sent properly
-1 if the connection died
int NET_SendToAll ( sizebuf_t data,
double  blocktime 
)

Send a reliable message to all attached clients.

Parameters
dataThe message to send.
blocktimeThe blocking timeout in seconds.
Returns
The number of clients to which the message could not be sent before the timeout.
int NET_SendUnreliableMessage ( struct qsocket_s sock,
sizebuf_t data 
)

Send a single unreliable message to the connection.

Parameters
sockThe qsocket representing the connection.
dataThe message to send.
Returns
1 if the message was sent properly
-1 if the connection died
void NET_Shutdown ( void  )

Shutdown the networking sub-system.

Shutdown the networking sub-system.

void SchedulePollProcedure ( PollProcedure pp,
double  timeOffset 
)

Schedule a poll procedure to run.

The poll procedure will be called by NET_Poll() no earlier than "now"+timeOffset.

Parameters
ppThe poll procedure to shedule.
timeOffsetThe time offset from "now" at which the procedure will be run.
double SetNetTime ( void  )

Cache the system time for the network sub-system.

Returns
The current time.

Variable Documentation

int DEFAULTnet_hostport
int hostCacheCount
struct cvar_s* hostname
int messagesReceived
int messagesSent
char my_tcpip_address[NET_NAMELEN]
int net_activeconnections
qsocket_t* net_activeSockets
int net_driverlevel
qsocket_t* net_freeSockets
int net_hostport
struct msg_s* net_message
int net_numsockets
double net_time
qboolean slistInProgress
qboolean slistLocal
qboolean slistSilent
qboolean tcpipAvailable
int unreliableMessagesReceived
int unreliableMessagesSent
QFile* vcrFile