diff options
Diffstat (limited to 'src/net_sock.h')
-rw-r--r-- | src/net_sock.h | 72 |
1 files changed, 37 insertions, 35 deletions
diff --git a/src/net_sock.h b/src/net_sock.h index 8fccacb..8e5a340 100644 --- a/src/net_sock.h +++ b/src/net_sock.h @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -26,12 +26,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define PORT_SERVER 27910 #define PORT_SERVER_STRING "27910" -#define MIN_PACKETLEN 512 // don't allow smaller packets -#define MAX_PACKETLEN 4096 // max length of a single packet -#define PACKET_HEADER 10 // two ints and a short (worst case) -#define MAX_PACKETLEN_DEFAULT 1400 // default quake2 limit -#define MAX_PACKETLEN_WRITABLE ( MAX_PACKETLEN - PACKET_HEADER ) -#define MAX_PACKETLEN_WRITABLE_DEFAULT ( MAX_PACKETLEN_DEFAULT - PACKET_HEADER ) +#define MIN_PACKETLEN 512 // don't allow smaller packets +#define MAX_PACKETLEN 4096 // max length of a single packet +#define PACKET_HEADER 10 // two ints and a short (worst case) +#define MAX_PACKETLEN_DEFAULT 1400 // default quake2 limit +#define MAX_PACKETLEN_WRITABLE (MAX_PACKETLEN - PACKET_HEADER) +#define MAX_PACKETLEN_WRITABLE_DEFAULT (MAX_PACKETLEN_DEFAULT - PACKET_HEADER) typedef enum { NA_BAD, @@ -48,8 +48,8 @@ typedef enum { typedef enum { NET_NONE = 0, - NET_CLIENT = ( 1 << 0 ), - NET_SERVER = ( 1 << 1 ) + NET_CLIENT = (1 << 0), + NET_SERVER = (1 << 1) } netflag_t; typedef enum { @@ -71,17 +71,18 @@ typedef struct { uint16_t port; } netadr_t; -static inline qboolean NET_IsEqualAdr( const netadr_t *a, const netadr_t *b ) { - if( a->type != b->type ) { +static inline qboolean NET_IsEqualAdr(const netadr_t *a, const netadr_t *b) +{ + if (a->type != b->type) { return qfalse; } - switch( a->type ) { + switch (a->type) { case NA_LOOPBACK: return qtrue; case NA_IP: case NA_BROADCAST: - if( a->ip.u32 == b->ip.u32 && a->port == b->port ) { + if (a->ip.u32 == b->ip.u32 && a->port == b->port) { return qtrue; } // fall through @@ -92,17 +93,18 @@ static inline qboolean NET_IsEqualAdr( const netadr_t *a, const netadr_t *b ) { return qfalse; } -static inline qboolean NET_IsEqualBaseAdr( const netadr_t *a, const netadr_t *b ) { - if( a->type != b->type ) { +static inline qboolean NET_IsEqualBaseAdr(const netadr_t *a, const netadr_t *b) +{ + if (a->type != b->type) { return qfalse; } - switch( a->type ) { + switch (a->type) { case NA_LOOPBACK: return qtrue; case NA_IP: case NA_BROADCAST: - if( a->ip.u32 == b->ip.u32 ) { + if (a->ip.u32 == b->ip.u32) { return qtrue; } // fall through @@ -113,18 +115,18 @@ static inline qboolean NET_IsEqualBaseAdr( const netadr_t *a, const netadr_t *b return qfalse; } -static inline qboolean NET_IsLanAddress( const netadr_t *adr ) { - switch( adr->type ) { +static inline qboolean NET_IsLanAddress(const netadr_t *adr) +{ + switch (adr->type) { case NA_LOOPBACK: return qtrue; case NA_IP: case NA_BROADCAST: - if( adr->ip.u8[0] == 127 || adr->ip.u8[0] == 10 ) { + if (adr->ip.u8[0] == 127 || adr->ip.u8[0] == 10) { return qtrue; } - if( adr->ip.u16[0] == MakeRawShort( 192, 168 ) || - adr->ip.u16[0] == MakeRawShort( 172, 16 ) ) - { + if (adr->ip.u16[0] == MakeRawShort(192, 168) || + adr->ip.u16[0] == MakeRawShort(172, 16)) { return qtrue; } // fall through @@ -135,26 +137,26 @@ static inline qboolean NET_IsLanAddress( const netadr_t *adr ) { return qfalse; } -void NET_Init( void ); -void NET_Shutdown( void ); +void NET_Init(void); +void NET_Shutdown(void); -void NET_Config( netflag_t flag ); -qboolean NET_GetAddress( netsrc_t sock, netadr_t *adr ); +void NET_Config(netflag_t flag); +qboolean NET_GetAddress(netsrc_t sock, netadr_t *adr); -qboolean NET_GetPacket( netsrc_t sock ); -qboolean NET_SendPacket( netsrc_t sock, const netadr_t *to, size_t length, const void *data ); -qboolean NET_GetLoopPacket( netsrc_t sock ); +qboolean NET_GetPacket(netsrc_t sock); +qboolean NET_SendPacket(netsrc_t sock, const netadr_t *to, size_t length, const void *data); +qboolean NET_GetLoopPacket(netsrc_t sock); -char *NET_AdrToString( const netadr_t *a ); -qboolean NET_StringToAdr( const char *s, netadr_t *a, int port ); +char *NET_AdrToString(const netadr_t *a); +qboolean NET_StringToAdr(const char *s, netadr_t *a, int port); #if USE_CLIENT && USE_SERVER -#define NET_IsLocalAddress( adr ) ( (adr)->type == NA_LOOPBACK ) +#define NET_IsLocalAddress(adr) ((adr)->type == NA_LOOPBACK) #else -#define NET_IsLocalAddress( adr ) 0 +#define NET_IsLocalAddress(adr) 0 #endif -const char *NET_ErrorString( void ); +const char *NET_ErrorString(void); extern cvar_t *net_ip; extern cvar_t *net_port; |