forked from haithun/CoD4X17a_testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netchan.h
104 lines (79 loc) · 3.32 KB
/
netchan.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
===========================================================================
Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of CoD4X17a-Server source code.
CoD4X17a-Server source code is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
CoD4X17a-Server source code 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. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
===========================================================================
*/
#ifndef __NETCHAN_H__
#define __NETCHAN_H__
#include "q_shared.h"
#include "sys_net.h"
#include "msg.h"
//#define MAC_STATIC // be fragmented into multiple packets
//#define TRUNCATE_LENGTH 64
//#define CL_DECODE_START 0
//#define SV_DECODE_START 12
//#define SV_ENCODE_START 4
//#define CL_ENCODE_START 9
#define NETCHAN_UNSENTBUFFER_SIZE 0x20000
#define NETCHAN_FRAGMENTBUFFER_SIZE 0x800
#define MAX_PACKETLEN 1400 // max size of a network packet
#define FRAGMENT_SIZE ( MAX_PACKETLEN - 100 )
typedef struct{
char command[MAX_STRING_CHARS];
int cmdTime;
int cmdType;
}reliableCommands_t;
typedef struct {
// sequencing variables
int outgoingSequence;
netsrc_t sock;
int dropped; // between last packet and previous
int incomingSequence;
//Remote address
netadr_t remoteAddress; // (0x10)
short qport; // qport value to write when transmitting (0x24)
// incoming fragment assembly buffer
int fragmentSequence;
int fragmentLength;
byte *fragmentBuffer; // (0x30)
int fragmentBufferSize;
// outgoing fragment buffer
// we need to space out the sending of large fragmented messages
qboolean unsentFragments;
int unsentFragmentStart;
int unsentLength;
byte *unsentBuffer; //(0x44)
int unsentBufferSize;
} netchan_t;
/*
typedef struct{
char command[MAX_STRING_CHARS];
int cmdTime;
int cmdType;
}reliableCommands_t;
*/
void Netchan_Init( int port );
void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport , byte* unsentBuffer, int unsentBufferSize, byte* fragmentBuffer, int fragmentBufferSize);
qboolean Netchan_Process( netchan_t *chan, msg_t *msg );
qboolean Netchan_TransmitNextFragment( netchan_t *chan );
qboolean Netchan_Transmit( netchan_t *chan, int length, const byte *data );
qboolean NET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, msg_t *net_message);
void NET_SendLoopPacket (netsrc_t sock, int length, const void *data, netadr_t to);
qboolean NET_SendPacket( netsrc_t sock, int length, const void *data, netadr_t *to );
__cdecl void QDECL NET_OutOfBandPrint( netsrc_t sock, netadr_t *adr, const char *format, ... );
void NET_OutOfBandData( netsrc_t sock, netadr_t *adr, byte *format, int len );
void QDECL NET_PrintData( int sock, const char *format, ... );
qboolean NET_SendData( int sock, byte *data, int len );
#endif