Definiciones | |
#define | IP_HEADER_LEN 20 |
#define | IP_V4_V 0x40 |
#define | IP_HEADER_LENGTH_V 0x05 |
Valores de protocolos sobre IP | |
Campo IP_PROTO | |
#define | IP_PROTO_ICMP_V 0x01 |
#define | IP_PROTO_TCP_V 0x06 |
#define | IP_PROTO_UDP_V 0x11 |
Posicion de los distintos campos | |
#define | IP_P 0x0E |
#define | IP_HEADER_VER_LEN_P 0x0E |
#define | IP_TOS_P 0x0F |
#define | IP_TOTLEN_H_P 0x10 |
#define | IP_TOTLEN_L_P 0x11 |
#define | IP_ID_H_P 0x12 |
#define | IP_ID_L_P 0x13 |
#define | IP_FLAGS_H_P 0x14 |
#define | IP_FLAGS_L_P 0x15 |
#define | IP_TTL_P 0x16 |
#define | IP_PROTO_P 0x17 |
#define | IP_CHECKSUM_H_P 0x18 |
#define | IP_CHECKSUM_L_P 0x19 |
#define | IP_SRC_IP_P 0x1A |
#define | IP_DST_IP_P 0x1E |
Funciones | |
BYTE | ip_packet_is_ip (BYTE *rxtx_buffer) |
Chequea si un paquete recibido es IP . | |
void | ip_generate_header (BYTE *rxtx_buffer, WORD_BYTES total_length, BYTE protocol, BYTE *dest_ip) |
Genera el encabezado IP . |
Contiene la definicion de los diferentes campos del paquete IP y valores tipicos.
#define IP_CHECKSUM_H_P 0x18 |
#define IP_CHECKSUM_L_P 0x19 |
#define IP_DST_IP_P 0x1E |
#define IP_FLAGS_H_P 0x14 |
#define IP_FLAGS_L_P 0x15 |
#define IP_HEADER_LEN 20 |
#define IP_HEADER_LENGTH_V 0x05 |
#define IP_HEADER_VER_LEN_P 0x0E |
#define IP_ID_H_P 0x12 |
#define IP_ID_L_P 0x13 |
#define IP_P 0x0E |
#define IP_PROTO_ICMP_V 0x01 |
#define IP_PROTO_P 0x17 |
#define IP_PROTO_TCP_V 0x06 |
#define IP_PROTO_UDP_V 0x11 |
#define IP_SRC_IP_P 0x1A |
#define IP_TOS_P 0x0F |
#define IP_TOTLEN_H_P 0x10 |
#define IP_TOTLEN_L_P 0x11 |
#define IP_TTL_P 0x16 |
#define IP_V4_V 0x40 |
void ip_generate_header | ( | BYTE * | rxtx_buffer, | |
WORD_BYTES | total_length, | |||
BYTE | protocol, | |||
BYTE * | dest_ip | |||
) |
Genera el encabezado IP
.
rxtx_buffer | el buffer que se utilizara para generar el encabezado. | |
total_length | largo total del paquete. | |
protocol | protocolo utilizado en la capa superior | |
dest_ip | IP de destino del paquete |
set ipv4 and header length
set TOS to default 0x00
set total length
set packet identification
set fragment flags
set Time To Live
set ip packettype to tcp/udp/icmp...
set source and destination ip address
clear the 2 byte checksum
calculate and fill the checksum:
Chequea si un paquete recibido es IP
.
rxtx_buffer | puntero al paquete. |