38#define IP_VERSION_MASK (0xF0)
39#define IP_VERSION_IPv4 (0x40)
40#define IP_VERSION_IPv6 (0x60)
46#define IP_HEADER_LENGTH_MASK (0x0F)
47#define IP_HEADER_LENGTH_NO_OPTIONS (0x05)
53#define IP_FLAGS_MASK (0xE000)
54#define IP_FRAGMENT_OFFSET_MASK (0x1FFF)
60#define IP_PROTOCOL_ICMP (0x01)
61#define IP_PROTOCOL_IGMP (0x02)
62#define IP_PROTOCOL_INTERNET (0x04)
63#define IP_PROTOCOL_TCP (0x06)
64#define IP_PROTOCOL_UDP (0x11)
70#define ICMP_TYPE_ECHO_REPLY (0)
71#define ICMP_CODE_ECHO_REPLY (0)
72#define ICMP_TYPE_DEST_UNREACHABLE (3)
73#define ICMP_CODE_PORT_UNREACHABLE (3)
74#define ICMP_TYPE_SOURCE_QUENCH (4)
75#define ICMP_CODE_SOURCE_QUENCH (0)
76#define ICMP_TYPE_REDIRECT_MESSAGE (5)
77#define ICMP_TYPE_ECHO_REQUEST (8)
78#define ICMP_CODE_ECHO_REQUEST (0)
84#define IANA_ECHO_PORT (7)
85#define IANA_DISCARD_PORT (9)
86#define IANA_SSH_PORT (22)
87#define IANA_TELNET_PORT (23)
89#define IANA_NETBIOS_NAME_SERVICE_PORT (137)
92#define ICMP_PING_DATA_SIZE (32)
135} __attribute__((packed))
IPPKT;
150} __attribute__((packed))
UDPPKT;
191 uint16_t
GetSum(puint16_t addr, uint16_t count);
203BOOL IsMyIp6(
const IPADDR &ip,
int ifc = -1);
207 return IsMyIp6(ip, ifc);
214 return GetSrcIp6(dst);
221 return GetSrcIp6wIf(ifn, dst);
262 return (p == NULL) ? NULL : (
PIPPKT)(p->pData + 14);
268 return (
PIPPKT)(pFrame->pData);
274 return (
PIPPKT)(pFrame->pData);
280 if (pIp == NULL) {
return NULL; }
314typedef void(FragmentProcessFunction)(PoolPtr pp);
315extern FragmentProcessFunction *pFragFunc;
334typedef void(PromisciousPacketFunc)(PoolPtr pp);
335extern PromisciousPacketFunc *pPromisciousPacketFunc;
355typedef int(TaskPacketFunc)(
UDPPacket &pkt,
int ifn);
356extern TaskPacketFunc *pTaskPacketFunc;
374void ShowIPBuffer(PoolPtr rp);
402int Ping4(
IPADDR4 to, uint16_t
id, uint16_t seq, uint16_t maxwaitticks);
403int Ping4ViaInterface(
IPADDR4 to, uint16_t
id, uint16_t seq, uint16_t wait,
int interface);
406int Ping6(
const IPADDR &to, uint16_t
id, uint16_t seq, uint16_t maxwaitticks,
int size = 32);
407int Ping6ViaInterface(
const IPADDR &to, uint16_t
id, uint16_t seq, uint16_t wait,
int interface,
int size = 32);
408inline int Ping(
const IPADDR &to, uint16_t
id, uint16_t seq, uint16_t maxwaitticks,
int size = 32)
410 return Ping6(to,
id, seq, maxwaitticks, size);
412inline int PingViaInterface(
const IPADDR &to, uint16_t
id, uint16_t seq, uint16_t wait,
int interface,
int size = 32)
414 return Ping6ViaInterface(to,
id, seq, wait, interface, size);
417inline int Ping(
IPADDR4 to, uint16_t
id, uint16_t seq, uint16_t maxwaitticks)
419 return Ping4(to,
id, seq, maxwaitticks);
421inline int PingViaInterface(
IPADDR4 to, uint16_t
id, uint16_t seq, uint16_t wait,
int interface)
423 return Ping4ViaInterface(to,
id, seq, wait, interface);
427BOOL IsLocal4(
IPADDR4 ip,
int ifc);
428int GetProperInterface4(
IPADDR4 dst);
430#if defined MULTIHOME || defined AUTOIP
432int GetMultiHomeInterface(
IPADDR4 ipa,
int norgif);
433int GetLocalIPInterface4(
IPADDR4 ipa);
435int GetLocalIPInterface6(
const IPADDR &ipa);
436inline int GetLocalIPInterface(
const IPADDR &ipa)
438 return GetLocalIPInterface6(ipa);
441inline int GetLocalIPInterface(
IPADDR4 ipa)
443 return GetLocalIPInterface4(ipa);
458#error Got to pick an IP version
463uint16_t GetEphemeralPort();
Used to store and manipulate IPv4 addresses in dual stack mode.
Definition nettypes.h:208
Used to hold and manipulate IPv4 and IPv6 addresses in dual stack mode.
Definition ipv6_addr.h:41
UDP Packet Class.
Definition udp.h:81
void FixHeaderAndSend(PoolPtr p, PIPPKT pIp)
Complete header and send on primary network interface.
IPADDR GetSrcIp(const IPADDR &dst)
Get source IP address for this destination.
Definition ip.h:212
BOOL bQuietStart
Quiet start.
void FixHeaderAndSendViaInterface(PoolPtr p, PIPPKT pIp, int Interface)
Complete header and send on an interface.
int AddInterface(IPADDR4 addr, IPADDR4 mask, IPADDR4 gateway, int root_if)
Add an interface with an interface number.
Definition multihome.h:151
struct _IpHeaderIPv4 IpHeaderIPv4
IP Header (IPv4)
void InitializeStack()
Initializes the IP stack.
PIPPKT GetIpPkt(PoolPtr p)
Get IP Packet pointer from network buffer pool buffer.
Definition ip.h:260
uint16_t wArpLifetime
ARP lifetime in seconds.
void SendICMPError(PoolPtr pBadPacket, uint8_t type, uint8_t code)
Send ICMP error.
IPADDR GetSrcIpwIf(int ifn, const IPADDR &dst)
Get source IP address for an interface.
Definition ip.h:219
IPADDR4 GetSrcIp4(IPADDR4 dst)
Get source IP address for this destination.
uint16_t GetSum20(puint32_t addr)
Checksum.
BOOL IsMyIp(const IPADDR &ip, int ifc=-1)
Is this my IP address?
Definition ip.h:205
IPADDR4 GetSrcIpwIf4(int ifn, const IPADDR4 dst)
uint16_t GetSumHdr(PsudeoHeader &hdr, puint16_t addr, uint16_t count)
Checksum using pseudo-header.
PUDPPKT GetUdpPkt(PIPPKT pIp)
Get UPD packet pointer from IP packet pointer.
Definition ip.h:278
void IpProcessEthernetPacket(PoolPtr poolPtr, uint16_t packetSizeInBytes)
IP packet insertion for processing.
uint16_t GetSum(puint16_t addr, uint16_t count)
Checksum.
BOOL IsMyIp4(IPADDR4 ip, int ifc=-1)
Is this my IP address?
uint8_t bTTL_Default
Default number of hops (time to live)
NetBurner IPADDR4 Class. See the IPADDR4 Class page for complete documentation.
Internal IPv4 Header.
Definition ip.h:120
uint16_t hCSum
Checksum Do not make a big endian var, checksumming is treated as native endian.
Definition ip.h:131
IPADDR4 ipSrc
Definition ip.h:132
uint8_t proto
Definition ip.h:127
beuint16_t wLength
Definition ip.h:123
uint8_t bTTL
Definition ip.h:126
uint8_t bTos
Definition ip.h:122
beuint16_t wpktId
Definition ip.h:124
uint8_t bVerHdrLen
Definition ip.h:121
IPADDR4 ipDst
Definition ip.h:133
beuint16_t wFlags_Frag
Definition ip.h:125
Internal UDP Header.
Definition ip.h:141
beuint16_t dstPort
Destination port number.
Definition ip.h:143
beuint16_t srcPort
Source port number.
Definition ip.h:142
uint16_t UdpCSum
Checksum (zero in IPv4) Do not make big endian, see IPPKT.
Definition ip.h:148
beuint16_t UdpLen
Datagram length including header.
Definition ip.h:144