NetBurner 3.5.0
PDF Version
 
IP

Definitions for various IP definitions and structures. More...

Topics

 IPADDR4 Class
 
 IPADDR6 Class
 

Classes

struct  _IpHeaderIPv4
 IP Header (IPv4) More...
 
struct  IPPKT
 Internal IPv4 Header. More...
 
struct  UDPPKT
 Internal UDP Header. More...
 
struct  PsudeoHeader
 UDP IPv4 Pseudo-header segment (bits 0 through 95) More...
 

Macros

#define ICMP_PING_DATA_SIZE   (32)
 size for ICMP echo request and replay ("ping")
 

Typedefs

typedef struct _IpHeaderIPv4 IpHeaderIPv4
 IP Header (IPv4)
 

Functions

void IpProcessEthernetPacket (PoolPtr poolPtr, uint16_t packetSizeInBytes)
 IP packet insertion for processing.
 
uint16_t GetSum (puint16_t addr, uint16_t count)
 Checksum.
 
uint16_t GetSum20 (puint32_t addr)
 Checksum.
 
uint16_t GetSumHdr (PsudeoHeader &hdr, puint16_t addr, uint16_t count)
 Checksum using pseudo-header.
 
BOOL IsMyIp4 (IPADDR4 ip, int ifc=-1)
 Is this my IP address?
 
IPADDR4 GetSrcIp4 (IPADDR4 dst)
 Get source IP address for this destination.
 
IPADDR4 GetSrcIpwIf4 (int ifn, const IPADDR4 dst)
 
BOOL IsMyIp (const IPADDR &ip, int ifc=-1)
 Is this my IP address?
 
IPADDR GetSrcIp (const IPADDR &dst)
 Get source IP address for this destination.
 
IPADDR GetSrcIpwIf (int ifn, const IPADDR &dst)
 Get source IP address for an interface.
 
void SendICMPError (PoolPtr pBadPacket, uint8_t type, uint8_t code)
 Send ICMP error.
 
void FixHeaderAndSend (PoolPtr p, PIPPKT pIp)
 Complete header and send on primary network interface.
 
void FixHeaderAndSendViaInterface (PoolPtr p, PIPPKT pIp, int Interface)
 Complete header and send on an interface.
 
void InitializeStack ()
 Initializes the IP stack.
 
int AddInterface (IPADDR4 addr, IPADDR4 mask, IPADDR4 gateway, int root_if)
 Add an interface with an interface number.
 

Global Data

uint8_t bTTL_Default
 Default number of hops (time to live)
 
uint16_t wArpLifetime
 ARP lifetime in seconds.
 
BOOL bQuietStart
 Quiet start.
 

Get Packet Functions

WARNING:
If you use these functions on an uninitialized buffer you will get bogus values for the pointer as the header length field in the IP packet is not yet set up!
PIPPKT GetIpPkt (PoolPtr p)
 Get IP Packet pointer from network buffer pool buffer.
 
PIPPKT GetIpPkt (PEFRAME pFrame)
 Get IP packet pointer from pointer to frame.
 
PIPPKT GetIpPkt (PVLEFRAME pFrame)
 Get IP Packet pointer from network buffer pool buffer.
 
PUDPPKT GetUdpPkt (PIPPKT pIp)
 Get UPD packet pointer from IP packet pointer.
 

IP Version

Uncomment for debugging

#define IP_VERSION_MASK   (0xF0)
 Version Mask.
 
#define IP_VERSION_IPv4   (0x40)
 IPv4.
 
#define IP_VERSION_IPv6   (0x60)
 IPv6.
 

Header Length

#define IP_HEADER_LENGTH_MASK   (0x0F)
 
#define IP_HEADER_LENGTH_NO_OPTIONS   (0x05)
 

Flags and Fragment Offset

#define IP_FLAGS_MASK   (0xE000)
 
#define IP_FRAGMENT_OFFSET_MASK   (0x1FFF)
 

IP protocol numbers

#define IP_PROTOCOL_ICMP   (0x01)
 
#define IP_PROTOCOL_IGMP   (0x02)
 
#define IP_PROTOCOL_INTERNET   (0x04)
 
#define IP_PROTOCOL_TCP   (0x06)
 
#define IP_PROTOCOL_UDP   (0x11)
 

control message type(s) and code(s)

#define ICMP_TYPE_ECHO_REPLY   (0)
 
#define ICMP_CODE_ECHO_REPLY   (0)
 
#define ICMP_TYPE_DEST_UNREACHABLE   (3)
 
#define ICMP_CODE_PORT_UNREACHABLE   (3)
 
#define ICMP_TYPE_SOURCE_QUENCH   (4)
 
#define ICMP_CODE_SOURCE_QUENCH   (0)
 
#define ICMP_TYPE_REDIRECT_MESSAGE   (5)
 
#define ICMP_TYPE_ECHO_REQUEST   (8)
 
#define ICMP_CODE_ECHO_REQUEST   (0)
 

Well Known Ports

#define IANA_ECHO_PORT   (7)
 
#define IANA_DISCARD_PORT   (9)
 
#define IANA_SSH_PORT   (22)
 
#define IANA_TELNET_PORT   (23)
 
#define IANA_NETBIOS_NAME_SERVICE_PORT   (137)
 

Detailed Description

Definitions for various IP definitions and structures.

#include< ip.h >

Macro Definition Documentation

◆ IANA_DISCARD_PORT

#define IANA_DISCARD_PORT   (9)

#include <ip.h>

◆ IANA_ECHO_PORT

#define IANA_ECHO_PORT   (7)

#include <ip.h>

◆ IANA_NETBIOS_NAME_SERVICE_PORT

#define IANA_NETBIOS_NAME_SERVICE_PORT   (137)

#include <ip.h>

◆ IANA_SSH_PORT

#define IANA_SSH_PORT   (22)

#include <ip.h>

◆ IANA_TELNET_PORT

#define IANA_TELNET_PORT   (23)

#include <ip.h>

◆ ICMP_CODE_ECHO_REPLY

#define ICMP_CODE_ECHO_REPLY   (0)

#include <ip.h>

◆ ICMP_CODE_ECHO_REQUEST

#define ICMP_CODE_ECHO_REQUEST   (0)

#include <ip.h>

◆ ICMP_CODE_PORT_UNREACHABLE

#define ICMP_CODE_PORT_UNREACHABLE   (3)

#include <ip.h>

◆ ICMP_CODE_SOURCE_QUENCH

#define ICMP_CODE_SOURCE_QUENCH   (0)

#include <ip.h>

◆ ICMP_TYPE_DEST_UNREACHABLE

#define ICMP_TYPE_DEST_UNREACHABLE   (3)

#include <ip.h>

◆ ICMP_TYPE_ECHO_REPLY

#define ICMP_TYPE_ECHO_REPLY   (0)

#include <ip.h>

◆ ICMP_TYPE_ECHO_REQUEST

#define ICMP_TYPE_ECHO_REQUEST   (8)

#include <ip.h>

◆ ICMP_TYPE_REDIRECT_MESSAGE

#define ICMP_TYPE_REDIRECT_MESSAGE   (5)

#include <ip.h>

◆ ICMP_TYPE_SOURCE_QUENCH

#define ICMP_TYPE_SOURCE_QUENCH   (4)

#include <ip.h>

◆ IP_FLAGS_MASK

#define IP_FLAGS_MASK   (0xE000)

#include <ip.h>

◆ IP_FRAGMENT_OFFSET_MASK

#define IP_FRAGMENT_OFFSET_MASK   (0x1FFF)

#include <ip.h>

◆ IP_HEADER_LENGTH_MASK

#define IP_HEADER_LENGTH_MASK   (0x0F)

#include <ip.h>

◆ IP_HEADER_LENGTH_NO_OPTIONS

#define IP_HEADER_LENGTH_NO_OPTIONS   (0x05)

#include <ip.h>

◆ IP_PROTOCOL_ICMP

#define IP_PROTOCOL_ICMP   (0x01)

#include <ip.h>

◆ IP_PROTOCOL_IGMP

#define IP_PROTOCOL_IGMP   (0x02)

#include <ip.h>

◆ IP_PROTOCOL_INTERNET

#define IP_PROTOCOL_INTERNET   (0x04)

#include <ip.h>

◆ IP_PROTOCOL_TCP

#define IP_PROTOCOL_TCP   (0x06)

#include <ip.h>

◆ IP_PROTOCOL_UDP

#define IP_PROTOCOL_UDP   (0x11)

#include <ip.h>

Typedef Documentation

◆ IpHeaderIPv4

typedef struct _IpHeaderIPv4 IpHeaderIPv4

#include <ip.h>

IP Header (IPv4)

Can contain options, determined by header length. No options header length is 5 for 5 32 bit words ( 20 bytes ) IETF RFC 791 September 1981, MIL-STD-1777

Function Documentation

◆ AddInterface()

int AddInterface ( IPADDR4 addr,
IPADDR4 mask,
IPADDR4 gateway,
int root_if = 0 )
inline

#include <ip.h>

Add an interface with an interface number.

Parameters
addrIP address of new interface
maskIP mask
gatewayIP gateway
root_ifOptional root physical interface number. If not specified the default is 0, for Ethernt 0.

returns Interface number of newly created interface

◆ GetIpPkt()

PIPPKT GetIpPkt ( PVLEFRAME pFrame)
inline

#include <ip.h>

Get IP Packet pointer from network buffer pool buffer.

◆ GetSrcIpwIf4()

IPADDR4 GetSrcIpwIf4 ( int ifn,
const IPADDR4 dst )

#include <ip.h>

◆ InitializeStack()

void InitializeStack ( )

#include <ip.h>

Initializes the IP stack.

Should be called once and only once before UserMain resets its priority. The default settings cause the configuration record settings to be used. This provides the network infrastructure for additional network interfaces.