eBPF for Windows
include
net
tcp.h
Go to the documentation of this file.
1
// Copyright (c) eBPF for Windows contributors
2
// SPDX-License-Identifier: MIT
3
#pragma once
4
5
#pragma pack(push)
6
#pragma pack(1)
7
struct
tcphdr
8
{
9
uint16_t
source
;
10
uint16_t
dest
;
11
uint32_t
seq
;
// Sequence Number
12
uint32_t
ack_seq
;
// Acknowledgement Number
13
14
// List bits in each byte from right (low) to left (high).
15
uint16_t
ns
: 1;
16
uint16_t
reserved
: 3;
17
uint16_t
doff
: 4;
// Data Offset
18
19
uint16_t
fin
: 1;
20
uint16_t
syn
: 1;
21
uint16_t
rst
: 1;
22
uint16_t
psh
: 1;
23
uint16_t
ack
: 1;
24
uint16_t
urg
: 1;
25
uint16_t
ece
: 1;
26
uint16_t
cwr
: 1;
27
28
uint16_t
window
;
// Window Size
29
uint16_t
check
;
// Checksum
30
uint16_t
urg_ptr
;
// Urgent Pointer
31
};
32
#pragma pack(pop)
33
34
#ifndef FIELD_OFFSET
35
#define FIELD_OFFSET(type, field) ((long)&(((type*)0)->field))
36
#endif
37
38
// check the offset of each field
39
static_assert(
FIELD_OFFSET
(
struct
tcphdr
, source) == 0,
"source offset mismatch"
);
40
static_assert(
FIELD_OFFSET
(
struct
tcphdr
, dest) == 2,
"dest offset mismatch"
);
41
static_assert(
FIELD_OFFSET
(
struct
tcphdr
, seq) == 4,
"seq offset mismatch"
);
42
static_assert(
FIELD_OFFSET
(
struct
tcphdr
, ack_seq) == 8,
"ack_seq offset mismatch"
);
43
// Skip bit fields
44
static_assert(
FIELD_OFFSET
(
struct
tcphdr
, window) == 14,
"window offset mismatch"
);
45
static_assert(
FIELD_OFFSET
(
struct
tcphdr
, check) == 16,
"check offset mismatch"
);
46
static_assert(
FIELD_OFFSET
(
struct
tcphdr
, urg_ptr) == 18,
"urg_ptr offset mismatch"
);
FIELD_OFFSET
#define FIELD_OFFSET(type, field)
Definition:
tcp.h:35
tcphdr
Definition:
tcp.h:8
tcphdr::urg_ptr
uint16_t urg_ptr
Definition:
tcp.h:30
tcphdr::dest
uint16_t dest
Definition:
tcp.h:10
tcphdr::fin
uint16_t fin
Definition:
tcp.h:19
tcphdr::psh
uint16_t psh
Definition:
tcp.h:22
tcphdr::ece
uint16_t ece
Definition:
tcp.h:25
tcphdr::window
uint16_t window
Definition:
tcp.h:28
tcphdr::rst
uint16_t rst
Definition:
tcp.h:21
tcphdr::syn
uint16_t syn
Definition:
tcp.h:20
tcphdr::ack
uint16_t ack
Definition:
tcp.h:23
tcphdr::check
uint16_t check
Definition:
tcp.h:29
tcphdr::seq
uint32_t seq
Definition:
tcp.h:11
tcphdr::doff
uint16_t doff
Definition:
tcp.h:17
tcphdr::source
uint16_t source
Definition:
tcp.h:9
tcphdr::reserved
uint16_t reserved
Definition:
tcp.h:16
tcphdr::urg
uint16_t urg
Definition:
tcp.h:24
tcphdr::ns
uint16_t ns
Definition:
tcp.h:15
tcphdr::cwr
uint16_t cwr
Definition:
tcp.h:26
tcphdr::ack_seq
uint32_t ack_seq
Definition:
tcp.h:12
Generated by
1.9.1