L4Re Operating System Framework
Interface and Usage Documentation
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
h
i
k
m
o
p
r
s
t
u
w
Functions
a
b
c
k
m
r
s
t
w
Variables
Typedefs
Enumerations
Enumerator
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Typedefs
_
a
b
c
d
e
f
g
i
k
m
n
o
p
r
s
t
v
w
Enumerations
a
c
d
e
f
i
m
n
p
q
r
s
t
v
Enumerator
a
b
c
d
e
f
g
i
k
l
m
n
o
p
r
s
t
u
w
x
Related Symbols
Files
File List
Globals
All
_
a
b
d
e
f
g
l
m
n
o
p
r
s
Functions
_
b
e
f
g
l
o
p
Typedefs
e
g
l
p
Enumerations
e
l
p
Enumerator
a
d
e
f
l
n
p
r
s
Macros
_
e
g
l
m
p
s
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
filter.cc
1
/*
2
* Copyright (C) 2016-2017, 2024 Kernkonzept GmbH.
3
* Author(s): Jean Wolter <jean.wolter@kernkonzept.com>
4
*
5
* License: see LICENSE.spdx (in this directory or the directories above)
6
*/
7
#include "filter.h"
8
9
/* This is an example filter and therefore rather verbose. A real
10
filter would not produce any output */
11
12
bool
13
filter(
const
uint8_t *buf,
size_t
size)
14
{
15
// Packet large enough to apply filter condition?
16
if
(size <= 13)
17
return
false
;
18
19
uint16_t ether_type = (uint16_t)*(buf + 12) << 8
20
| (uint16_t)*(buf + 13);
21
char
const
*protocol;
22
switch
(ether_type)
23
{
24
case
0x0800: protocol =
"IPv4"
;
break
;
25
case
0x0806: protocol =
"ARP"
;
break
;
26
case
0x8100: protocol =
"Vlan"
;
break
;
27
case
0x86dd: protocol =
"IPv6"
;
break
;
28
case
0x8863: protocol =
"PPPoE Discovery"
;
break
;
29
case
0x8864: protocol =
"PPPoE Session"
;
break
;
30
default
: protocol =
nullptr
;
31
}
32
if
(protocol)
33
printf(
"%s\n"
, protocol);
34
else
35
printf(
"%04x\n"
, ether_type);
36
37
if
(ether_type == 0x0806)
38
{
39
printf(
"Do not filter arp\n"
);
40
return
false
;
41
}
42
43
return
true
;
44
}
pkg
virtio-net-switch
server
switch
filter.cc
Generated on Mon Mar 3 2025 23:08:49 for L4Re Operating System Framework by
1.9.8