Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
iproute2
Commits
5cf35d6a
Commit
5cf35d6a
authored
May 17, 2013
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add BPF header files
For later ss change.
parent
2a126a85
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
217 additions
and
0 deletions
+217
-0
include/linux/filter.h
include/linux/filter.h
+138
-0
include/linux/packet_diag.h
include/linux/packet_diag.h
+79
-0
No files found.
include/linux/filter.h
0 → 100644
View file @
5cf35d6a
/*
* Linux Socket Filter Data Structures
*/
#ifndef __LINUX_FILTER_H__
#define __LINUX_FILTER_H__
#include <linux/types.h>
/*
* Current version of the filter code architecture.
*/
#define BPF_MAJOR_VERSION 1
#define BPF_MINOR_VERSION 1
/*
* Try and keep these values and structures similar to BSD, especially
* the BPF code definitions which need to match so you can share filters
*/
struct
sock_filter
{
/* Filter block */
__u16
code
;
/* Actual filter code */
__u8
jt
;
/* Jump true */
__u8
jf
;
/* Jump false */
__u32
k
;
/* Generic multiuse field */
};
struct
sock_fprog
{
/* Required for SO_ATTACH_FILTER. */
unsigned
short
len
;
/* Number of filter blocks */
struct
sock_filter
*
filter
;
};
/*
* Instruction classes
*/
#define BPF_CLASS(code) ((code) & 0x07)
#define BPF_LD 0x00
#define BPF_LDX 0x01
#define BPF_ST 0x02
#define BPF_STX 0x03
#define BPF_ALU 0x04
#define BPF_JMP 0x05
#define BPF_RET 0x06
#define BPF_MISC 0x07
/* ld/ldx fields */
#define BPF_SIZE(code) ((code) & 0x18)
#define BPF_W 0x00
#define BPF_H 0x08
#define BPF_B 0x10
#define BPF_MODE(code) ((code) & 0xe0)
#define BPF_IMM 0x00
#define BPF_ABS 0x20
#define BPF_IND 0x40
#define BPF_MEM 0x60
#define BPF_LEN 0x80
#define BPF_MSH 0xa0
/* alu/jmp fields */
#define BPF_OP(code) ((code) & 0xf0)
#define BPF_ADD 0x00
#define BPF_SUB 0x10
#define BPF_MUL 0x20
#define BPF_DIV 0x30
#define BPF_OR 0x40
#define BPF_AND 0x50
#define BPF_LSH 0x60
#define BPF_RSH 0x70
#define BPF_NEG 0x80
#define BPF_MOD 0x90
#define BPF_XOR 0xa0
#define BPF_JA 0x00
#define BPF_JEQ 0x10
#define BPF_JGT 0x20
#define BPF_JGE 0x30
#define BPF_JSET 0x40
#define BPF_SRC(code) ((code) & 0x08)
#define BPF_K 0x00
#define BPF_X 0x08
/* ret - BPF_K and BPF_X also apply */
#define BPF_RVAL(code) ((code) & 0x18)
#define BPF_A 0x10
/* misc */
#define BPF_MISCOP(code) ((code) & 0xf8)
#define BPF_TAX 0x00
#define BPF_TXA 0x80
#ifndef BPF_MAXINSNS
#define BPF_MAXINSNS 4096
#endif
/*
* Macros for filter block array initializers.
*/
#ifndef BPF_STMT
#define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
#endif
#ifndef BPF_JUMP
#define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k }
#endif
/*
* Number of scratch memory words for: BPF_ST and BPF_STX
*/
#define BPF_MEMWORDS 16
/* RATIONALE. Negative offsets are invalid in BPF.
We use them to reference ancillary data.
Unlike introduction new instructions, it does not break
existing compilers/optimizers.
*/
#define SKF_AD_OFF (-0x1000)
#define SKF_AD_PROTOCOL 0
#define SKF_AD_PKTTYPE 4
#define SKF_AD_IFINDEX 8
#define SKF_AD_NLATTR 12
#define SKF_AD_NLATTR_NEST 16
#define SKF_AD_MARK 20
#define SKF_AD_QUEUE 24
#define SKF_AD_HATYPE 28
#define SKF_AD_RXHASH 32
#define SKF_AD_CPU 36
#define SKF_AD_ALU_XOR_X 40
#define SKF_AD_VLAN_TAG 44
#define SKF_AD_VLAN_TAG_PRESENT 48
#define SKF_AD_PAY_OFFSET 52
#define SKF_AD_MAX 56
#define SKF_NET_OFF (-0x100000)
#define SKF_LL_OFF (-0x200000)
#endif
/* __LINUX_FILTER_H__ */
include/linux/packet_diag.h
0 → 100644
View file @
5cf35d6a
#ifndef __PACKET_DIAG_H__
#define __PACKET_DIAG_H__
#include <linux/types.h>
struct
packet_diag_req
{
__u8
sdiag_family
;
__u8
sdiag_protocol
;
__u16
pad
;
__u32
pdiag_ino
;
__u32
pdiag_show
;
__u32
pdiag_cookie
[
2
];
};
#define PACKET_SHOW_INFO 0x00000001
/* Basic packet_sk information */
#define PACKET_SHOW_MCLIST 0x00000002
/* A set of packet_diag_mclist-s */
#define PACKET_SHOW_RING_CFG 0x00000004
/* Rings configuration parameters */
#define PACKET_SHOW_FANOUT 0x00000008
#define PACKET_SHOW_MEMINFO 0x00000010
#define PACKET_SHOW_FILTER 0x00000020
struct
packet_diag_msg
{
__u8
pdiag_family
;
__u8
pdiag_type
;
__u16
pdiag_num
;
__u32
pdiag_ino
;
__u32
pdiag_cookie
[
2
];
};
enum
{
PACKET_DIAG_INFO
,
PACKET_DIAG_MCLIST
,
PACKET_DIAG_RX_RING
,
PACKET_DIAG_TX_RING
,
PACKET_DIAG_FANOUT
,
PACKET_DIAG_UID
,
PACKET_DIAG_MEMINFO
,
PACKET_DIAG_FILTER
,
__PACKET_DIAG_MAX
,
};
#define PACKET_DIAG_MAX (__PACKET_DIAG_MAX - 1)
struct
packet_diag_info
{
__u32
pdi_index
;
__u32
pdi_version
;
__u32
pdi_reserve
;
__u32
pdi_copy_thresh
;
__u32
pdi_tstamp
;
__u32
pdi_flags
;
#define PDI_RUNNING 0x1
#define PDI_AUXDATA 0x2
#define PDI_ORIGDEV 0x4
#define PDI_VNETHDR 0x8
#define PDI_LOSS 0x10
};
struct
packet_diag_mclist
{
__u32
pdmc_index
;
__u32
pdmc_count
;
__u16
pdmc_type
;
__u16
pdmc_alen
;
__u8
pdmc_addr
[
MAX_ADDR_LEN
];
};
struct
packet_diag_ring
{
__u32
pdr_block_size
;
__u32
pdr_block_nr
;
__u32
pdr_frame_size
;
__u32
pdr_frame_nr
;
__u32
pdr_retire_tmo
;
__u32
pdr_sizeof_priv
;
__u32
pdr_features
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment