Documentation
¶
Index ¶
- Variables
- func BuildIPv4Header(header IPv4Header) (*bitstring.BitString, error)
- func BuildNetworkPacket(packet NetworkPacket) (*bitstring.BitString, error)
- func BuildPNGChunk(chunk PNGChunk) ([]byte, error)
- func BuildPNGHeader(header PNGHeader) (*bitstring.BitString, error)
- func BuildTCPFlags(flags TCPFlags) (*bitstring.BitString, error)
- func BuildTCPHeader(header TCPHeader) (*bitstring.BitString, error)
- func FormatIPAddress(ip uint32) string
- func FormatNetworkPacketInfo(packet *NetworkPacket) string
- func FormatPNGIHDRInfo(ihdr *PNGIHDRChunk) string
- func GetIPv4HeaderLength(header *IPv4Header) uint
- func GetIPv4PayloadLength(header *IPv4Header) uint
- func GetPNGColorTypeName(colorType uint8) string
- func GetPNGInterlaceMethodName(interlace uint8) string
- func GetTCPFlagsString(flags TCPFlags) string
- func GetTCPHeaderLength(header *TCPHeader) uint
- func IsTCPConnectionEstablished(flags TCPFlags) bool
- func IsTCPConnectionEstablishment(flags TCPFlags) bool
- func IsTCPConnectionTermination(flags TCPFlags) bool
- func IsTCPDataPacket(flags TCPFlags) bool
- func ParseIPAddress(ipStr string) (uint32, error)
- func ValidateIPv4Header(header *IPv4Header) error
- func ValidateNetworkPacket(packet *NetworkPacket) error
- func ValidatePNGChunk(chunk *PNGChunk) error
- func ValidatePNGHeader(header *PNGHeader) error
- func ValidatePNGIHDRChunk(ihdr *PNGIHDRChunk) error
- func ValidateTCPFlags(flags *TCPFlags) error
- func ValidateTCPHeader(header *TCPHeader) error
- type IPv4Header
- type NetworkPacket
- type PNGChunk
- type PNGHeader
- type PNGIHDRChunk
- type TCPFlags
- type TCPHeader
Constants ¶
This section is empty.
Variables ¶
var PNGSignature = []byte{137, 80, 78, 71, 13, 10, 26, 10}
PNGSignature represents the PNG file signature
Functions ¶
func BuildIPv4Header ¶
func BuildIPv4Header(header IPv4Header) (*bitstring.BitString, error)
BuildIPv4Header creates an IPv4 header from a structure
func BuildNetworkPacket ¶
func BuildNetworkPacket(packet NetworkPacket) (*bitstring.BitString, error)
BuildNetworkPacket creates a network packet from a structure
func BuildPNGChunk ¶
BuildPNGChunk creates a PNG chunk from a structure
func BuildPNGHeader ¶
BuildPNGHeader creates a PNG header from a structure
func BuildTCPFlags ¶
BuildTCPFlags creates TCP flags from a structure
func BuildTCPHeader ¶
BuildTCPHeader creates a complete TCP header from a structure
func FormatIPAddress ¶
FormatIPAddress formats an IP address from uint32 to string
func FormatNetworkPacketInfo ¶
func FormatNetworkPacketInfo(packet *NetworkPacket) string
FormatNetworkPacketInfo formats network packet information for output
func FormatPNGIHDRInfo ¶
func FormatPNGIHDRInfo(ihdr *PNGIHDRChunk) string
FormatPNGIHDRInfo formats IHDR chunk information for output
func GetIPv4HeaderLength ¶
func GetIPv4HeaderLength(header *IPv4Header) uint
GetIPv4HeaderLength returns the header length in bytes
func GetIPv4PayloadLength ¶
func GetIPv4PayloadLength(header *IPv4Header) uint
GetIPv4PayloadLength returns the payload length in bytes
func GetPNGColorTypeName ¶
GetPNGColorTypeName returns the color type name
func GetPNGInterlaceMethodName ¶
GetPNGInterlaceMethodName returns the interlace method name
func GetTCPFlagsString ¶
GetTCPFlagsString returns a string representation of set flags
func GetTCPHeaderLength ¶
GetTCPHeaderLength returns the TCP header length in bytes
func IsTCPConnectionEstablished ¶
IsTCPConnectionEstablished checks if the packet is a connection establishment confirmation (SYN+ACK)
func IsTCPConnectionEstablishment ¶
IsTCPConnectionEstablishment checks if the packet is a connection establishment (SYN)
func IsTCPConnectionTermination ¶
IsTCPConnectionTermination checks if the packet is a connection termination (FIN or RST)
func IsTCPDataPacket ¶
IsTCPDataPacket checks if the packet contains data (PSH and ACK)
func ParseIPAddress ¶
ParseIPAddress parses an IP address from string to uint32
func ValidateIPv4Header ¶
func ValidateIPv4Header(header *IPv4Header) error
ValidateIPv4Header performs full validation of an IPv4 header
func ValidateNetworkPacket ¶
func ValidateNetworkPacket(packet *NetworkPacket) error
ValidateNetworkPacket performs full validation of a network packet
func ValidatePNGChunk ¶
ValidatePNGChunk performs PNG chunk validation
func ValidatePNGHeader ¶
ValidatePNGHeader performs PNG header validation
func ValidatePNGIHDRChunk ¶
func ValidatePNGIHDRChunk(ihdr *PNGIHDRChunk) error
ValidatePNGIHDRChunk performs IHDR chunk validation
func ValidateTCPFlags ¶
ValidateTCPFlags performs validation of TCP flags
func ValidateTCPHeader ¶
ValidateTCPHeader performs full validation of a TCP header
Types ¶
type IPv4Header ¶
type IPv4Header struct {
Version uint // Version (4 bits)
HeaderLength uint // Header length (4 bits)
ServiceType uint // Service type (8 bits)
TotalLength uint // Total length (16 bits)
Identification uint // Identification (16 bits)
Flags uint // Flags (3 bits)
FragmentOffset uint // Fragment offset (13 bits)
TTL uint // Time to live (8 bits)
Protocol uint // Protocol (8 bits)
Checksum uint // Checksum (16 bits)
SourceIP uint // Source IP address (32 bits)
DestinationIP uint // Destination IP address (32 bits)
}
IPv4Header represents the structure of an IPv4 header
func ParseIPv4Header ¶
func ParseIPv4Header(data *bitstring.BitString) (*IPv4Header, error)
ParseIPv4Header parses an IPv4 header from a bitstring
type NetworkPacket ¶
type NetworkPacket struct {
IPv4Header IPv4Header
TCPHeader TCPHeader
Payload []byte
}
NetworkPacket represents a network packet with IPv4 and TCP headers
func CreateHTTPPacket ¶
func CreateHTTPPacket(srcIP, dstIP string, srcPort, dstPort uint16, method, path, host string) (*NetworkPacket, error)
CreateHTTPPacket creates an HTTP request packet
func CreateTCPSynPacket ¶
func CreateTCPSynPacket(srcIP, dstIP string, srcPort, dstPort uint16) (*NetworkPacket, error)
CreateTCPSynPacket creates a TCP SYN packet for connection establishment
func ParseNetworkPacket ¶
func ParseNetworkPacket(data *bitstring.BitString) (*NetworkPacket, error)
ParseNetworkPacket parses a network packet from a bitstring
type PNGChunk ¶
type PNGChunk struct {
Length uint32 // Chunk data length (4 bytes)
Type []byte // Chunk type (4 bytes)
Data []byte // Chunk data (variable length)
CRC uint32 // CRC32 checksum (4 bytes)
}
PNGChunk represents the structure of a PNG chunk
func BuildPNGIHDRChunk ¶
func BuildPNGIHDRChunk(ihdr PNGIHDRChunk) (PNGChunk, error)
BuildPNGIHDRChunk creates an IHDR chunk from a structure
type PNGHeader ¶
type PNGHeader struct {
Signature []byte // PNG signature (8 bytes)
Chunks []PNGChunk // PNG chunks
}
PNGHeader represents the structure of a PNG header
type PNGIHDRChunk ¶
type PNGIHDRChunk struct {
Width uint32 // Image width (4 bytes)
Height uint32 // Image height (4 bytes)
BitDepth uint8 // Color depth (1 byte)
ColorType uint8 // Color type (1 byte)
Compression uint8 // Compression method (1 byte)
Filter uint8 // Filter method (1 byte)
Interlace uint8 // Interlace method (1 byte)
}
PNGIHDRChunk represents the IHDR chunk of PNG (image header)
func ParsePNGIHDRChunk ¶
func ParsePNGIHDRChunk(data []byte) (*PNGIHDRChunk, error)
ParsePNGIHDRChunk parses an IHDR chunk from data
type TCPFlags ¶
type TCPFlags struct {
Reserved uint // Reserved bits (2 bits)
URG uint // Urgent flag (1 bit)
ACK uint // Acknowledgment flag (1 bit)
PSH uint // Push flag (1 bit)
RST uint // Reset flag (1 bit)
SYN uint // Synchronize flag (1 bit)
FIN uint // Finish flag (1 bit)
}
TCPFlags represents the structure of TCP flags
type TCPHeader ¶
type TCPHeader struct {
SourcePort uint // Source port (16 bits)
DestinationPort uint // Destination port (16 bits)
SequenceNumber uint // Sequence number (32 bits)
Acknowledgment uint // Acknowledgment number (32 bits)
DataOffset uint // Data offset (4 bits)
Reserved uint // Reserved (3 bits)
Flags TCPFlags // Flags (9 bits: 2 reserved + 7 flags)
Window uint // Window size (16 bits)
Checksum uint // Checksum (16 bits)
UrgentPointer uint // Urgent pointer (16 bits)
}
TCPHeader represents a complete TCP header