NetBurner 3.5.0
PDF Version
 
tcp_private.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5#ifndef _NB_PVT_TCP_H
6#define _NB_PVT_TCP_H
7
8/**********************************************************************/
9/* Internal TCP Definitions */
10/**********************************************************************/
11typedef struct
12{
13 beuint16_t srcPort;
14 beuint16_t dstPort;
15 beuint32_t SeqNumber;
16 beuint32_t AckNumber;
17 uint8_t header_len;
18 uint8_t flags;
19 beuint16_t window;
20 uint16_t csum; // Do not make big endian. csum is calculated as if native
21 beuint16_t urgent;
22 uint8_t DATA[]; // The data field is actually as long as the packet....
23} TCPPKT;
24
25typedef TCPPKT *PTCPPKT;
26
27/**********************************************************************/
28/* Warning WARNING WARNING If you use these functions on an */
29/* uninitialized buffer you will get bogus values for the pointer */
30/* As the header length field in the IP packet is not yet set up! */
31/* Use the GetInitxxx functions instead */
32/**********************************************************************/
33
34inline PTCPPKT GetTcpPkt(PIPPKT pIp)
35{
36 if (pIp == NULL) { return NULL; }
37 if (pIp->bVerHdrLen == 0x45) { return (PTCPPKT)pIp->DATA; }
38 return (PTCPPKT)(pIp->DATA + (((pIp->bVerHdrLen & 0XF) * 4) - 20));
39}
40
41inline PTCPPKT GetTcpPkt(PoolPtr p)
42{
43 return GetTcpPkt(GetIpPkt(p));
44};
45inline PTCPPKT GetTcpPkt(PEFRAME pFrame)
46{
47 return GetTcpPkt(GetIpPkt(pFrame));
48};
49
50inline PTCPPKT GetInitTcpPkt4(PIPPKT pIp)
51{
52 pIp->bVerHdrLen = 0x45;
53 return (PTCPPKT)pIp->DATA;
54}
55
56inline PTCPPKT GetInitTcpPkt4(PoolPtr p)
57{
58 return GetInitTcpPkt4(GetIpPkt(p));
59};
60
61// Used by the IP.cpp process packet function
62void process_tcp4(PoolPtr pp, PIPPKT pIP, uint16_t csum);
63
64void DumpTcpDebug();
65void EnableTcpDebug(uint16_t);
66void DumpTcpPacket(PIPPKT pIP);
67
68int CoreConnect(const IPADDR &ipAddress, uint16_t localPort, uint16_t remotePort, TickTimeout &timeout, const IPADDR &ifip, int ifn);
69int NoBlockCoreConnect(const IPADDR &ipAddress, uint16_t localPort, uint16_t remotePort, const IPADDR &ifip, int ifn);
70
71#ifdef IPV6
72inline int CoreConnect4(IPADDR4 ipAddress, uint16_t localPort, uint16_t remotePort, TickTimeout &timeout, IPADDR4 ifip, int ifn)
73{
74 IPADDR ipl = ipAddress;
75 IPADDR ipf;
76 if (ifip.IsNull()) { ipf = IPADDR::NullIP(); }
77 else
78 ipf = ifip;
79 return CoreConnect(ipl, localPort, remotePort, timeout, ipf, ifn);
80}
81
82inline int NoBlockCoreConnect4(IPADDR4 ipAddress, uint16_t localPort, uint16_t remotePort, IPADDR4 ifip, int ifn)
83{
84 IPADDR ipl = ipAddress;
85 IPADDR ipf;
86 if (ifip.IsNull()) { ipf = IPADDR::NullIP(); }
87 else
88 ipf = ifip;
89 return NoBlockCoreConnect(ipl, localPort, remotePort, ipf, ifn);
90}
91#endif
92
93int CoreListen(const IPADDR &addr, uint16_t port, int ifn, const IPADDR &localIpAddress, uint8_t maxpend = 5);
94
95#ifdef IPV6
96inline int CoreListen4(IPADDR4 ipAddress, uint16_t port, int ifn, const IPADDR4 localIpAddress, uint8_t maxpend)
97{
98 IPADDR ipl = ipAddress;
99 IPADDR ipf;
100 if (localIpAddress.IsNull()) { ipf = IPADDR4::NullIP(); }
101 else
102 ipf = localIpAddress;
103 return CoreListen(ipl, port, ifn, ipf, maxpend);
104}
105#endif
106
107void InitTCP();
108
109#endif
Used to store and manipulate IPv4 addresses in dual stack mode.
Definition nettypes.h:208
bool IsNull() const
Check if the IP address is null.
Definition nettypes.h:262
static IPADDR4 NullIP()
C++ static function for a null IP address.
Definition nettypes.h:346
Used to hold and manipulate IPv4 and IPv6 addresses in dual stack mode.
Definition ipv6_addr.h:41
static IPADDR6 NullIP()
Static function to return a null IPADDR6 object.
TickTimeout objects are used to facilitate sequential function calls with timeout parameters that nee...
Definition nbrtos.h:157
PIPPKT GetIpPkt(PoolPtr p)
Get IP Packet pointer from network buffer pool buffer.
Definition ip.h:260
Internal IPv4 Header.
Definition ip.h:120
uint8_t bVerHdrLen
Definition ip.h:121