This repository was archived by the owner on Sep 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathheaders.h
More file actions
65 lines (51 loc) · 1.78 KB
/
headers.h
File metadata and controls
65 lines (51 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CLERK_HEADERS_H_
#define CLERK_HEADERS_H_
#include <netinet/if_ether.h> // ethhdr
#define __FAVOR_BSD
#include <netinet/tcp.h> // tcphdr
#undef __FAVOR_BSD
#include <netinet/icmp6.h> // icmp6_hdr
#include <netinet/ip.h> // iphdr
#include <netinet/ip6.h> // ip6_hdr
#include <netinet/ip_icmp.h> // icmphdr
#include <netinet/udp.h> // udphdr
#include "util.h"
#include "stringpiece.h"
namespace clerk {
struct Headers {
Headers();
void Reset();
// Parse the given packet data, setting the found header pointers in this
// struct. Note that initially we expect to find an ethernet header first,
// other link types are not yet supported (though they could be later on).
void Parse(StringPiece p);
// These pointers are reset to NULL on every call to Parse, then those
// associated with the packet are set.
// Layer 2
const struct ethhdr* eth;
// Layer 3
const struct iphdr* ip4;
const struct ip6_hdr* ip6;
// Layer 4
const struct tcphdr* tcp;
const struct udphdr* udp;
const struct icmphdr* icmp4;
const struct icmp6_hdr* icmp6;
// Other metadata
const struct ip6_frag* ip6frag;
};
} // namespace clerk
#endif // CLERK_HEADERS_H_