mirror of
https://github.com/openharmony/device_rockchip.git
synced 2026-07-01 21:24:04 -04:00
add device_rockchip source
Signed-off-by: yanghongliang <yang_hongliang@hoperun.com>
This commit is contained in:
Executable
+25
@@ -0,0 +1,25 @@
|
||||
# Copyright (C) 2021 HiHope Open Source Organization .
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
group("products_group") {
|
||||
if (device_name == "rk3568") {
|
||||
deps = [
|
||||
"//device/rockchip/rk3568:rk3568_group",
|
||||
]
|
||||
}
|
||||
|
||||
deps += [
|
||||
"//device/rockchip/common:common_group",
|
||||
]
|
||||
}
|
||||
Executable
+176
@@ -0,0 +1,176 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -0,0 +1,36 @@
|
||||
# device_rockchip_build
|
||||
|
||||
#### Description
|
||||
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
@@ -0,0 +1,39 @@
|
||||
# device_rockchip_build
|
||||
|
||||
#### 介绍
|
||||
{**以下是 Gitee 平台说明,您可以替换此简介**
|
||||
Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
|
||||
无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
|
||||
|
||||
#### 软件架构
|
||||
软件架构说明
|
||||
|
||||
|
||||
#### 安装教程
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 使用说明
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"subsystem": "rockchip_products",
|
||||
"parts": {
|
||||
"rockchip_products": {
|
||||
"module_list": [
|
||||
"//device/rockchip/build:products_group"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
# Copyright (C) 2021 HiHope Open Source Organization .
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
print("common_group in")
|
||||
group("common_group") {
|
||||
deps = [
|
||||
"//device/rockchip/hardware/wifi:ap6xxx",
|
||||
"//device/rockchip/hardware/isp:isp",
|
||||
"//device/rockchip/hardware/mpp:mpp",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
# device_rockchip_common
|
||||
|
||||
#### Description
|
||||
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
@@ -0,0 +1,39 @@
|
||||
# device_rockchip_common
|
||||
|
||||
#### 介绍
|
||||
{**以下是 Gitee 平台说明,您可以替换此简介**
|
||||
Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
|
||||
无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
|
||||
|
||||
#### 软件架构
|
||||
软件架构说明
|
||||
|
||||
|
||||
#### 安装教程
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 使用说明
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
# Copyright (C) 2021 HiHope Open Source Organization .
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/ndk/ndk.gni")
|
||||
|
||||
ohos_prebuilt_shared_library("display_gralloc") {
|
||||
if (target_cpu == "arm") {
|
||||
source = "lib/libdisplay_gralloc.z.so"
|
||||
}
|
||||
subsystem_name = "hdf"
|
||||
part_name = "hdf"
|
||||
install_enable = true
|
||||
# output_name = "display_gralloc.z"
|
||||
}
|
||||
|
||||
ohos_prebuilt_shared_library("display_gfx") {
|
||||
if (target_cpu == "arm") {
|
||||
source = "lib/libdisplay_gfx.z.so"
|
||||
}
|
||||
subsystem_name = "hdf"
|
||||
part_name = "hdf"
|
||||
install_enable = true
|
||||
# output_name = "display_gfx.z"
|
||||
}
|
||||
|
||||
ohos_prebuilt_shared_library("display_device") {
|
||||
if (target_cpu == "arm") {
|
||||
source = "lib/libdisplay_device_drm.z.so"
|
||||
}
|
||||
subsystem_name = "hdf"
|
||||
part_name = "hdf"
|
||||
install_enable = true
|
||||
# output_name = "display_device_drm.z"
|
||||
}
|
||||
|
||||
ohos_prebuilt_shared_library("display_layer") {
|
||||
if (target_cpu == "arm") {
|
||||
source = "lib/libdisplay_layer.z.so"
|
||||
}
|
||||
subsystem_name = "hdf"
|
||||
part_name = "hdf"
|
||||
install_enable = true
|
||||
# output_name = "display_device_drm.z"
|
||||
}
|
||||
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
+44
@@ -0,0 +1,44 @@
|
||||
# Copyright (C) 2021 HiHope Open Source Organization .
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/ndk/ndk.gni")
|
||||
|
||||
config("libmali-bifrost-g52-g2p0-wayland") {
|
||||
include_dirs = [ "include" ]
|
||||
cflags = [
|
||||
"-Wno-incompatible-pointer-types",
|
||||
"-Werror",
|
||||
"-Wimplicit-function-declaration",
|
||||
"-Wno-error=unused-variable",
|
||||
]
|
||||
cflags = []
|
||||
}
|
||||
|
||||
ohos_prebuilt_shared_library("mali-bifrost-g52-g2p0-wayland") {
|
||||
if (target_cpu == "arm") {
|
||||
source = "lib/libmali-bifrost-g52-g2p0-wayland.so"
|
||||
}
|
||||
subsystem_name = "hdf"
|
||||
part_name = "hdf"
|
||||
install_enable = true
|
||||
symlink_target_name = [
|
||||
"libEGL.so",
|
||||
"libGLESv1.so",
|
||||
"libGLESv2.so",
|
||||
"libGLESv3.so",
|
||||
"libgbm.so",
|
||||
"libmali.so.1",
|
||||
]
|
||||
}
|
||||
|
||||
Executable
+406
@@ -0,0 +1,406 @@
|
||||
/*
|
||||
* Copyright © 2011 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Benjamin Franzke <benjaminfranzke@googlemail.com>
|
||||
*/
|
||||
|
||||
#ifndef _GBM_H_
|
||||
#define _GBM_H_
|
||||
|
||||
#define __GBM__ 1
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \file gbm.h
|
||||
* \brief Generic Buffer Manager
|
||||
*/
|
||||
|
||||
struct gbm_device;
|
||||
struct gbm_bo;
|
||||
struct gbm_surface;
|
||||
|
||||
/**
|
||||
* \mainpage The Generic Buffer Manager
|
||||
*
|
||||
* This module provides an abstraction that the caller can use to request a
|
||||
* buffer from the underlying memory management system for the platform.
|
||||
*
|
||||
* This allows the creation of portable code whilst still allowing access to
|
||||
* the underlying memory manager.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstraction representing the handle to a buffer allocated by the
|
||||
* manager
|
||||
*/
|
||||
union gbm_bo_handle {
|
||||
void *ptr;
|
||||
int32_t s32;
|
||||
uint32_t u32;
|
||||
int64_t s64;
|
||||
uint64_t u64;
|
||||
};
|
||||
|
||||
/** Format of the allocated buffer */
|
||||
enum gbm_bo_format {
|
||||
/** RGB with 8 bits per channel in a 32 bit value */
|
||||
GBM_BO_FORMAT_XRGB8888,
|
||||
/** ARGB with 8 bits per channel in a 32 bit value */
|
||||
GBM_BO_FORMAT_ARGB8888
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The FourCC format codes are taken from the drm_fourcc.h definition, and
|
||||
* re-namespaced. New GBM formats must not be added, unless they are
|
||||
* identical ports from drm_fourcc.
|
||||
*/
|
||||
#define __gbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
|
||||
((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
|
||||
|
||||
#define GBM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */
|
||||
|
||||
/* color index */
|
||||
#define GBM_FORMAT_C8 __gbm_fourcc_code('C', '8', ' ', ' ') /* [7:0] C */
|
||||
|
||||
/* 8 bpp Red */
|
||||
#define GBM_FORMAT_R8 __gbm_fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
|
||||
|
||||
/* 16 bpp RG */
|
||||
#define GBM_FORMAT_GR88 __gbm_fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */
|
||||
|
||||
/* 8 bpp RGB */
|
||||
#define GBM_FORMAT_RGB332 __gbm_fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */
|
||||
#define GBM_FORMAT_BGR233 __gbm_fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */
|
||||
|
||||
/* 16 bpp RGB */
|
||||
#define GBM_FORMAT_XRGB4444 __gbm_fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_XBGR4444 __gbm_fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_RGBX4444 __gbm_fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_BGRX4444 __gbm_fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */
|
||||
|
||||
#define GBM_FORMAT_ARGB4444 __gbm_fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_ABGR4444 __gbm_fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_RGBA4444 __gbm_fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */
|
||||
#define GBM_FORMAT_BGRA4444 __gbm_fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */
|
||||
|
||||
#define GBM_FORMAT_XRGB1555 __gbm_fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */
|
||||
#define GBM_FORMAT_XBGR1555 __gbm_fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */
|
||||
#define GBM_FORMAT_RGBX5551 __gbm_fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */
|
||||
#define GBM_FORMAT_BGRX5551 __gbm_fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */
|
||||
|
||||
#define GBM_FORMAT_ARGB1555 __gbm_fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */
|
||||
#define GBM_FORMAT_ABGR1555 __gbm_fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */
|
||||
#define GBM_FORMAT_RGBA5551 __gbm_fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */
|
||||
#define GBM_FORMAT_BGRA5551 __gbm_fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */
|
||||
|
||||
#define GBM_FORMAT_RGB565 __gbm_fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */
|
||||
#define GBM_FORMAT_BGR565 __gbm_fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */
|
||||
|
||||
/* 24 bpp RGB */
|
||||
#define GBM_FORMAT_RGB888 __gbm_fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */
|
||||
#define GBM_FORMAT_BGR888 __gbm_fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */
|
||||
|
||||
/* 32 bpp RGB */
|
||||
#define GBM_FORMAT_XRGB8888 __gbm_fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_XBGR8888 __gbm_fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_RGBX8888 __gbm_fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_BGRX8888 __gbm_fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */
|
||||
|
||||
#define GBM_FORMAT_ARGB8888 __gbm_fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_ABGR8888 __gbm_fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_RGBA8888 __gbm_fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_BGRA8888 __gbm_fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */
|
||||
|
||||
#define GBM_FORMAT_XRGB2101010 __gbm_fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */
|
||||
#define GBM_FORMAT_XBGR2101010 __gbm_fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */
|
||||
#define GBM_FORMAT_RGBX1010102 __gbm_fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */
|
||||
#define GBM_FORMAT_BGRX1010102 __gbm_fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */
|
||||
|
||||
#define GBM_FORMAT_ARGB2101010 __gbm_fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */
|
||||
#define GBM_FORMAT_ABGR2101010 __gbm_fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */
|
||||
#define GBM_FORMAT_RGBA1010102 __gbm_fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */
|
||||
#define GBM_FORMAT_BGRA1010102 __gbm_fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */
|
||||
|
||||
/* packed YCbCr */
|
||||
#define GBM_FORMAT_YUYV __gbm_fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_YVYU __gbm_fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_UYVY __gbm_fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */
|
||||
#define GBM_FORMAT_VYUY __gbm_fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
|
||||
|
||||
#define GBM_FORMAT_AYUV __gbm_fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
|
||||
|
||||
/*
|
||||
* 2 plane YCbCr
|
||||
* index 0 = Y plane, [7:0] Y
|
||||
* index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian
|
||||
* or
|
||||
* index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian
|
||||
*/
|
||||
#define GBM_FORMAT_NV12 __gbm_fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */
|
||||
#define GBM_FORMAT_NV21 __gbm_fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */
|
||||
#define GBM_FORMAT_NV16 __gbm_fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */
|
||||
#define GBM_FORMAT_NV61 __gbm_fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */
|
||||
|
||||
/*
|
||||
* 3 plane YCbCr
|
||||
* index 0: Y plane, [7:0] Y
|
||||
* index 1: Cb plane, [7:0] Cb
|
||||
* index 2: Cr plane, [7:0] Cr
|
||||
* or
|
||||
* index 1: Cr plane, [7:0] Cr
|
||||
* index 2: Cb plane, [7:0] Cb
|
||||
*/
|
||||
#define GBM_FORMAT_YUV410 __gbm_fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */
|
||||
#define GBM_FORMAT_YVU410 __gbm_fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */
|
||||
#define GBM_FORMAT_YUV411 __gbm_fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */
|
||||
#define GBM_FORMAT_YVU411 __gbm_fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */
|
||||
#define GBM_FORMAT_YUV420 __gbm_fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */
|
||||
#define GBM_FORMAT_YVU420 __gbm_fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */
|
||||
#define GBM_FORMAT_YUV422 __gbm_fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */
|
||||
#define GBM_FORMAT_YVU422 __gbm_fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */
|
||||
#define GBM_FORMAT_YUV444 __gbm_fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */
|
||||
#define GBM_FORMAT_YVU444 __gbm_fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
|
||||
|
||||
|
||||
/**
|
||||
* Flags to indicate the intended use for the buffer - these are passed into
|
||||
* gbm_bo_create(). The caller must set the union of all the flags that are
|
||||
* appropriate
|
||||
*
|
||||
* \sa Use gbm_device_is_format_supported() to check if the combination of format
|
||||
* and use flags are supported
|
||||
*/
|
||||
enum gbm_bo_flags {
|
||||
/**
|
||||
* Buffer is going to be presented to the screen using an API such as KMS
|
||||
*/
|
||||
GBM_BO_USE_SCANOUT = (1 << 0),
|
||||
/**
|
||||
* Buffer is going to be used as cursor
|
||||
*/
|
||||
GBM_BO_USE_CURSOR = (1 << 1),
|
||||
/**
|
||||
* Deprecated
|
||||
*/
|
||||
GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR,
|
||||
/**
|
||||
* Buffer is to be used for rendering - for example it is going to be used
|
||||
* as the storage for a color buffer
|
||||
*/
|
||||
GBM_BO_USE_RENDERING = (1 << 2),
|
||||
/**
|
||||
* Buffer can be used for gbm_bo_write. This is guaranteed to work
|
||||
* with GBM_BO_USE_CURSOR, but may not work for other combinations.
|
||||
*/
|
||||
GBM_BO_USE_WRITE = (1 << 3),
|
||||
/**
|
||||
* Buffer is linear, i.e. not tiled.
|
||||
*/
|
||||
GBM_BO_USE_LINEAR = (1 << 4),
|
||||
};
|
||||
|
||||
int
|
||||
gbm_device_get_fd(struct gbm_device *gbm);
|
||||
|
||||
const char *
|
||||
gbm_device_get_backend_name(struct gbm_device *gbm);
|
||||
|
||||
int
|
||||
gbm_device_is_format_supported(struct gbm_device *gbm,
|
||||
uint32_t format, uint32_t usage);
|
||||
|
||||
int
|
||||
gbm_device_get_format_modifier_plane_count(struct gbm_device *gbm,
|
||||
uint32_t format,
|
||||
uint64_t modifier);
|
||||
|
||||
void
|
||||
gbm_device_destroy(struct gbm_device *gbm);
|
||||
|
||||
struct gbm_device *
|
||||
gbm_create_device(int fd);
|
||||
|
||||
struct gbm_bo *
|
||||
gbm_bo_create(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format, uint32_t flags);
|
||||
|
||||
struct gbm_bo *
|
||||
gbm_bo_create_with_modifiers(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format,
|
||||
const uint64_t *modifiers,
|
||||
const unsigned int count);
|
||||
#define GBM_BO_IMPORT_WL_BUFFER 0x5501
|
||||
#define GBM_BO_IMPORT_EGL_IMAGE 0x5502
|
||||
#define GBM_BO_IMPORT_FD 0x5503
|
||||
#define GBM_BO_IMPORT_FD_MODIFIER 0x5504
|
||||
|
||||
struct gbm_import_fd_data {
|
||||
int fd;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t stride;
|
||||
uint32_t format;
|
||||
};
|
||||
|
||||
struct gbm_import_fd_modifier_data {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
uint32_t num_fds;
|
||||
int fds[4];
|
||||
int strides[4];
|
||||
int offsets[4];
|
||||
uint64_t modifier;
|
||||
};
|
||||
|
||||
struct gbm_bo *
|
||||
gbm_bo_import(struct gbm_device *gbm, uint32_t type,
|
||||
void *buffer, uint32_t usage);
|
||||
|
||||
/**
|
||||
* Flags to indicate the type of mapping for the buffer - these are
|
||||
* passed into gbm_bo_map(). The caller must set the union of all the
|
||||
* flags that are appropriate.
|
||||
*
|
||||
* These flags are independent of the GBM_BO_USE_* creation flags. However,
|
||||
* mapping the buffer may require copying to/from a staging buffer.
|
||||
*
|
||||
* See also: pipe_transfer_usage
|
||||
*/
|
||||
enum gbm_bo_transfer_flags {
|
||||
/**
|
||||
* Buffer contents read back (or accessed directly) at transfer
|
||||
* create time.
|
||||
*/
|
||||
GBM_BO_TRANSFER_READ = (1 << 0),
|
||||
/**
|
||||
* Buffer contents will be written back at unmap time
|
||||
* (or modified as a result of being accessed directly).
|
||||
*/
|
||||
GBM_BO_TRANSFER_WRITE = (1 << 1),
|
||||
/**
|
||||
* Read/modify/write
|
||||
*/
|
||||
GBM_BO_TRANSFER_READ_WRITE = (GBM_BO_TRANSFER_READ | GBM_BO_TRANSFER_WRITE),
|
||||
};
|
||||
|
||||
void *
|
||||
gbm_bo_map(struct gbm_bo *bo,
|
||||
uint32_t x, uint32_t y, uint32_t width, uint32_t height,
|
||||
uint32_t flags, uint32_t *stride, void **map_data);
|
||||
|
||||
void
|
||||
gbm_bo_unmap(struct gbm_bo *bo, void *map_data);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_width(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_height(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_stride(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_stride_for_plane(struct gbm_bo *bo, int plane);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_format(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_bpp(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_offset(struct gbm_bo *bo, int plane);
|
||||
|
||||
struct gbm_device *
|
||||
gbm_bo_get_device(struct gbm_bo *bo);
|
||||
|
||||
union gbm_bo_handle
|
||||
gbm_bo_get_handle(struct gbm_bo *bo);
|
||||
|
||||
int
|
||||
gbm_bo_get_fd(struct gbm_bo *bo);
|
||||
|
||||
uint64_t
|
||||
gbm_bo_get_modifier(struct gbm_bo *bo);
|
||||
|
||||
int
|
||||
gbm_bo_get_plane_count(struct gbm_bo *bo);
|
||||
|
||||
union gbm_bo_handle
|
||||
gbm_bo_get_handle_for_plane(struct gbm_bo *bo, int plane);
|
||||
|
||||
int
|
||||
gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);
|
||||
|
||||
void
|
||||
gbm_bo_set_user_data(struct gbm_bo *bo, void *data,
|
||||
void (*destroy_user_data)(struct gbm_bo *, void *));
|
||||
|
||||
void *
|
||||
gbm_bo_get_user_data(struct gbm_bo *bo);
|
||||
|
||||
void
|
||||
gbm_bo_destroy(struct gbm_bo *bo);
|
||||
|
||||
struct gbm_surface *
|
||||
gbm_surface_create(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format, uint32_t flags);
|
||||
|
||||
struct gbm_surface *
|
||||
gbm_surface_create_with_modifiers(struct gbm_device *gbm,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t format,
|
||||
const uint64_t *modifiers,
|
||||
const unsigned int count);
|
||||
|
||||
struct gbm_bo *
|
||||
gbm_surface_lock_front_buffer(struct gbm_surface *surface);
|
||||
|
||||
void
|
||||
gbm_surface_release_buffer(struct gbm_surface *surface, struct gbm_bo *bo);
|
||||
|
||||
int
|
||||
gbm_surface_has_free_buffers(struct gbm_surface *surface);
|
||||
|
||||
void
|
||||
gbm_surface_destroy(struct gbm_surface *surface);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,46 @@
|
||||
# Copyright (C) 2021 HiHope Open Source Organization .
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
ISP_LIB_DIR = "//device/rockchip/hardware/isp/lib"
|
||||
ISP_ETC_DIR = "//device/rockchip/hardware/isp/etc"
|
||||
ISP_BIN_DIR = "//device/rockchip/hardware/isp/bin"
|
||||
|
||||
ohos_prebuilt_shared_library("librkaiq") {
|
||||
source = "$ISP_LIB_DIR/librkaiq.z.so"
|
||||
subsystem_name = "rockchip_products"
|
||||
install_enable = true
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("gc8034_RK-CMK-8M-2-v1_CK8401") {
|
||||
source = "$ISP_ETC_DIR/iqfiles/gc8034_RK-CMK-8M-2-v1_CK8401.json"
|
||||
install_images = [ "system" ]
|
||||
relative_install_dir = "iqfiles"
|
||||
part_name = "rockchip_products"
|
||||
install_enable = true
|
||||
}
|
||||
|
||||
ohos_prebuilt_executable("ispserver") {
|
||||
source = "$ISP_BIN_DIR/ispserver"
|
||||
part_name = "rockchip_products"
|
||||
install_enable = true
|
||||
}
|
||||
|
||||
group("isp") {
|
||||
deps = [
|
||||
":librkaiq",
|
||||
":gc8034_RK-CMK-8M-2-v1_CK8401",
|
||||
":ispserver",
|
||||
]
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Executable
+31
@@ -0,0 +1,31 @@
|
||||
# Copyright (C) 2021 HiHope Open Source Organization .
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/ndk/ndk.gni")
|
||||
|
||||
ohos_prebuilt_shared_library("libmpp") {
|
||||
if (target_cpu == "arm") {
|
||||
source = "lib/librockchip_mpp.so"
|
||||
} else {
|
||||
source = "lib64/librockchip_mpp.so"
|
||||
}
|
||||
part_name = "rockchip_products"
|
||||
install_enable = true
|
||||
}
|
||||
|
||||
group("mpp") {
|
||||
deps = [
|
||||
":libmpp",
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Executable
+24
@@ -0,0 +1,24 @@
|
||||
# Copyright (C) 2021 HiHope Open Source Organization .
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/ndk/ndk.gni")
|
||||
|
||||
ohos_prebuilt_shared_library("librga") {
|
||||
if (target_cpu == "arm") {
|
||||
source = "lib/librga.z.so"
|
||||
}
|
||||
subsystem_name = "hdf"
|
||||
part_name = "hdf"
|
||||
install_enable = true
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2021 HiHope Open Source Organization .
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
AP6XXX_ETC_DIR = "//device/rockchip/hardware/wifi/ap6xxx"
|
||||
|
||||
ohos_prebuilt_etc("clm_bcm43752a2_ag.blob") {
|
||||
source = "$AP6XXX_ETC_DIR/clm_bcm43752a2_ag.blob"
|
||||
install_images = [ "vendor" ]
|
||||
relative_install_dir = "firmware"
|
||||
part_name = "rockchip_products"
|
||||
install_enable = true
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("fw_bcm43752a2_ag_apsta.bin") {
|
||||
source = "$AP6XXX_ETC_DIR/fw_bcm43752a2_ag_apsta.bin"
|
||||
install_images = [ "vendor" ]
|
||||
relative_install_dir = "firmware"
|
||||
part_name = "rockchip_products"
|
||||
install_enable = true
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("fw_bcm43752a2_ag.bin") {
|
||||
source = "$AP6XXX_ETC_DIR/fw_bcm43752a2_ag.bin"
|
||||
install_images = [ "vendor" ]
|
||||
relative_install_dir = "firmware"
|
||||
part_name = "rockchip_products"
|
||||
install_enable = true
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("nvram_ap6275s.txt") {
|
||||
source = "$AP6XXX_ETC_DIR/nvram_ap6275s.txt"
|
||||
install_images = [ "vendor" ]
|
||||
relative_install_dir = "firmware"
|
||||
part_name = "rockchip_products"
|
||||
install_enable = true
|
||||
}
|
||||
|
||||
group("ap6xxx") {
|
||||
deps = [
|
||||
":clm_bcm43752a2_ag.blob",
|
||||
":fw_bcm43752a2_ag_apsta.bin",
|
||||
":fw_bcm43752a2_ag.bin",
|
||||
":nvram_ap6275s.txt",
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,356 @@
|
||||
# AP6275S_NVRAM_V1.4_20201116
|
||||
# AP6275S v00 WLBGA reference board, iPA version.
|
||||
|
||||
# SSID generated using Alberto's boardssid.py script:
|
||||
# ********************SUMMARY********************
|
||||
# Board Name: AP6275S_V00
|
||||
#SSID: 0x086d
|
||||
#macmid: 0x02df
|
||||
# Successfully made SSID entry in sromdefs.tcl.
|
||||
# Successfully made macmid entry in sromdefs.tcl.
|
||||
# Successfully made SSID entry in tblssid.py.
|
||||
# *************************************************
|
||||
# $ Copyright Broadcom $
|
||||
#
|
||||
#
|
||||
# <<Broadcom-WL-IPTag/Proprietary:>>
|
||||
NVRAMRev=$Rev: 844050 $
|
||||
sromrev=11
|
||||
boardrev=0x1213
|
||||
boardtype=0x08ed
|
||||
boardflags=0x00400201
|
||||
boardflags2=0xc0800000
|
||||
boardflags3=0x40002180
|
||||
#boardnum=57410
|
||||
macaddr=00:90:4c:12:d0:01
|
||||
jtag_irw=38
|
||||
|
||||
#Regulatory specific
|
||||
ccode=0
|
||||
regrev=0
|
||||
|
||||
# Board specific
|
||||
vendid=0x14e4
|
||||
devid=0x449d
|
||||
manfid=0x2d0
|
||||
antswitch=0
|
||||
pdgain5g=0
|
||||
pdgain2g=0
|
||||
aa2g=3
|
||||
aa5g=3
|
||||
agbg0=2
|
||||
agbg1=2
|
||||
aga0=2
|
||||
aga1=2
|
||||
extpagain2g=2
|
||||
extpagain5g=2
|
||||
rxgains2gelnagaina0=0
|
||||
rxgains2gtrisoa0=0
|
||||
rxgains2gtrelnabypa0=0
|
||||
rxgains5gelnagaina0=0
|
||||
rxgains5gtrisoa0=0
|
||||
rxgains5gtrelnabypa0=0
|
||||
rxgains5gmelnagaina0=0
|
||||
rxgains5gmtrisoa0=0
|
||||
rxgains5gmtrelnabypa0=0
|
||||
rxgains5ghelnagaina0=0
|
||||
rxgains5ghtrisoa0=0
|
||||
rxgains5ghtrelnabypa0=0
|
||||
rxgains2gelnagaina1=0
|
||||
rxgains2gtrisoa1=0
|
||||
rxgains2gtrelnabypa1=0
|
||||
rxgains5gelnagaina1=0
|
||||
rxgains5gtrisoa1=0
|
||||
rxgains5gtrelnabypa1=0
|
||||
rxgains5gmelnagaina1=0
|
||||
rxgains5gmtrisoa1=0
|
||||
rxgains5gmtrelnabypa1=0
|
||||
rxgains5ghelnagaina1=0
|
||||
rxgains5ghtrisoa1=0
|
||||
rxgains5ghtrelnabypa1=0
|
||||
|
||||
#RSSI related
|
||||
# 2G
|
||||
rssicorrnorm_c0=4,4
|
||||
rssicorrnorm_c1=4,4
|
||||
# 5G
|
||||
rssicorrnorm5g_c0=5,5,5,5,5,5,5,5,5,5,5,5
|
||||
rssicorrnorm5g_c1=4,4,4,4,4,4,4,4,4,4,4,4
|
||||
|
||||
|
||||
#Two range TSSI
|
||||
tworangetssi2g=0
|
||||
tworangetssi5g=0
|
||||
lowpowerrange2g=0
|
||||
lowpowerrange5g=0
|
||||
low_adc_rate_en=1
|
||||
# NOTE :================================================================================
|
||||
# To run TPC with Two Range TSSI ,set tworangetssi2g = 1 and lowpowerrange2g = 0
|
||||
# To run TPC with Single Range TSSI, set tworangetssi2g = 0
|
||||
# To run TPC please READ instructions near pa2ga0 and pa2ga1 as well
|
||||
# To generate PA params for Low Range set tworangetssi2g = 0 and lowpowerrange2g to 1
|
||||
# To generate PA params for High Range set tworangetssi2g = 1 and lowpowerrange2g to 1
|
||||
# ======================================================================================
|
||||
|
||||
#Related to FW Download. Host may use this
|
||||
nocrc=1
|
||||
|
||||
otpimagesize=502
|
||||
|
||||
xtalfreq=37400
|
||||
|
||||
txchain=3
|
||||
rxchain=3
|
||||
|
||||
cckdigfilttype=2
|
||||
|
||||
#bit mask for slice capability bit 0:2G bit 1:5G
|
||||
bandcap=3
|
||||
|
||||
#TXBF Related
|
||||
rpcal2g=0
|
||||
rpcal5gb0=0
|
||||
rpcal5gb1=0
|
||||
rpcal5gb2=0
|
||||
rpcal5gb3=0
|
||||
|
||||
|
||||
#FDSS Related
|
||||
fdss_level_2g=4,4
|
||||
fdss_interp_en=1
|
||||
fdss_level_5g=4,4
|
||||
fdss_level_11ax_2g=3,3
|
||||
fdss_level_11ax_2g_ch1=3,3
|
||||
fdss_level_11ax_2g_ch11=3,3
|
||||
fdss_level_11ax_5g=3,3
|
||||
|
||||
#Tempsense Related
|
||||
tempthresh=110
|
||||
tempoffset=40
|
||||
rawtempsense=0x1ff
|
||||
phycal_tempdelta=15
|
||||
temps_period=15
|
||||
temps_hysteresis=15
|
||||
|
||||
#------------- TSSI Related -------------
|
||||
|
||||
tssipos2g=1
|
||||
tssipos5g=1
|
||||
AvVmid_c0=2,127,4,92,4,91,4,91,4,94
|
||||
AvVmid_c1=2,127,4,93,4,93,4,95,3,110
|
||||
# CCK in case of multi mode 2
|
||||
pa2gccka0=-71,9683,-1064
|
||||
pa2gccka1=-59,9596,-1046
|
||||
# OFDM in case of multi_mode 2
|
||||
pa2ga0=-131,6980,-771
|
||||
pa2ga1=-119,7130,-776
|
||||
pa5ga0=-150,6098,-730,-141,6312,-729,-127,6151,-723,-136,5935,-702
|
||||
#pa5ga0=-150,6098,-730,-141,6312,-729,-136,6050,-713,-179,5504,-688
|
||||
#pa5ga1=-143,5954,-705,-136,6243,-722,-100,6496,-727,-89,7190,-798
|
||||
pa5ga1=-148,6016,-719,-136,6243,-722,-123,6019,-711,-89,7190,-798
|
||||
|
||||
# Max power and offsets
|
||||
maxp2ga0=86
|
||||
maxp2ga1=91
|
||||
maxp5ga0=75,76,68,68
|
||||
maxp5ga1=73,76,70,76
|
||||
subband5gver=0x4
|
||||
paparambwver=3
|
||||
cckpwroffset0=-5
|
||||
cckpwroffset1=-3
|
||||
pdoffset40ma0=0x4433
|
||||
pdoffset80ma0=0x3232
|
||||
pdoffset40ma1=0x2333
|
||||
pdoffset80ma1=0x1222
|
||||
cckbw202gpo=0x1111
|
||||
cckbw20ul2gpo=0x0000
|
||||
mcsbw202gpo=0x65544332
|
||||
mcsbw402gpo=0xEC444332
|
||||
dot11agofdmhrbw202gpo=0x4433
|
||||
ofdmlrbw202gpo=0x0022
|
||||
mcsbw205glpo=0x87544441
|
||||
mcsbw405glpo=0xB6443332
|
||||
mcsbw805glpo=0xCC553332
|
||||
mcsbw1605glpo=0
|
||||
mcsbw205gmpo=0x98544440
|
||||
mcsbw405gmpo=0xB6443332
|
||||
mcsbw805gmpo=0xBB553332
|
||||
mcsbw1605gmpo=0
|
||||
mcsbw205ghpo=0x98422230
|
||||
mcsbw405ghpo=0xB7554442
|
||||
mcsbw805ghpo=0xCC442221
|
||||
powoffs2gtna0=-3,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,0
|
||||
powoffs2gtna1=-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0
|
||||
mcs1024qam2gpo=0xCCAA
|
||||
mcs1024qam5glpo=0xFFFFCB
|
||||
mcs1024qam5gmpo=0xFFEECB
|
||||
mcs1024qam5ghpo=0xFFFFED
|
||||
mcs1024qam5gx1po=0xEECCCC
|
||||
mcs1024qam5gx2po=0xEECCCC
|
||||
mcs8poexp=0
|
||||
mcs9poexp=0
|
||||
mcs10poexp=0
|
||||
|
||||
# 5G power offset per channel for band edge channel
|
||||
powoffs5g20mtna0=0,0,0,0,0,0,0
|
||||
powoffs5g20mtna1=0,0,0,0,0,0,0
|
||||
powoffs5g40mtna0=0,0,0,0,0
|
||||
powoffs5g40mtna1=0,0,0,0,0
|
||||
powoffs5g80mtna0=0,0,0,0,0
|
||||
powoffs5g80mtna1=0,0,0,0,0
|
||||
mcs11poexp=0
|
||||
|
||||
#LTE Coex Related
|
||||
ltecxmux=0
|
||||
ltecxpadnum=0x0504
|
||||
ltecxfnsel=0x44
|
||||
ltecxgcigpio=0x04
|
||||
#OOB params
|
||||
#device_wake_opt=1
|
||||
host_wake_opt=0
|
||||
|
||||
# SWCTRL Related
|
||||
|
||||
swctrlmap_2g=0x10101010,0x06030401,0x04011010,0x000000,0x3FF
|
||||
swctrlmapext_2g=0x00000000,0x00000000,0x00000000,0x000000,0x000
|
||||
swctrlmap_5g=0x80408040,0x21240120,0x01208040,0x000000,0x3FF
|
||||
swctrlmapext_5g=0x00000000,0x00000000,0x00000000,0x000000,0x000
|
||||
clb2gslice0core0=0x01b
|
||||
clb2gslice1core0=0x000
|
||||
clb5gslice0core0=0x064
|
||||
clb5gslice1core0=0x000
|
||||
clb2gslice0core1=0x056
|
||||
clb2gslice1core1=0x000
|
||||
clb5gslice0core1=0x0a1
|
||||
clb5gslice1core1=0x000
|
||||
btc_prisel_ant_mask=0x2
|
||||
clb_swctrl_smask_ant0=0x27f
|
||||
clb_swctrl_smask_ant1=0x2f7
|
||||
|
||||
|
||||
#BT Coex 1:TDM
|
||||
btc_mode=1
|
||||
|
||||
# --- PAPD Cal related params ----
|
||||
txwbpapden=0 # 0:NBPAPD 1:WBPAPD
|
||||
# NB PAPD Cal params
|
||||
nb_eps_offset=470,470
|
||||
nb_bbmult=66,66
|
||||
nb_papdcalidx=6,6
|
||||
nb_txattn=2,2
|
||||
nb_rxattn=1,1
|
||||
nb_eps_stopidx=63
|
||||
epsilonoff_5g20_c0=0,1,1,-1
|
||||
epsilonoff_5g40_c0=0,1,1,1
|
||||
epsilonoff_5g80_c0=1,0,1,1
|
||||
epsilonoff_5g20_c1=1,0,0,-1
|
||||
epsilonoff_5g40_c1=0,0,0,0
|
||||
epsilonoff_5g80_c1=1,0,1,1
|
||||
epsilonoff_2g20_c0=0
|
||||
epsilonoff_2g20_c1=0
|
||||
|
||||
# energy detect threshold
|
||||
ed_thresh2g=-67
|
||||
ed_thresh5g=-67
|
||||
# energy detect threshold for EU
|
||||
eu_edthresh2g=-67
|
||||
eu_edthresh5g=-67
|
||||
|
||||
#rpcal coef for imptxbf
|
||||
rpcal5gb0=238
|
||||
rpcal5gb1=228
|
||||
rpcal5gb2=222
|
||||
rpcal5gb3=229
|
||||
rpcal2g=15
|
||||
ocl=0
|
||||
bt_coex_chdep_div=1
|
||||
|
||||
# OLPC Related
|
||||
disable_olpc=0
|
||||
olpc_thresh5g=32
|
||||
olpc_anchor5g=40
|
||||
olpc_thresh2g=32
|
||||
olpc_anchor2g=40
|
||||
|
||||
#PAPR related
|
||||
paprdis=0
|
||||
paprrmcsgamma2g=500,550,550,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
paprrmcsgain2g=128,128,128,0,0,0,0,0,0,0,0,0
|
||||
paprrmcsgamma2g_ch13=500,550,550,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
paprrmcsgain2g_ch13=128,128,128,0,0,0,0,0,0,0,0,0
|
||||
paprrmcsgamma2g_ch1=500,550,550,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
paprrmcsgain2g_ch1=128,128,128,0,0,0,0,0,0,0,0,0
|
||||
paprrmcsgamma5g20=500,500,500,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
paprrmcsgain5g20=128,128,128,0,0,0,0,0,0,0,0,0
|
||||
paprrmcsgamma5g40=600,600,600,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
paprrmcsgain5g40=128,128,128,0,0,0,0,0,0,0,0,0
|
||||
paprrmcsgamma5g80=-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
paprrmcsgain5g80=0,0,0,0,0,0,0,0,0,0,0,0
|
||||
|
||||
# Enable papd for cck when target pwr ge 16dBm
|
||||
cckpapd_pwrthresh=64
|
||||
|
||||
## ULOFDMA Board limit PPRs for 2G20 ##
|
||||
ruppr2g20bpska0=0x8421
|
||||
ruppr2g20bpska1=0x8421
|
||||
ruppr2g20qpska0=0x8421
|
||||
ruppr2g20qpska1=0x8421
|
||||
ruppr2g20qam16a0=0x10842
|
||||
ruppr2g20qam16a1=0x10842
|
||||
ruppr2g20qam64a0=0x18C63
|
||||
ruppr2g20qam64a1=0x18C63
|
||||
ruppr2g20qam256a0=0x318C6
|
||||
ruppr2g20qam256a1=0x318C6
|
||||
ruppr2g20qam1024a0=0x5AD6B
|
||||
ruppr2g20qam1024a1=0x5AD6B
|
||||
## ULOFDMA Board limit PPRs for 5G20 ##
|
||||
ruppr5g20bpska0=0x30421
|
||||
ruppr5g20bpska1=0x30421
|
||||
ruppr5g20qpska0=0x30421
|
||||
ruppr5g20qpska1=0x30421
|
||||
ruppr5g20qam16a0=0x30842
|
||||
ruppr5g20qam16a1=0x30842
|
||||
ruppr5g20qam64a0=0x314A5
|
||||
ruppr5g20qam64a1=0x314A5
|
||||
ruppr5g20qam256a0=0x4A529
|
||||
ruppr5g20qam256a1=0x4A529
|
||||
ruppr5g20qam1024a0=0x7294A
|
||||
ruppr5g20qam1024a1=0x7294A
|
||||
## ULOFDMA Board limit PPRs for 5G40 ##
|
||||
ruppr5g40bpska0=0x508421
|
||||
ruppr5g40bpska1=0x508421
|
||||
ruppr5g40qpska0=0x508421
|
||||
ruppr5g40qpska1=0x508421
|
||||
ruppr5g40qam16a0=0x508421
|
||||
ruppr5g40qam16a1=0x508421
|
||||
ruppr5g40qam64a0=0x518C63
|
||||
ruppr5g40qam64a1=0x518C63
|
||||
ruppr5g40qam256a0=0xA42108
|
||||
ruppr5g40qam256a1=0xA42108
|
||||
ruppr5g40qam1024a0=0xE68421
|
||||
ruppr5g40qam1024a1=0xE68421
|
||||
## ULOFDMA Board limit PPRs for 5G80 ##
|
||||
ruppr5g80bpska0=0xC108421
|
||||
ruppr5g80bpska1=0xC108421
|
||||
ruppr5g80qpska0=0xC108421
|
||||
ruppr5g80qpska1=0xC108421
|
||||
ruppr5g80qam16a0=0xC108421
|
||||
ruppr5g80qam16a1=0xC108421
|
||||
ruppr5g80qam64a0=0x14418C63
|
||||
ruppr5g80qam64a1=0x14418C63
|
||||
ruppr5g80qam256a0=0x2C94A529
|
||||
ruppr5g80qam256a1=0x2C94A529
|
||||
ruppr5g80qam1024a0=0x3CD60000
|
||||
ruppr5g80qam1024a1=0x3CD60000
|
||||
|
||||
muxenab=0x10
|
||||
|
||||
# ########### BTC Dynctl profile params ############
|
||||
# flags:bit0 - dynctl enabled, bit1 dynamic desense, bit2 dynamic mode, bit 3 TX power control
|
||||
#btcdyn_flags=1
|
||||
|
||||
#btcdyn_default_btc_mode=5
|
||||
#btcdyn_msw_rows=0
|
||||
#btcdyn_dsns_rows=0
|
||||
#btc_params1007=100
|
||||
#btc_params1017=4
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* netlink/addr.h Abstract Address
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_ADDR_H_
|
||||
#define NETLINK_ADDR_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nl_addr;
|
||||
|
||||
/* Creation */
|
||||
extern struct nl_addr * nl_addr_alloc(size_t);
|
||||
extern struct nl_addr * nl_addr_alloc_attr(struct nlattr *, int);
|
||||
extern struct nl_addr * nl_addr_build(int, void *, size_t);
|
||||
extern int nl_addr_parse(const char *, int, struct nl_addr **);
|
||||
extern struct nl_addr * nl_addr_clone(struct nl_addr *);
|
||||
|
||||
/* Usage Management */
|
||||
extern struct nl_addr * nl_addr_get(struct nl_addr *);
|
||||
extern void nl_addr_put(struct nl_addr *);
|
||||
extern int nl_addr_shared(struct nl_addr *);
|
||||
|
||||
extern int nl_addr_cmp(struct nl_addr *, struct nl_addr *);
|
||||
extern int nl_addr_cmp_prefix(struct nl_addr *, struct nl_addr *);
|
||||
extern int nl_addr_iszero(struct nl_addr *);
|
||||
extern int nl_addr_valid(char *, int);
|
||||
extern int nl_addr_guess_family(struct nl_addr *);
|
||||
extern int nl_addr_fill_sockaddr(struct nl_addr *,
|
||||
struct sockaddr *, socklen_t *);
|
||||
extern int nl_addr_info(struct nl_addr *, struct addrinfo **);
|
||||
extern int nl_addr_resolve(struct nl_addr *, char *, size_t);
|
||||
|
||||
/* Access Functions */
|
||||
extern void nl_addr_set_family(struct nl_addr *, int);
|
||||
extern int nl_addr_get_family(struct nl_addr *);
|
||||
extern int nl_addr_set_binary_addr(struct nl_addr *, void *,
|
||||
size_t);
|
||||
extern void * nl_addr_get_binary_addr(struct nl_addr *);
|
||||
extern unsigned int nl_addr_get_len(struct nl_addr *);
|
||||
extern void nl_addr_set_prefixlen(struct nl_addr *, int);
|
||||
extern unsigned int nl_addr_get_prefixlen(struct nl_addr *);
|
||||
|
||||
/* Address Family Translations */
|
||||
extern char * nl_af2str(int, char *, size_t);
|
||||
extern int nl_str2af(const char *);
|
||||
|
||||
/* Translations to Strings */
|
||||
extern char * nl_addr2str(struct nl_addr *, char *, size_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* netlink/attr.h Netlink Attributes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_ATTR_H_
|
||||
#define NETLINK_ATTR_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/object.h>
|
||||
#include <netlink/addr.h>
|
||||
#include <netlink/data.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nl_msg;
|
||||
|
||||
/**
|
||||
* @name Basic Attribute Data Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup attr
|
||||
* Basic attribute data types
|
||||
*
|
||||
* See section @core_doc{core_attr_parse,Attribute Parsing} for more details.
|
||||
*/
|
||||
enum {
|
||||
NLA_UNSPEC, /**< Unspecified type, binary data chunk */
|
||||
NLA_U8, /**< 8 bit integer */
|
||||
NLA_U16, /**< 16 bit integer */
|
||||
NLA_U32, /**< 32 bit integer */
|
||||
NLA_U64, /**< 64 bit integer */
|
||||
NLA_STRING, /**< NUL terminated character string */
|
||||
NLA_FLAG, /**< Flag */
|
||||
NLA_MSECS, /**< Micro seconds (64bit) */
|
||||
NLA_NESTED, /**< Nested attributes */
|
||||
__NLA_TYPE_MAX,
|
||||
};
|
||||
|
||||
#define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @ingroup attr
|
||||
* Attribute validation policy.
|
||||
*
|
||||
* See section @core_doc{core_attr_parse,Attribute Parsing} for more details.
|
||||
*/
|
||||
struct nla_policy {
|
||||
/** Type of attribute or NLA_UNSPEC */
|
||||
uint16_t type;
|
||||
|
||||
/** Minimal length of payload required */
|
||||
uint16_t minlen;
|
||||
|
||||
/** Maximal length of payload allowed */
|
||||
uint16_t maxlen;
|
||||
};
|
||||
|
||||
/* Size calculations */
|
||||
extern int nla_attr_size(int payload);
|
||||
extern int nla_total_size(int payload);
|
||||
extern int nla_padlen(int payload);
|
||||
|
||||
/* Attribute parsing */
|
||||
extern int nla_type(const struct nlattr *);
|
||||
extern void * nla_data(const struct nlattr *);
|
||||
extern int nla_len(const struct nlattr *);
|
||||
extern int nla_ok(const struct nlattr *, int);
|
||||
extern struct nlattr * nla_next(const struct nlattr *, int *);
|
||||
extern int nla_parse(struct nlattr **, int, struct nlattr *,
|
||||
int, struct nla_policy *);
|
||||
extern int nla_validate(struct nlattr *, int, int,
|
||||
struct nla_policy *);
|
||||
extern struct nlattr * nla_find(struct nlattr *, int, int);
|
||||
|
||||
/* Helper Functions */
|
||||
extern int nla_memcpy(void *, struct nlattr *, int);
|
||||
extern size_t nla_strlcpy(char *, const struct nlattr *, size_t);
|
||||
extern int nla_memcmp(const struct nlattr *, const void *, size_t);
|
||||
extern int nla_strcmp(const struct nlattr *, const char *);
|
||||
|
||||
/* Unspecific attribute */
|
||||
extern struct nlattr * nla_reserve(struct nl_msg *, int, int);
|
||||
extern int nla_put(struct nl_msg *, int, int, const void *);
|
||||
extern int nla_put_data(struct nl_msg *, int, struct nl_data *);
|
||||
extern int nla_put_addr(struct nl_msg *, int, struct nl_addr *);
|
||||
|
||||
/* Integer attribute */
|
||||
extern uint8_t nla_get_u8(struct nlattr *);
|
||||
extern int nla_put_u8(struct nl_msg *, int, uint8_t);
|
||||
extern uint16_t nla_get_u16(struct nlattr *);
|
||||
extern int nla_put_u16(struct nl_msg *, int, uint16_t);
|
||||
extern uint32_t nla_get_u32(struct nlattr *);
|
||||
extern int nla_put_u32(struct nl_msg *, int, uint32_t);
|
||||
extern uint64_t nla_get_u64(struct nlattr *);
|
||||
extern int nla_put_u64(struct nl_msg *, int, uint64_t);
|
||||
|
||||
/* String attribute */
|
||||
extern char * nla_get_string(struct nlattr *);
|
||||
extern char * nla_strdup(struct nlattr *);
|
||||
extern int nla_put_string(struct nl_msg *, int, const char *);
|
||||
|
||||
/* Flag attribute */
|
||||
extern int nla_get_flag(struct nlattr *);
|
||||
extern int nla_put_flag(struct nl_msg *, int);
|
||||
|
||||
/* Msec attribute */
|
||||
extern unsigned long nla_get_msecs(struct nlattr *);
|
||||
extern int nla_put_msecs(struct nl_msg *, int, unsigned long);
|
||||
|
||||
/* Attribute nesting */
|
||||
extern int nla_put_nested(struct nl_msg *, int, struct nl_msg *);
|
||||
extern struct nlattr * nla_nest_start(struct nl_msg *, int);
|
||||
extern int nla_nest_end(struct nl_msg *, struct nlattr *);
|
||||
extern void nla_nest_cancel(struct nl_msg *, struct nlattr *);
|
||||
extern int nla_parse_nested(struct nlattr **, int, struct nlattr *,
|
||||
struct nla_policy *);
|
||||
extern int nla_is_nested(struct nlattr *);
|
||||
|
||||
/**
|
||||
* @name Attribute Construction (Exception Based)
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup attr
|
||||
* Add unspecific attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg attrtype Attribute type.
|
||||
* @arg attrlen Length of attribute payload.
|
||||
* @arg data Head of attribute payload.
|
||||
*/
|
||||
#define NLA_PUT(msg, attrtype, attrlen, data) \
|
||||
do { \
|
||||
if (nla_put(msg, attrtype, attrlen, data) < 0) \
|
||||
goto nla_put_failure; \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @ingroup attr
|
||||
* Add atomic type attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg type Atomic type.
|
||||
* @arg attrtype Attribute type.
|
||||
* @arg value Head of attribute payload.
|
||||
*/
|
||||
#define NLA_PUT_TYPE(msg, type, attrtype, value) \
|
||||
do { \
|
||||
type __tmp = value; \
|
||||
NLA_PUT(msg, attrtype, sizeof(type), &__tmp); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Add 8 bit integer attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg attrtype Attribute type.
|
||||
* @arg value Numeric value.
|
||||
*/
|
||||
#define NLA_PUT_U8(msg, attrtype, value) \
|
||||
NLA_PUT_TYPE(msg, uint8_t, attrtype, value)
|
||||
|
||||
/**
|
||||
* Add 16 bit integer attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg attrtype Attribute type.
|
||||
* @arg value Numeric value.
|
||||
*/
|
||||
#define NLA_PUT_U16(msg, attrtype, value) \
|
||||
NLA_PUT_TYPE(msg, uint16_t, attrtype, value)
|
||||
|
||||
/**
|
||||
* Add 32 bit integer attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg attrtype Attribute type.
|
||||
* @arg value Numeric value.
|
||||
*/
|
||||
#define NLA_PUT_U32(msg, attrtype, value) \
|
||||
NLA_PUT_TYPE(msg, uint32_t, attrtype, value)
|
||||
|
||||
/**
|
||||
* Add 64 bit integer attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg attrtype Attribute type.
|
||||
* @arg value Numeric value.
|
||||
*/
|
||||
#define NLA_PUT_U64(msg, attrtype, value) \
|
||||
NLA_PUT_TYPE(msg, uint64_t, attrtype, value)
|
||||
|
||||
/**
|
||||
* Add string attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg attrtype Attribute type.
|
||||
* @arg value NUL terminated character string.
|
||||
*/
|
||||
#define NLA_PUT_STRING(msg, attrtype, value) \
|
||||
NLA_PUT(msg, attrtype, (int) strlen(value) + 1, value)
|
||||
|
||||
/**
|
||||
* Add flag attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg attrtype Attribute type.
|
||||
*/
|
||||
#define NLA_PUT_FLAG(msg, attrtype) \
|
||||
NLA_PUT(msg, attrtype, 0, NULL)
|
||||
|
||||
/**
|
||||
* Add msecs attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg attrtype Attribute type.
|
||||
* @arg msecs Numeric value in micro seconds.
|
||||
*/
|
||||
#define NLA_PUT_MSECS(msg, attrtype, msecs) \
|
||||
NLA_PUT_U64(msg, attrtype, msecs)
|
||||
|
||||
/**
|
||||
* Add address attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg attrtype Attribute type.
|
||||
* @arg addr Abstract address object.
|
||||
*/
|
||||
#define NLA_PUT_ADDR(msg, attrtype, addr) \
|
||||
NLA_PUT(msg, attrtype, nl_addr_get_len(addr), \
|
||||
nl_addr_get_binary_addr(addr))
|
||||
|
||||
/**
|
||||
* Add abstract data attribute to netlink message.
|
||||
* @arg msg Netlink message.
|
||||
* @arg attrtype Attribute type.
|
||||
* @arg data Abstract data object.
|
||||
*/
|
||||
#define NLA_PUT_DATA(msg, attrtype, data) \
|
||||
NLA_PUT(msg, attrtype, nl_data_get_size(data), \
|
||||
nl_data_get(data))
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Iterators
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup attr
|
||||
* Iterate over a stream of attributes
|
||||
* @arg pos loop counter, set to current attribute
|
||||
* @arg head head of attribute stream
|
||||
* @arg len length of attribute stream
|
||||
* @arg rem initialized to len, holds bytes currently remaining in stream
|
||||
*/
|
||||
#define nla_for_each_attr(pos, head, len, rem) \
|
||||
for (pos = head, rem = len; \
|
||||
nla_ok(pos, rem); \
|
||||
pos = nla_next(pos, &(rem)))
|
||||
|
||||
/**
|
||||
* @ingroup attr
|
||||
* Iterate over a stream of nested attributes
|
||||
* @arg pos loop counter, set to current attribute
|
||||
* @arg nla attribute containing the nested attributes
|
||||
* @arg rem initialized to len, holds bytes currently remaining in stream
|
||||
*/
|
||||
#define nla_for_each_nested(pos, nla, rem) \
|
||||
for (pos = nla_data(nla), rem = nla_len(nla); \
|
||||
nla_ok(pos, rem); \
|
||||
pos = nla_next(pos, &(rem)))
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* netlink/cache-api.h Caching API
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_DUMMY_CACHE_API_H_
|
||||
#define NETLINK_DUMMY_CACHE_API_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
|
||||
#warning "You are including a deprecated header file, include <netlink/cache.h>."
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* netlink/cache.h Caching Module
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CACHE_H_
|
||||
#define NETLINK_CACHE_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/msg.h>
|
||||
#include <netlink/utils.h>
|
||||
#include <netlink/object.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
NL_ACT_UNSPEC,
|
||||
NL_ACT_NEW,
|
||||
NL_ACT_DEL,
|
||||
NL_ACT_GET,
|
||||
NL_ACT_SET,
|
||||
NL_ACT_CHANGE,
|
||||
__NL_ACT_MAX,
|
||||
};
|
||||
|
||||
#define NL_ACT_MAX (__NL_ACT_MAX - 1)
|
||||
|
||||
struct nl_cache;
|
||||
typedef void (*change_func_t)(struct nl_cache *, struct nl_object *, int, void *);
|
||||
|
||||
/**
|
||||
* @ingroup cache
|
||||
* Explicitely iterate over all address families when updating the cache
|
||||
*/
|
||||
#define NL_CACHE_AF_ITER 0x0001
|
||||
|
||||
/* Access Functions */
|
||||
extern int nl_cache_nitems(struct nl_cache *);
|
||||
extern int nl_cache_nitems_filter(struct nl_cache *,
|
||||
struct nl_object *);
|
||||
extern struct nl_cache_ops * nl_cache_get_ops(struct nl_cache *);
|
||||
extern struct nl_object * nl_cache_get_first(struct nl_cache *);
|
||||
extern struct nl_object * nl_cache_get_last(struct nl_cache *);
|
||||
extern struct nl_object * nl_cache_get_next(struct nl_object *);
|
||||
extern struct nl_object * nl_cache_get_prev(struct nl_object *);
|
||||
|
||||
extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *);
|
||||
extern int nl_cache_alloc_and_fill(struct nl_cache_ops *,
|
||||
struct nl_sock *,
|
||||
struct nl_cache **);
|
||||
extern int nl_cache_alloc_name(const char *,
|
||||
struct nl_cache **);
|
||||
extern struct nl_cache * nl_cache_subset(struct nl_cache *,
|
||||
struct nl_object *);
|
||||
extern struct nl_cache * nl_cache_clone(struct nl_cache *);
|
||||
extern void nl_cache_clear(struct nl_cache *);
|
||||
extern void nl_cache_get(struct nl_cache *);
|
||||
extern void nl_cache_free(struct nl_cache *);
|
||||
extern void nl_cache_put(struct nl_cache *cache);
|
||||
|
||||
/* Cache modification */
|
||||
extern int nl_cache_add(struct nl_cache *,
|
||||
struct nl_object *);
|
||||
extern int nl_cache_parse_and_add(struct nl_cache *,
|
||||
struct nl_msg *);
|
||||
extern int nl_cache_move(struct nl_cache *,
|
||||
struct nl_object *);
|
||||
extern void nl_cache_remove(struct nl_object *);
|
||||
extern int nl_cache_refill(struct nl_sock *,
|
||||
struct nl_cache *);
|
||||
extern int nl_cache_pickup(struct nl_sock *,
|
||||
struct nl_cache *);
|
||||
extern int nl_cache_resync(struct nl_sock *,
|
||||
struct nl_cache *,
|
||||
change_func_t,
|
||||
void *);
|
||||
extern int nl_cache_include(struct nl_cache *,
|
||||
struct nl_object *,
|
||||
change_func_t,
|
||||
void *);
|
||||
extern void nl_cache_set_arg1(struct nl_cache *, int);
|
||||
extern void nl_cache_set_arg2(struct nl_cache *, int);
|
||||
extern void nl_cache_set_flags(struct nl_cache *, unsigned int);
|
||||
|
||||
/* General */
|
||||
extern int nl_cache_is_empty(struct nl_cache *);
|
||||
extern struct nl_object * nl_cache_search(struct nl_cache *,
|
||||
struct nl_object *);
|
||||
extern struct nl_object *nl_cache_find(struct nl_cache *,
|
||||
struct nl_object *);
|
||||
extern void nl_cache_mark_all(struct nl_cache *);
|
||||
|
||||
/* Dumping */
|
||||
extern void nl_cache_dump(struct nl_cache *,
|
||||
struct nl_dump_params *);
|
||||
extern void nl_cache_dump_filter(struct nl_cache *,
|
||||
struct nl_dump_params *,
|
||||
struct nl_object *);
|
||||
|
||||
/* Iterators */
|
||||
extern void nl_cache_foreach(struct nl_cache *,
|
||||
void (*cb)(struct nl_object *,
|
||||
void *),
|
||||
void *arg);
|
||||
extern void nl_cache_foreach_filter(struct nl_cache *,
|
||||
struct nl_object *,
|
||||
void (*cb)(struct
|
||||
nl_object *,
|
||||
void *),
|
||||
void *arg);
|
||||
|
||||
/* --- cache management --- */
|
||||
|
||||
/* Cache type management */
|
||||
extern struct nl_cache_ops * nl_cache_ops_lookup(const char *);
|
||||
extern struct nl_cache_ops * nl_cache_ops_lookup_safe(const char *);
|
||||
extern struct nl_cache_ops * nl_cache_ops_associate(int, int);
|
||||
extern struct nl_cache_ops * nl_cache_ops_associate_safe(int, int);
|
||||
extern struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int);
|
||||
extern void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *);
|
||||
extern int nl_cache_mngt_register(struct nl_cache_ops *);
|
||||
extern int nl_cache_mngt_unregister(struct nl_cache_ops *);
|
||||
|
||||
/* Global cache provisioning/requiring */
|
||||
extern void nl_cache_mngt_provide(struct nl_cache *);
|
||||
extern void nl_cache_mngt_unprovide(struct nl_cache *);
|
||||
extern struct nl_cache * nl_cache_mngt_require(const char *);
|
||||
extern struct nl_cache * nl_cache_mngt_require_safe(const char *);
|
||||
extern struct nl_cache * __nl_cache_mngt_require(const char *);
|
||||
|
||||
struct nl_cache_mngr;
|
||||
|
||||
#define NL_AUTO_PROVIDE 1
|
||||
#define NL_ALLOCATED_SOCK 2 /* For internal use only, do not use */
|
||||
|
||||
extern int nl_cache_mngr_alloc(struct nl_sock *,
|
||||
int, int,
|
||||
struct nl_cache_mngr **);
|
||||
extern int nl_cache_mngr_add(struct nl_cache_mngr *,
|
||||
const char *,
|
||||
change_func_t,
|
||||
void *,
|
||||
struct nl_cache **);
|
||||
extern int nl_cache_mngr_add_cache(struct nl_cache_mngr *mngr,
|
||||
struct nl_cache *cache,
|
||||
change_func_t cb, void *data);
|
||||
extern int nl_cache_mngr_get_fd(struct nl_cache_mngr *);
|
||||
extern int nl_cache_mngr_poll(struct nl_cache_mngr *,
|
||||
int);
|
||||
extern int nl_cache_mngr_data_ready(struct nl_cache_mngr *);
|
||||
extern void nl_cache_mngr_info(struct nl_cache_mngr *,
|
||||
struct nl_dump_params *);
|
||||
extern void nl_cache_mngr_free(struct nl_cache_mngr *);
|
||||
|
||||
extern void nl_cache_ops_get(struct nl_cache_ops *);
|
||||
extern void nl_cache_ops_put(struct nl_cache_ops *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* netlink/cli/addr.h CLI Address Helpers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_ADDR_H_
|
||||
#define __NETLINK_CLI_ADDR_H_
|
||||
|
||||
#include <netlink/route/addr.h>
|
||||
|
||||
#define nl_cli_addr_alloc_cache(sk) \
|
||||
nl_cli_alloc_cache((sk), "address", rtnl_addr_alloc_cache)
|
||||
|
||||
extern struct rtnl_addr *nl_cli_addr_alloc(void);
|
||||
|
||||
extern void nl_cli_addr_parse_family(struct rtnl_addr *, char *);
|
||||
extern void nl_cli_addr_parse_local(struct rtnl_addr *, char *);
|
||||
extern void nl_cli_addr_parse_dev(struct rtnl_addr *, struct nl_cache *,char *);
|
||||
extern void nl_cli_addr_parse_label(struct rtnl_addr *, char *);
|
||||
extern void nl_cli_addr_parse_peer(struct rtnl_addr *, char *);
|
||||
extern void nl_cli_addr_parse_scope(struct rtnl_addr *, char *);
|
||||
extern void nl_cli_addr_parse_broadcast(struct rtnl_addr *, char *);
|
||||
extern void nl_cli_addr_parse_preferred(struct rtnl_addr *, char *);
|
||||
extern void nl_cli_addr_parse_valid(struct rtnl_addr *, char *);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* netlink/cli/class.h CLI Class Helpers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_CLASS_H_
|
||||
#define __NETLINK_CLI_CLASS_H_
|
||||
|
||||
#include <netlink/route/class.h>
|
||||
#include <netlink/cli/tc.h>
|
||||
|
||||
extern struct rtnl_class *nl_cli_class_alloc(void);
|
||||
extern struct nl_cache *nl_cli_class_alloc_cache(struct nl_sock *, int);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* netlink/cli/cls.h CLI Classifier Helpers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_CLS_H_
|
||||
#define __NETLINK_CLI_CLS_H_
|
||||
|
||||
#include <netlink/route/classifier.h>
|
||||
#include <netlink/cli/tc.h>
|
||||
|
||||
extern struct rtnl_cls * nl_cli_cls_alloc(void);
|
||||
extern struct nl_cache * nl_cli_cls_alloc_cache(struct nl_sock *,
|
||||
int, uint32_t);
|
||||
extern void nl_cli_cls_parse_proto(struct rtnl_cls *, char *);
|
||||
extern struct rtnl_ematch_tree *nl_cli_cls_parse_ematch(struct rtnl_cls *, char *);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* netlink/cli/ct.h CLI Conntrack Helper
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_CT_H_
|
||||
#define __NETLINK_CLI_CT_H_
|
||||
|
||||
#include <netlink/netfilter/ct.h>
|
||||
#include <linux/netfilter/nf_conntrack_common.h>
|
||||
|
||||
extern struct nfnl_ct *nl_cli_ct_alloc(void);
|
||||
extern struct nl_cache *nl_cli_ct_alloc_cache(struct nl_sock *);
|
||||
|
||||
extern void nl_cli_ct_parse_family(struct nfnl_ct *, char *);
|
||||
extern void nl_cli_ct_parse_protocol(struct nfnl_ct *, char *);
|
||||
extern void nl_cli_ct_parse_mark(struct nfnl_ct *, char *);
|
||||
extern void nl_cli_ct_parse_timeout(struct nfnl_ct *, char *);
|
||||
extern void nl_cli_ct_parse_id(struct nfnl_ct *, char *);
|
||||
extern void nl_cli_ct_parse_use(struct nfnl_ct *, char *);
|
||||
extern void nl_cli_ct_parse_src(struct nfnl_ct *, int, char *);
|
||||
extern void nl_cli_ct_parse_dst(struct nfnl_ct *, int, char *);
|
||||
extern void nl_cli_ct_parse_src_port(struct nfnl_ct *, int, char *);
|
||||
extern void nl_cli_ct_parse_dst_port(struct nfnl_ct *, int, char *);
|
||||
extern void nl_cli_ct_parse_tcp_state(struct nfnl_ct *, char *);
|
||||
extern void nl_cli_ct_parse_status(struct nfnl_ct *, char *);
|
||||
extern void nl_cli_ct_parse_zone(struct nfnl_ct *, char *);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* netlink/cli/exp.h CLI Expectation Helper
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2012 Rich Fought <Rich.Fought@watchguard.com>
|
||||
* Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_EXP_H_
|
||||
#define __NETLINK_CLI_EXP_H_
|
||||
|
||||
#include <netlink/netfilter/exp.h>
|
||||
#include <linux/netfilter/nf_conntrack_common.h>
|
||||
|
||||
extern struct nfnl_exp *nl_cli_exp_alloc(void);
|
||||
extern struct nl_cache *nl_cli_exp_alloc_cache(struct nl_sock *);
|
||||
|
||||
extern void nl_cli_exp_parse_family(struct nfnl_exp *, char *);
|
||||
extern void nl_cli_exp_parse_timeout(struct nfnl_exp *, char *);
|
||||
extern void nl_cli_exp_parse_id(struct nfnl_exp *, char *);
|
||||
extern void nl_cli_exp_parse_helper_name(struct nfnl_exp *, char *);
|
||||
extern void nl_cli_exp_parse_zone(struct nfnl_exp *, char *);
|
||||
extern void nl_cli_exp_parse_flags(struct nfnl_exp *, char *);
|
||||
extern void nl_cli_exp_parse_class(struct nfnl_exp *, char *);
|
||||
extern void nl_cli_exp_parse_nat_dir(struct nfnl_exp *, char *);
|
||||
extern void nl_cli_exp_parse_fn(struct nfnl_exp *, char *);
|
||||
|
||||
extern void nl_cli_exp_parse_src(struct nfnl_exp *, int, char *);
|
||||
extern void nl_cli_exp_parse_dst(struct nfnl_exp *, int, char *);
|
||||
extern void nl_cli_exp_parse_l4protonum(struct nfnl_exp *, int, char *);
|
||||
extern void nl_cli_exp_parse_src_port(struct nfnl_exp *, int, char *);
|
||||
extern void nl_cli_exp_parse_dst_port(struct nfnl_exp *, int, char *);
|
||||
extern void nl_cli_exp_parse_icmp_id(struct nfnl_exp *, int, char *);
|
||||
extern void nl_cli_exp_parse_icmp_type(struct nfnl_exp *, int, char *);
|
||||
extern void nl_cli_exp_parse_icmp_code(struct nfnl_exp *, int, char *);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* netlink/cli/link.h CLI Link Helpers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008-2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_LINK_H_
|
||||
#define __NETLINK_CLI_LINK_H_
|
||||
|
||||
#include <netlink/route/link.h>
|
||||
#include <netlink/cli/utils.h>
|
||||
|
||||
extern struct rtnl_link *nl_cli_link_alloc(void);
|
||||
extern struct nl_cache *nl_cli_link_alloc_cache_family(struct nl_sock *, int);
|
||||
extern struct nl_cache *nl_cli_link_alloc_cache(struct nl_sock *);
|
||||
|
||||
extern void nl_cli_link_parse_family(struct rtnl_link *, char *);
|
||||
extern void nl_cli_link_parse_name(struct rtnl_link *, char *);
|
||||
extern void nl_cli_link_parse_mtu(struct rtnl_link *, char *);
|
||||
extern void nl_cli_link_parse_ifindex(struct rtnl_link *, char *);
|
||||
extern void nl_cli_link_parse_txqlen(struct rtnl_link *, char *);
|
||||
extern void nl_cli_link_parse_weight(struct rtnl_link *, char *);
|
||||
extern void nl_cli_link_parse_ifalias(struct rtnl_link *, char *);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* netlink/cli/neighbour.h CLI Neighbour Helpers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_NEIGH_H_
|
||||
#define __NETLINK_CLI_NEIGH_H_
|
||||
|
||||
#include <netlink/route/neighbour.h>
|
||||
|
||||
#define nl_cli_neigh_alloc_cache(sk) \
|
||||
nl_cli_alloc_cache((sk), "neighbour", rtnl_neigh_alloc_cache)
|
||||
|
||||
extern struct rtnl_neigh *nl_cli_neigh_alloc(void);
|
||||
extern void nl_cli_neigh_parse_dst(struct rtnl_neigh *, char *);
|
||||
extern void nl_cli_neigh_parse_lladdr(struct rtnl_neigh *, char *);
|
||||
extern void nl_cli_neigh_parse_dev(struct rtnl_neigh *, struct nl_cache *, char *);
|
||||
extern void nl_cli_neigh_parse_family(struct rtnl_neigh *, char *);
|
||||
extern void nl_cli_neigh_parse_state(struct rtnl_neigh *, char *);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* netlink/cli/qdisc.h CLI QDisc Helpers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008-2011 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_QDISC_H_
|
||||
#define __NETLINK_CLI_QDISC_H_
|
||||
|
||||
#include <netlink/route/qdisc.h>
|
||||
|
||||
#define nl_cli_qdisc_alloc_cache(sk) \
|
||||
nl_cli_alloc_cache((sk), "queueing disciplines", \
|
||||
rtnl_qdisc_alloc_cache)
|
||||
|
||||
extern struct rtnl_qdisc *nl_cli_qdisc_alloc(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* netlink/cli//route.h CLI Route Helpers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_ROUTE_H_
|
||||
#define __NETLINK_CLI_ROUTE_H_
|
||||
|
||||
#include <netlink/route/route.h>
|
||||
|
||||
extern struct rtnl_route *nl_cli_route_alloc(void);
|
||||
|
||||
extern struct nl_cache *nl_cli_route_alloc_cache(struct nl_sock *, int);
|
||||
|
||||
extern void nl_cli_route_parse_family(struct rtnl_route *, char *);
|
||||
extern void nl_cli_route_parse_dst(struct rtnl_route *, char *);
|
||||
extern void nl_cli_route_parse_src(struct rtnl_route *, char *);
|
||||
extern void nl_cli_route_parse_pref_src(struct rtnl_route *, char *);
|
||||
extern void nl_cli_route_parse_metric(struct rtnl_route *, char *);
|
||||
extern void nl_cli_route_parse_nexthop(struct rtnl_route *, char *, struct nl_cache *);
|
||||
extern void nl_cli_route_parse_table(struct rtnl_route *, char *);
|
||||
extern void nl_cli_route_parse_prio(struct rtnl_route *, char *);
|
||||
extern void nl_cli_route_parse_scope(struct rtnl_route *, char *);
|
||||
extern void nl_cli_route_parse_protocol(struct rtnl_route *, char *);
|
||||
extern void nl_cli_route_parse_type(struct rtnl_route *, char *);
|
||||
extern void nl_cli_route_parse_iif(struct rtnl_route *, char *, struct nl_cache *);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* netlink/cli/rule.h CLI Routing Rule Helpers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_RULE_H_
|
||||
#define __NETLINK_CLI_RULE_H_
|
||||
|
||||
#include <netlink/route/rule.h>
|
||||
|
||||
extern struct rtnl_rule *nl_cli_rule_alloc(void);
|
||||
extern struct nl_cache *nl_cli_rule_alloc_cache(struct nl_sock *);
|
||||
extern void nl_cli_rule_parse_family(struct rtnl_rule *, char *);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* netlink/cli/tc.h CLI Traffic Control Helpers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_TC_H_
|
||||
#define __NETLINK_CLI_TC_H_
|
||||
|
||||
#include <netlink/route/tc.h>
|
||||
|
||||
struct rtnl_tc_ops;
|
||||
|
||||
extern void nl_cli_tc_parse_dev(struct rtnl_tc *, struct nl_cache *, char *);
|
||||
extern void nl_cli_tc_parse_parent(struct rtnl_tc *, char *);
|
||||
extern void nl_cli_tc_parse_handle(struct rtnl_tc *, char *, int);
|
||||
extern void nl_cli_tc_parse_mtu(struct rtnl_tc *, char *);
|
||||
extern void nl_cli_tc_parse_mpu(struct rtnl_tc *, char *);
|
||||
extern void nl_cli_tc_parse_overhead(struct rtnl_tc *, char *);
|
||||
extern void nl_cli_tc_parse_linktype(struct rtnl_tc *, char *);
|
||||
extern void nl_cli_tc_parse_kind(struct rtnl_tc *, char *);
|
||||
|
||||
struct nl_cli_tc_module
|
||||
{
|
||||
const char * tm_name;
|
||||
enum rtnl_tc_type tm_type;
|
||||
struct rtnl_tc_ops * tm_ops;
|
||||
void (*tm_parse_argv)(struct rtnl_tc *, int, char **);
|
||||
struct nl_list_head tm_list;
|
||||
};
|
||||
|
||||
extern struct nl_cli_tc_module *nl_cli_tc_lookup(struct rtnl_tc_ops *);
|
||||
extern void nl_cli_tc_register(struct nl_cli_tc_module *);
|
||||
extern void nl_cli_tc_unregister(struct nl_cli_tc_module *);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* src/utils.h Utilities
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef __NETLINK_CLI_UTILS_H_
|
||||
#define __NETLINK_CLI_UTILS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <inttypes.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <ctype.h>
|
||||
#include <getopt.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/utils.h>
|
||||
#include <netlink/addr.h>
|
||||
#include <netlink/list.h>
|
||||
#include <netlink/route/rtnl.h>
|
||||
#include <netlink/route/link.h>
|
||||
#include <netlink/route/addr.h>
|
||||
#include <netlink/route/neighbour.h>
|
||||
#include <netlink/route/neightbl.h>
|
||||
#include <netlink/route/route.h>
|
||||
#include <netlink/route/rule.h>
|
||||
#include <netlink/route/qdisc.h>
|
||||
#include <netlink/route/class.h>
|
||||
#include <netlink/route/classifier.h>
|
||||
#include <netlink/route/cls/ematch.h>
|
||||
#include <netlink/fib_lookup/lookup.h>
|
||||
#include <netlink/fib_lookup/request.h>
|
||||
#include <netlink/genl/genl.h>
|
||||
#include <netlink/genl/ctrl.h>
|
||||
#include <netlink/genl/mngt.h>
|
||||
#include <netlink/netfilter/ct.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __init
|
||||
#define __init __attribute__((constructor))
|
||||
#endif
|
||||
|
||||
#ifndef __exit
|
||||
#define __exit __attribute__((destructor))
|
||||
#endif
|
||||
|
||||
extern uint32_t nl_cli_parse_u32(const char *);
|
||||
extern void nl_cli_print_version(void);
|
||||
extern void nl_cli_fatal(int, const char *, ...);
|
||||
extern struct nl_addr * nl_cli_addr_parse(const char *, int);
|
||||
extern int nl_cli_connect(struct nl_sock *, int);
|
||||
extern struct nl_sock * nl_cli_alloc_socket(void);
|
||||
extern int nl_cli_parse_dumptype(const char *);
|
||||
extern int nl_cli_confirm(struct nl_object *,
|
||||
struct nl_dump_params *, int);
|
||||
|
||||
extern struct nl_cache *nl_cli_alloc_cache(struct nl_sock *, const char *,
|
||||
int (*ac)(struct nl_sock *, struct nl_cache **));
|
||||
|
||||
extern void nl_cli_load_module(const char *, const char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* netlink/data.h Abstract Data
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_DATA_H_
|
||||
#define NETLINK_DATA_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nl_data;
|
||||
|
||||
/* General */
|
||||
extern struct nl_data * nl_data_alloc(void *, size_t);
|
||||
extern struct nl_data * nl_data_alloc_attr(struct nlattr *);
|
||||
extern struct nl_data * nl_data_clone(struct nl_data *);
|
||||
extern int nl_data_append(struct nl_data *, void *, size_t);
|
||||
extern void nl_data_free(struct nl_data *);
|
||||
|
||||
/* Access Functions */
|
||||
extern void * nl_data_get(struct nl_data *);
|
||||
extern size_t nl_data_get_size(struct nl_data *);
|
||||
|
||||
/* Misc */
|
||||
extern int nl_data_cmp(struct nl_data *, struct nl_data *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* netlink/errno.h Error Numbers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_ERRNO_H_
|
||||
#define NETLINK_ERRNO_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NLE_SUCCESS 0
|
||||
#define NLE_FAILURE 1
|
||||
#define NLE_INTR 2
|
||||
#define NLE_BAD_SOCK 3
|
||||
#define NLE_AGAIN 4
|
||||
#define NLE_NOMEM 5
|
||||
#define NLE_EXIST 6
|
||||
#define NLE_INVAL 7
|
||||
#define NLE_RANGE 8
|
||||
#define NLE_MSGSIZE 9
|
||||
#define NLE_OPNOTSUPP 10
|
||||
#define NLE_AF_NOSUPPORT 11
|
||||
#define NLE_OBJ_NOTFOUND 12
|
||||
#define NLE_NOATTR 13
|
||||
#define NLE_MISSING_ATTR 14
|
||||
#define NLE_AF_MISMATCH 15
|
||||
#define NLE_SEQ_MISMATCH 16
|
||||
#define NLE_MSG_OVERFLOW 17
|
||||
#define NLE_MSG_TRUNC 18
|
||||
#define NLE_NOADDR 19
|
||||
#define NLE_SRCRT_NOSUPPORT 20
|
||||
#define NLE_MSG_TOOSHORT 21
|
||||
#define NLE_MSGTYPE_NOSUPPORT 22
|
||||
#define NLE_OBJ_MISMATCH 23
|
||||
#define NLE_NOCACHE 24
|
||||
#define NLE_BUSY 25
|
||||
#define NLE_PROTO_MISMATCH 26
|
||||
#define NLE_NOACCESS 27
|
||||
#define NLE_PERM 28
|
||||
#define NLE_PKTLOC_FILE 29
|
||||
#define NLE_PARSE_ERR 30
|
||||
#define NLE_NODEV 31
|
||||
#define NLE_IMMUTABLE 32
|
||||
#define NLE_DUMP_INTR 33
|
||||
|
||||
#define NLE_MAX NLE_DUMP_INTR
|
||||
|
||||
extern const char * nl_geterror(int);
|
||||
extern void nl_perror(int, const char *);
|
||||
extern int nl_syserr2nlerr(int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* netlink/fib_lookup/fib_lookup.h FIB Lookup
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_FIB_LOOKUP_H_
|
||||
#define NETLINK_FIB_LOOKUP_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/addr.h>
|
||||
#include <netlink/fib_lookup/request.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct flnl_result;
|
||||
|
||||
extern struct flnl_result * flnl_result_alloc(void);
|
||||
extern void flnl_result_put(struct flnl_result *);
|
||||
|
||||
extern struct nl_cache * flnl_result_alloc_cache(void);
|
||||
|
||||
extern int flnl_lookup_build_request(struct flnl_request *,
|
||||
int,
|
||||
struct nl_msg **);
|
||||
extern int flnl_lookup(struct nl_sock *,
|
||||
struct flnl_request *,
|
||||
struct nl_cache *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* netlink/fib_lookup/request.h FIB Lookup Request
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_FIB_LOOKUP_REQUEST_H_
|
||||
#define NETLINK_FIB_LOOKUP_REQUEST_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/addr.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct flnl_request;
|
||||
|
||||
#define REQUEST_CAST(ptr) ((struct flnl_request *) (ptr))
|
||||
|
||||
extern struct flnl_request * flnl_request_alloc(void);
|
||||
|
||||
extern void flnl_request_set_fwmark(struct flnl_request *,
|
||||
uint64_t);
|
||||
extern uint64_t flnl_request_get_fwmark(struct flnl_request *);
|
||||
extern void flnl_request_set_tos(struct flnl_request *,
|
||||
int);
|
||||
extern int flnl_request_get_tos(struct flnl_request *);
|
||||
extern void flnl_request_set_scope(struct flnl_request *,
|
||||
int);
|
||||
extern int flnl_request_get_scope(struct flnl_request *);
|
||||
extern void flnl_request_set_table(struct flnl_request *,
|
||||
int);
|
||||
extern int flnl_request_get_table(struct flnl_request *);
|
||||
extern int flnl_request_set_addr(struct flnl_request *,
|
||||
struct nl_addr *);
|
||||
extern struct nl_addr * flnl_request_get_addr(struct flnl_request *);
|
||||
|
||||
extern int flnl_request_cmp(struct flnl_request *,
|
||||
struct flnl_request *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* netlink/genl/ctrl.h Generic Netlink Controller
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_GENL_CTRL_H_
|
||||
#define NETLINK_GENL_CTRL_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/addr.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct genl_family;
|
||||
|
||||
extern int genl_ctrl_alloc_cache(struct nl_sock *,
|
||||
struct nl_cache **);
|
||||
extern struct genl_family * genl_ctrl_search(struct nl_cache *, int);
|
||||
extern struct genl_family * genl_ctrl_search_by_name(struct nl_cache *,
|
||||
const char *);
|
||||
extern int genl_ctrl_resolve(struct nl_sock *,
|
||||
const char *);
|
||||
extern int genl_ctrl_resolve_grp(struct nl_sock *sk,
|
||||
const char *family,
|
||||
const char *grp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* netlink/genl/family.h Generic Netlink Family
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_GENL_FAMILY_H_
|
||||
#define NETLINK_GENL_FAMILY_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct genl_family;
|
||||
|
||||
extern struct genl_family * genl_family_alloc(void);
|
||||
extern void genl_family_put(struct genl_family *);
|
||||
|
||||
extern unsigned int genl_family_get_id(struct genl_family *);
|
||||
extern void genl_family_set_id(struct genl_family *, unsigned int);
|
||||
extern char * genl_family_get_name(struct genl_family *);
|
||||
extern void genl_family_set_name(struct genl_family *, const char *);
|
||||
extern uint8_t genl_family_get_version(struct genl_family *);
|
||||
extern void genl_family_set_version(struct genl_family *, uint8_t);
|
||||
extern uint32_t genl_family_get_hdrsize(struct genl_family *);
|
||||
extern void genl_family_set_hdrsize(struct genl_family *, uint32_t);
|
||||
extern uint32_t genl_family_get_maxattr(struct genl_family *);
|
||||
extern void genl_family_set_maxattr(struct genl_family *, uint32_t);
|
||||
|
||||
extern int genl_family_add_op(struct genl_family *, int, int);
|
||||
extern int genl_family_add_grp(struct genl_family *, uint32_t ,
|
||||
const char *);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* netlink/genl/genl.h Generic Netlink
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_GENL_H_
|
||||
#define NETLINK_GENL_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/msg.h>
|
||||
#include <netlink/attr.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int genl_connect(struct nl_sock *);
|
||||
extern int genl_send_simple(struct nl_sock *, int, int,
|
||||
int, int);
|
||||
|
||||
extern void * genlmsg_put(struct nl_msg *, uint32_t, uint32_t,
|
||||
int, int, int, uint8_t, uint8_t);
|
||||
|
||||
extern int genlmsg_valid_hdr(struct nlmsghdr *, int);
|
||||
extern int genlmsg_validate(struct nlmsghdr *, int, int,
|
||||
struct nla_policy *);
|
||||
extern int genlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
|
||||
int, struct nla_policy *);
|
||||
extern struct genlmsghdr *
|
||||
genlmsg_hdr(struct nlmsghdr *);
|
||||
extern void * genlmsg_data(const struct genlmsghdr *);
|
||||
extern void * genlmsg_user_hdr(const struct genlmsghdr *);
|
||||
extern void * genlmsg_user_data(const struct genlmsghdr *, const int);
|
||||
extern int genlmsg_user_datalen(const struct genlmsghdr *,
|
||||
const int);
|
||||
extern int genlmsg_len(const struct genlmsghdr *);
|
||||
extern struct nlattr * genlmsg_attrdata(const struct genlmsghdr *, int);
|
||||
extern int genlmsg_attrlen(const struct genlmsghdr *, int);
|
||||
|
||||
extern char * genl_op2name(int, int, char *, size_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* netlink/genl/mngt.h Generic Netlink Management
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_GENL_MNGT_H_
|
||||
#define NETLINK_GENL_MNGT_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/attr.h>
|
||||
#include <netlink/list.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nl_cache_ops;
|
||||
|
||||
/**
|
||||
* @ingroup genl_mngt
|
||||
* @struct genl_info netlink/genl/mngt.h
|
||||
*
|
||||
* Informative structure passed on to message parser callbacks
|
||||
*
|
||||
* This structure is passed on to all message parser callbacks and contains
|
||||
* information about the sender of the message as well as pointers to all
|
||||
* relevant sections of the parsed message.
|
||||
*
|
||||
* @see genl_cmd::c_msg_parser
|
||||
*/
|
||||
struct genl_info
|
||||
{
|
||||
/** Socket address of sender */
|
||||
struct sockaddr_nl * who;
|
||||
|
||||
/** Pointer to Netlink message header */
|
||||
struct nlmsghdr * nlh;
|
||||
|
||||
/** Pointer to Generic Netlink message header */
|
||||
struct genlmsghdr * genlhdr;
|
||||
|
||||
/** Pointer to user header */
|
||||
void * userhdr;
|
||||
|
||||
/** Pointer to array of parsed attributes */
|
||||
struct nlattr ** attrs;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup genl_mngt
|
||||
* @struct genl_cmd netlink/genl/mngt.h
|
||||
*
|
||||
* Definition of a Generic Netlink command.
|
||||
*
|
||||
* This structure is used to define the list of available commands on the
|
||||
* receiving side.
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* static struct genl_cmd foo_cmds[] = {
|
||||
* {
|
||||
* .c_id = FOO_CMD_NEW,
|
||||
* .c_name = "NEWFOO" ,
|
||||
* .c_maxattr = FOO_ATTR_MAX,
|
||||
* .c_attr_policy = foo_policy,
|
||||
* .c_msg_parser = foo_msg_parser,
|
||||
* },
|
||||
* {
|
||||
* .c_id = FOO_CMD_DEL,
|
||||
* .c_name = "DELFOO" ,
|
||||
* },
|
||||
* };
|
||||
*
|
||||
* static struct genl_ops my_genl_ops = {
|
||||
* [...]
|
||||
* .o_cmds = foo_cmds,
|
||||
* .o_ncmds = ARRAY_SIZE(foo_cmds),
|
||||
* };
|
||||
* @endcode
|
||||
*/
|
||||
struct genl_cmd
|
||||
{
|
||||
/** Numeric command identifier (required) */
|
||||
int c_id;
|
||||
|
||||
/** Human readable name (required) */
|
||||
char * c_name;
|
||||
|
||||
/** Maximum attribute identifier that the command is prepared to handle. */
|
||||
int c_maxattr;
|
||||
|
||||
/** Called whenever a message for this command is received */
|
||||
int (*c_msg_parser)(struct nl_cache_ops *,
|
||||
struct genl_cmd *,
|
||||
struct genl_info *, void *);
|
||||
|
||||
/** Attribute validation policy, enforced before the callback is called */
|
||||
struct nla_policy * c_attr_policy;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup genl_mngt
|
||||
* @struct genl_ops netlink/genl/mngt.h
|
||||
*
|
||||
* Definition of a Generic Netlink family
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* static struct genl_cmd foo_cmds[] = {
|
||||
* [...]
|
||||
* };
|
||||
*
|
||||
* static struct genl_ops my_genl_ops = {
|
||||
* .o_name = "foo",
|
||||
* .o_hdrsize = sizeof(struct my_hdr),
|
||||
* .o_cmds = foo_cmds,
|
||||
* .o_ncmds = ARRAY_SIZE(foo_cmds),
|
||||
* };
|
||||
*
|
||||
* if ((err = genl_register_family(&my_genl_ops)) < 0)
|
||||
* // ERROR
|
||||
* @endcode
|
||||
*
|
||||
* @see genl_cmd
|
||||
*/
|
||||
struct genl_ops
|
||||
{
|
||||
/** Length of user header */
|
||||
unsigned int o_hdrsize;
|
||||
|
||||
/** Numeric identifier, automatically filled in by genl_ops_resolve() */
|
||||
int o_id;
|
||||
|
||||
/** Human readable name, used by genl_ops_resolve() to resolve numeric id */
|
||||
char * o_name;
|
||||
|
||||
/**
|
||||
* If registered via genl_register(), will point to the related
|
||||
* cache operations.
|
||||
*/
|
||||
struct nl_cache_ops * o_cache_ops;
|
||||
|
||||
/** Optional array defining the available Generic Netlink commands */
|
||||
struct genl_cmd * o_cmds;
|
||||
|
||||
/** Number of elements in \c o_cmds array */
|
||||
int o_ncmds;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Used internally to link together all registered operations.
|
||||
*/
|
||||
struct nl_list_head o_list;
|
||||
};
|
||||
|
||||
extern int genl_register_family(struct genl_ops *);
|
||||
extern int genl_unregister_family(struct genl_ops *);
|
||||
extern int genl_handle_msg(struct nl_msg *, void *);
|
||||
|
||||
extern int genl_register(struct nl_cache_ops *);
|
||||
extern void genl_unregister(struct nl_cache_ops *);
|
||||
|
||||
extern int genl_ops_resolve(struct nl_sock *, struct genl_ops *);
|
||||
extern int genl_mngt_resolve(struct nl_sock *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* netlink/handlers.c default netlink message handlers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_HANDLERS_H_
|
||||
#define NETLINK_HANDLERS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <netlink/netlink-compat.h>
|
||||
#include <netlink/netlink-kernel.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nl_cb;
|
||||
struct nl_sock;
|
||||
struct nl_msg;
|
||||
struct ucred;
|
||||
|
||||
/**
|
||||
* @name Callback Typedefs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* nl_recvmsgs() callback for message processing customization
|
||||
* @ingroup cb
|
||||
* @arg msg netlink message being processed
|
||||
* @arg arg argument passwd on through caller
|
||||
*/
|
||||
typedef int (*nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg);
|
||||
|
||||
/**
|
||||
* nl_recvmsgs() callback for error message processing customization
|
||||
* @ingroup cb
|
||||
* @arg nla netlink address of the peer
|
||||
* @arg nlerr netlink error message being processed
|
||||
* @arg arg argument passed on through caller
|
||||
*/
|
||||
typedef int (*nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla,
|
||||
struct nlmsgerr *nlerr, void *arg);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Callback actions
|
||||
* @ingroup cb
|
||||
*/
|
||||
enum nl_cb_action {
|
||||
/** Proceed with wathever would come next */
|
||||
NL_OK,
|
||||
/** Skip this message */
|
||||
NL_SKIP,
|
||||
/** Stop parsing altogether and discard remaining messages */
|
||||
NL_STOP,
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback kinds
|
||||
* @ingroup cb
|
||||
*/
|
||||
enum nl_cb_kind {
|
||||
/** Default handlers (quiet) */
|
||||
NL_CB_DEFAULT,
|
||||
/** Verbose default handlers (error messages printed) */
|
||||
NL_CB_VERBOSE,
|
||||
/** Debug handlers for debugging */
|
||||
NL_CB_DEBUG,
|
||||
/** Customized handler specified by the user */
|
||||
NL_CB_CUSTOM,
|
||||
__NL_CB_KIND_MAX,
|
||||
};
|
||||
|
||||
#define NL_CB_KIND_MAX (__NL_CB_KIND_MAX - 1)
|
||||
|
||||
/**
|
||||
* Callback types
|
||||
* @ingroup cb
|
||||
*/
|
||||
enum nl_cb_type {
|
||||
/** Message is valid */
|
||||
NL_CB_VALID,
|
||||
/** Last message in a series of multi part messages received */
|
||||
NL_CB_FINISH,
|
||||
/** Report received that data was lost */
|
||||
NL_CB_OVERRUN,
|
||||
/** Message wants to be skipped */
|
||||
NL_CB_SKIPPED,
|
||||
/** Message is an acknowledge */
|
||||
NL_CB_ACK,
|
||||
/** Called for every message received */
|
||||
NL_CB_MSG_IN,
|
||||
/** Called for every message sent out except for nl_sendto() */
|
||||
NL_CB_MSG_OUT,
|
||||
/** Message is malformed and invalid */
|
||||
NL_CB_INVALID,
|
||||
/** Called instead of internal sequence number checking */
|
||||
NL_CB_SEQ_CHECK,
|
||||
/** Sending of an acknowledge message has been requested */
|
||||
NL_CB_SEND_ACK,
|
||||
/** Flag NLM_F_DUMP_INTR is set in message */
|
||||
NL_CB_DUMP_INTR,
|
||||
__NL_CB_TYPE_MAX,
|
||||
};
|
||||
|
||||
#define NL_CB_TYPE_MAX (__NL_CB_TYPE_MAX - 1)
|
||||
|
||||
extern struct nl_cb * nl_cb_alloc(enum nl_cb_kind);
|
||||
extern struct nl_cb * nl_cb_clone(struct nl_cb *);
|
||||
extern struct nl_cb * nl_cb_get(struct nl_cb *);
|
||||
extern void nl_cb_put(struct nl_cb *);
|
||||
|
||||
extern int nl_cb_set(struct nl_cb *, enum nl_cb_type, enum nl_cb_kind,
|
||||
nl_recvmsg_msg_cb_t, void *);
|
||||
extern int nl_cb_set_all(struct nl_cb *, enum nl_cb_kind,
|
||||
nl_recvmsg_msg_cb_t, void *);
|
||||
extern int nl_cb_err(struct nl_cb *, enum nl_cb_kind, nl_recvmsg_err_cb_t,
|
||||
void *);
|
||||
|
||||
extern void nl_cb_overwrite_recvmsgs(struct nl_cb *,
|
||||
int (*func)(struct nl_sock *,
|
||||
struct nl_cb *));
|
||||
extern void nl_cb_overwrite_recv(struct nl_cb *,
|
||||
int (*func)(struct nl_sock *,
|
||||
struct sockaddr_nl *,
|
||||
unsigned char **,
|
||||
struct ucred **));
|
||||
extern void nl_cb_overwrite_send(struct nl_cb *,
|
||||
int (*func)(struct nl_sock *,
|
||||
struct nl_msg *));
|
||||
|
||||
extern enum nl_cb_type nl_cb_active_type(struct nl_cb *cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file was taken from http://ccodearchive.net/info/hash.html
|
||||
* Changes to the original file include cleanups and removal of unwanted code
|
||||
* and also code that depended on build_asert
|
||||
*/
|
||||
#ifndef CCAN_HASH_H
|
||||
#define CCAN_HASH_H
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <endian.h>
|
||||
|
||||
/* Stolen mostly from: lookup3.c, by Bob Jenkins, May 2006, Public Domain.
|
||||
*
|
||||
* http://burtleburtle.net/bob/c/lookup3.c
|
||||
*/
|
||||
|
||||
#ifdef __LITTLE_ENDIAN
|
||||
# define HAVE_LITTLE_ENDIAN 1
|
||||
#elif __BIG_ENDIAN
|
||||
# define HAVE_BIG_ENDIAN 1
|
||||
#else
|
||||
#error Unknown endianness. Failure in endian.h
|
||||
#endif
|
||||
|
||||
/**
|
||||
* hash - fast hash of an array for internal use
|
||||
* @p: the array or pointer to first element
|
||||
* @num: the number of elements to hash
|
||||
* @base: the base number to roll into the hash (usually 0)
|
||||
*
|
||||
* The memory region pointed to by p is combined with the base to form
|
||||
* a 32-bit hash.
|
||||
*
|
||||
* This hash will have different results on different machines, so is
|
||||
* only useful for internal hashes (ie. not hashes sent across the
|
||||
* network or saved to disk).
|
||||
*
|
||||
* It may also change with future versions: it could even detect at runtime
|
||||
* what the fastest hash to use is.
|
||||
*
|
||||
* See also: hash64, hash_stable.
|
||||
*
|
||||
* Example:
|
||||
* #include <ccan/hash/hash.h>
|
||||
* #include <err.h>
|
||||
* #include <stdio.h>
|
||||
* #include <string.h>
|
||||
*
|
||||
* // Simple demonstration: idential strings will have the same hash, but
|
||||
* // two different strings will probably not.
|
||||
* int main(int argc, char *argv[])
|
||||
* {
|
||||
* uint32_t hash1, hash2;
|
||||
*
|
||||
* if (argc != 3)
|
||||
* err(1, "Usage: %s <string1> <string2>", argv[0]);
|
||||
*
|
||||
* hash1 = __nl_hash(argv[1], strlen(argv[1]), 0);
|
||||
* hash2 = __nl_hash(argv[2], strlen(argv[2]), 0);
|
||||
* printf("Hash is %s\n", hash1 == hash2 ? "same" : "different");
|
||||
* return 0;
|
||||
* }
|
||||
*/
|
||||
#define __nl_hash(p, num, base) nl_hash_any((p), (num)*sizeof(*(p)), (base))
|
||||
|
||||
/* Our underlying operations. */
|
||||
uint32_t nl_hash_any(const void *key, size_t length, uint32_t base);
|
||||
|
||||
#endif /* HASH_H */
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* netlink/hashtable.h Netlink hashtable Utilities
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2012 Cumulus Networks, Inc
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_HASHTABLE_H_
|
||||
#define NETLINK_HASHTABLE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct nl_hash_node {
|
||||
uint32_t key;
|
||||
uint32_t key_size;
|
||||
struct nl_object * obj;
|
||||
struct nl_hash_node * next;
|
||||
} nl_hash_node_t;
|
||||
|
||||
typedef struct nl_hash_table {
|
||||
int size;
|
||||
nl_hash_node_t ** nodes;
|
||||
} nl_hash_table_t;
|
||||
|
||||
/* Default hash table size */
|
||||
#define NL_MAX_HASH_ENTRIES 1024
|
||||
|
||||
/* Access Functions */
|
||||
extern nl_hash_table_t * nl_hash_table_alloc(int size);
|
||||
extern void nl_hash_table_free(nl_hash_table_t *ht);
|
||||
|
||||
extern int nl_hash_table_add(nl_hash_table_t *ht,
|
||||
struct nl_object *obj);
|
||||
extern int nl_hash_table_del(nl_hash_table_t *ht,
|
||||
struct nl_object *obj);
|
||||
|
||||
extern struct nl_object * nl_hash_table_lookup(nl_hash_table_t *ht,
|
||||
struct nl_object *obj);
|
||||
extern uint32_t nl_hash(void *k, size_t length,
|
||||
uint32_t initval);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NETLINK_HASHTABLE_H_ */
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* netlink/idiag/idiagnl.h Inetdiag Netlink
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_IDIAGNL_H_
|
||||
#define NETLINK_IDIAGNL_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Inet Diag message types
|
||||
*/
|
||||
#define IDIAG_TCPDIAG_GETSOCK 18
|
||||
#define IDIAG_DCCPDIAG_GETSOCK 19
|
||||
#define IDIAG_GETSOCK_MAX 24
|
||||
|
||||
/**
|
||||
* Socket state identifiers
|
||||
* @ingroup idiag
|
||||
*/
|
||||
enum {
|
||||
IDIAG_SS_UNKNOWN,
|
||||
IDIAG_SS_ESTABLISHED,
|
||||
IDIAG_SS_SYN_SENT,
|
||||
IDIAG_SS_SYN_RECV,
|
||||
IDIAG_SS_FIN_WAIT1,
|
||||
IDIAG_SS_FIN_WAIT2,
|
||||
IDIAG_SS_TIME_WAIT,
|
||||
IDIAG_SS_CLOSE,
|
||||
IDIAG_SS_CLOSE_WAIT,
|
||||
IDIAG_SS_LAST_ACK,
|
||||
IDIAG_SS_LISTEN,
|
||||
IDIAG_SS_CLOSING,
|
||||
IDIAG_SS_MAX
|
||||
};
|
||||
|
||||
/**
|
||||
* Macro to represent all socket states.
|
||||
* @ingroup idiag
|
||||
*/
|
||||
#define IDIAG_SS_ALL ((1<<IDIAG_SS_MAX)-1)
|
||||
|
||||
/**
|
||||
* Inet Diag extended attributes
|
||||
* @ingroup idiag
|
||||
*/
|
||||
enum {
|
||||
IDIAG_ATTR_NONE,
|
||||
IDIAG_ATTR_MEMINFO,
|
||||
IDIAG_ATTR_INFO,
|
||||
IDIAG_ATTR_VEGASINFO,
|
||||
IDIAG_ATTR_CONG,
|
||||
IDIAG_ATTR_TOS,
|
||||
IDIAG_ATTR_TCLASS,
|
||||
IDIAG_ATTR_SKMEMINFO,
|
||||
IDIAG_ATTR_SHUTDOWN,
|
||||
IDIAG_ATTR_MAX,
|
||||
};
|
||||
|
||||
/**
|
||||
* Macro to represent all socket attributes.
|
||||
* @ingroup idiag
|
||||
*/
|
||||
#define IDIAG_ATTR_ALL ((1<<IDIAG_ATTR_MAX)-1)
|
||||
|
||||
/**
|
||||
* Socket memory info identifiers
|
||||
* @ingroup idiag
|
||||
*/
|
||||
enum {
|
||||
IDIAG_SK_MEMINFO_RMEM_ALLOC,
|
||||
IDIAG_SK_MEMINFO_RCVBUF,
|
||||
IDIAG_SK_MEMINFO_WMEM_ALLOC,
|
||||
IDIAG_SK_MEMINFO_SNDBUF,
|
||||
IDIAG_SK_MEMINFO_FWD_ALLOC,
|
||||
IDIAG_SK_MEMINFO_WMEM_QUEUED,
|
||||
IDIAG_SK_MEMINFO_OPTMEM,
|
||||
IDIAG_SK_MEMINFO_BACKLOG,
|
||||
|
||||
IDIAG_SK_MEMINFO_VARS,
|
||||
};
|
||||
|
||||
/**
|
||||
* Socket timer indentifiers
|
||||
* @ingroupd idiag
|
||||
*/
|
||||
enum {
|
||||
IDIAG_TIMER_OFF,
|
||||
IDIAG_TIMER_ON,
|
||||
IDIAG_TIMER_KEEPALIVE,
|
||||
IDIAG_TIMER_TIMEWAIT,
|
||||
IDIAG_TIMER_PERSIST,
|
||||
IDIAG_TIMER_UNKNOWN,
|
||||
};
|
||||
|
||||
extern char * idiagnl_state2str(int, char *, size_t);
|
||||
extern int idiagnl_str2state(const char *);
|
||||
|
||||
extern int idiagnl_connect(struct nl_sock *);
|
||||
extern int idiagnl_send_simple(struct nl_sock *, int, uint8_t, uint16_t,
|
||||
uint16_t);
|
||||
|
||||
extern char * idiagnl_timer2str(int, char *, size_t);
|
||||
extern int idiagnl_str2timer(const char *);
|
||||
extern char * idiagnl_attrs2str(int, char *, size_t);
|
||||
extern char * idiagnl_tcpstate2str(uint8_t, char *, size_t);
|
||||
extern char * idiagnl_tcpopts2str(uint8_t, char *, size_t);
|
||||
extern char * idiagnl_shutdown2str(uint8_t, char *, size_t);
|
||||
extern char * idiagnl_exts2str(uint8_t, char *, size_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* NETLINK_IDIAGNL_H_ */
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* netlink/idiag/meminfo.h Inetdiag Netlink Memory Info
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_IDIAGNL_MEMINFO_H_
|
||||
#define NETLINK_IDIAGNL_MEMINFO_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern struct nl_object_ops idiagnl_meminfo_obj_ops;
|
||||
|
||||
extern struct idiagnl_meminfo *idiagnl_meminfo_alloc(void);
|
||||
extern void idiagnl_meminfo_get(struct idiagnl_meminfo *);
|
||||
extern void idiagnl_meminfo_put(struct idiagnl_meminfo *);
|
||||
|
||||
extern uint32_t idiagnl_meminfo_get_rmem(const struct idiagnl_meminfo *);
|
||||
extern uint32_t idiagnl_meminfo_get_wmem(const struct idiagnl_meminfo *);
|
||||
extern uint32_t idiagnl_meminfo_get_fmem(const struct idiagnl_meminfo *);
|
||||
extern uint32_t idiagnl_meminfo_get_tmem(const struct idiagnl_meminfo *);
|
||||
|
||||
extern void idiagnl_meminfo_set_rmem(struct idiagnl_meminfo *, uint32_t);
|
||||
extern void idiagnl_meminfo_set_wmem(struct idiagnl_meminfo *, uint32_t);
|
||||
extern void idiagnl_meminfo_set_fmem(struct idiagnl_meminfo *, uint32_t);
|
||||
extern void idiagnl_meminfo_set_tmem(struct idiagnl_meminfo *, uint32_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* NETLINK_IDIAGNL_MEMINFO_H_ */
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* netlink/idiag/msg.h Inetdiag Netlink Message
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_IDIAGNL_MSG_H_
|
||||
#define NETLINK_IDIAGNL_MSG_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct idiagnl_msg;
|
||||
extern struct nl_object_ops idiagnl_msg_obj_ops;
|
||||
|
||||
extern struct idiagnl_msg * idiagnl_msg_alloc(void);
|
||||
extern int idiagnl_msg_alloc_cache(struct nl_sock *, int, int,
|
||||
struct nl_cache**);
|
||||
extern void idiagnl_msg_get(struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_put(struct idiagnl_msg *);
|
||||
extern uint8_t idiagnl_msg_get_family(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_family(struct idiagnl_msg *, uint8_t);
|
||||
extern uint8_t idiagnl_msg_get_state(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_state(struct idiagnl_msg *, uint8_t);
|
||||
extern uint8_t idiagnl_msg_get_timer(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_timer(struct idiagnl_msg *, uint8_t);
|
||||
extern uint8_t idiagnl_msg_get_retrans(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_retrans(struct idiagnl_msg *, uint8_t);
|
||||
extern uint16_t idiagnl_msg_get_sport(struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_sport(struct idiagnl_msg *, uint16_t);
|
||||
extern uint16_t idiagnl_msg_get_dport(struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_dport(struct idiagnl_msg *, uint16_t);
|
||||
extern struct nl_addr * idiagnl_msg_get_src(const struct idiagnl_msg *);
|
||||
extern int idiagnl_msg_set_src(struct idiagnl_msg *,
|
||||
struct nl_addr *);
|
||||
extern struct nl_addr * idiagnl_msg_get_dst(const struct idiagnl_msg *);
|
||||
extern int idiagnl_msg_set_dst(struct idiagnl_msg *,
|
||||
struct nl_addr *);
|
||||
extern uint32_t idiagnl_msg_get_ifindex(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_ifindex(struct idiagnl_msg *, uint32_t);
|
||||
extern uint32_t idiagnl_msg_get_expires(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_expires(struct idiagnl_msg *, uint32_t);
|
||||
extern uint32_t idiagnl_msg_get_rqueue(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_rqueue(struct idiagnl_msg *, uint32_t);
|
||||
extern uint32_t idiagnl_msg_get_wqueue(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_wqueue(struct idiagnl_msg *, uint32_t);
|
||||
extern uint32_t idiagnl_msg_get_uid(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_uid(struct idiagnl_msg *, uint32_t);
|
||||
extern uint32_t idiagnl_msg_get_inode(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_inode(struct idiagnl_msg *, uint32_t);
|
||||
extern uint8_t idiagnl_msg_get_tos(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_tos(struct idiagnl_msg *, uint8_t);
|
||||
extern uint8_t idiagnl_msg_get_tclass(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_tclass(struct idiagnl_msg *, uint8_t);
|
||||
extern uint8_t idiagnl_msg_get_shutdown(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_shutdown(struct idiagnl_msg *, uint8_t);
|
||||
extern char * idiagnl_msg_get_cong(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_cong(struct idiagnl_msg *, char *);
|
||||
extern struct idiagnl_meminfo *idiagnl_msg_get_meminfo(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_meminfo(struct idiagnl_msg *,
|
||||
struct idiagnl_meminfo *);
|
||||
extern struct idiagnl_vegasinfo *idiagnl_msg_get_vegasinfo(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_vegasinfo(struct idiagnl_msg *,
|
||||
struct idiagnl_vegasinfo *);
|
||||
extern struct tcp_info idiagnl_msg_get_tcpinfo(const struct idiagnl_msg *);
|
||||
extern void idiagnl_msg_set_tcpinfo(struct idiagnl_msg *,
|
||||
struct tcp_info *);
|
||||
|
||||
extern int idiagnl_msg_parse(struct nlmsghdr *,
|
||||
struct idiagnl_msg **);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* NETLINK_IDIAGNL_MSG_H_ */
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* netlink/idiag/req.h Inetdiag Netlink Request
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_IDIAGNL_REQ_H_
|
||||
#define NETLINK_IDIAGNL_REQ_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct idiagnl_req;
|
||||
extern struct nl_object_ops idiagnl_req_obj_ops;
|
||||
|
||||
extern struct idiagnl_req * idiagnl_req_alloc(void);
|
||||
extern void idiagnl_req_get(struct idiagnl_req *);
|
||||
extern void idiagnl_req_put(struct idiagnl_req *);
|
||||
extern uint8_t idiagnl_req_get_family(const struct idiagnl_req *);
|
||||
extern void idiagnl_req_set_family(struct idiagnl_req *,
|
||||
uint8_t);
|
||||
extern uint8_t idiagnl_req_get_ext(const struct idiagnl_req *);
|
||||
extern void idiagnl_req_set_ext(struct idiagnl_req *, uint8_t);
|
||||
extern uint32_t idiagnl_req_get_ifindex(const struct idiagnl_req *);
|
||||
extern void idiagnl_req_set_ifindex(struct idiagnl_req *,
|
||||
uint32_t);
|
||||
extern uint32_t idiagnl_req_get_states(const struct idiagnl_req *);
|
||||
extern void idiagnl_req_set_states(struct idiagnl_req *,
|
||||
uint32_t);
|
||||
extern uint32_t idiagnl_req_get_dbs(const struct idiagnl_req *);
|
||||
extern void idiagnl_req_set_dbs(struct idiagnl_req *, uint32_t);
|
||||
extern struct nl_addr * idiagnl_req_get_src(const struct idiagnl_req *);
|
||||
extern int idiagnl_req_set_src(struct idiagnl_req *,
|
||||
struct nl_addr *);
|
||||
extern struct nl_addr * idiagnl_req_get_dst(const struct idiagnl_req *);
|
||||
extern int idiagnl_req_set_dst(struct idiagnl_req *,
|
||||
struct nl_addr *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* NETLINK_IDIAGNL_REQ_H_ */
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* netlink/idiag/vegasinfo.h Inetdiag Netlink TCP Vegas Info
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_IDIAGNL_VEGASINFO_H_
|
||||
#define NETLINK_IDIAGNL_VEGASINFO_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern struct nl_object_ops idiagnl_vegasinfo_obj_ops;
|
||||
extern struct idiagnl_vegasinfo * idiagnl_vegasinfo_alloc(void);
|
||||
extern void idiagnl_vegasinfo_get(struct idiagnl_vegasinfo *);
|
||||
extern void idiagnl_vegasinfo_put(struct idiagnl_vegasinfo *);
|
||||
|
||||
extern uint32_t idiagnl_vegasinfo_get_enabled(const struct idiagnl_vegasinfo *);
|
||||
extern uint32_t idiagnl_vegasinfo_get_rttcnt(const struct idiagnl_vegasinfo *);
|
||||
extern uint32_t idiagnl_vegasinfo_get_rtt(const struct idiagnl_vegasinfo *);
|
||||
extern uint32_t idiagnl_vegasinfo_get_minrtt(const struct idiagnl_vegasinfo *);
|
||||
|
||||
extern void idiagnl_vegasinfo_set_enabled(struct idiagnl_vegasinfo *,
|
||||
uint32_t);
|
||||
extern void idiagnl_vegasinfo_set_rttcnt(struct idiagnl_vegasinfo *,
|
||||
uint32_t);
|
||||
extern void idiagnl_vegasinfo_set_rtt(struct idiagnl_vegasinfo *, uint32_t);
|
||||
extern void idiagnl_vegasinfo_set_minrtt(struct idiagnl_vegasinfo *,
|
||||
uint32_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* NETLINK_IDIAGNL_VEGASINFO_H_ */
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* netlink/list.h Netlink List Utilities
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_LIST_H_
|
||||
#define NETLINK_LIST_H_
|
||||
|
||||
struct nl_list_head
|
||||
{
|
||||
struct nl_list_head * next;
|
||||
struct nl_list_head * prev;
|
||||
};
|
||||
|
||||
static inline void NL_INIT_LIST_HEAD(struct nl_list_head *list)
|
||||
{
|
||||
list->next = list;
|
||||
list->prev = list;
|
||||
}
|
||||
|
||||
static inline void __nl_list_add(struct nl_list_head *obj,
|
||||
struct nl_list_head *prev,
|
||||
struct nl_list_head *next)
|
||||
{
|
||||
prev->next = obj;
|
||||
obj->prev = prev;
|
||||
next->prev = obj;
|
||||
obj->next = next;
|
||||
}
|
||||
|
||||
static inline void nl_list_add_tail(struct nl_list_head *obj,
|
||||
struct nl_list_head *head)
|
||||
{
|
||||
__nl_list_add(obj, head->prev, head);
|
||||
}
|
||||
|
||||
static inline void nl_list_add_head(struct nl_list_head *obj,
|
||||
struct nl_list_head *head)
|
||||
{
|
||||
__nl_list_add(obj, head, head->next);
|
||||
}
|
||||
|
||||
static inline void nl_list_del(struct nl_list_head *obj)
|
||||
{
|
||||
obj->next->prev = obj->prev;
|
||||
obj->prev->next = obj->next;
|
||||
}
|
||||
|
||||
static inline int nl_list_empty(struct nl_list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
#define nl_container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - ((size_t) &((type *)0)->member));})
|
||||
|
||||
#define nl_list_entry(ptr, type, member) \
|
||||
nl_container_of(ptr, type, member)
|
||||
|
||||
#define nl_list_at_tail(pos, head, member) \
|
||||
((pos)->member.next == (head))
|
||||
|
||||
#define nl_list_at_head(pos, head, member) \
|
||||
((pos)->member.prev == (head))
|
||||
|
||||
#define NL_LIST_HEAD(name) \
|
||||
struct nl_list_head name = { &(name), &(name) }
|
||||
|
||||
#define nl_list_first_entry(head, type, member) \
|
||||
nl_list_entry((head)->next, type, member)
|
||||
|
||||
#define nl_list_for_each_entry(pos, head, member) \
|
||||
for (pos = nl_list_entry((head)->next, typeof(*pos), member); \
|
||||
&(pos)->member != (head); \
|
||||
(pos) = nl_list_entry((pos)->member.next, typeof(*(pos)), member))
|
||||
|
||||
#define nl_list_for_each_entry_safe(pos, n, head, member) \
|
||||
for (pos = nl_list_entry((head)->next, typeof(*pos), member), \
|
||||
n = nl_list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&(pos)->member != (head); \
|
||||
pos = n, n = nl_list_entry(n->member.next, typeof(*n), member))
|
||||
|
||||
#define nl_init_list_head(head) \
|
||||
do { (head)->next = (head); (head)->prev = (head); } while (0)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* netlink/msg.c Netlink Messages Interface
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_MSG_H_
|
||||
#define NETLINK_MSG_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/object.h>
|
||||
#include <netlink/attr.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NL_DONTPAD 0
|
||||
|
||||
/**
|
||||
* @ingroup msg
|
||||
* @brief
|
||||
* Will cause the netlink port to be set to the port assigned to
|
||||
* the netlink icoket ust before sending the message off.
|
||||
*
|
||||
* @note Requires the use of nl_send_auto()!
|
||||
*/
|
||||
#define NL_AUTO_PORT 0
|
||||
#define NL_AUTO_PID NL_AUTO_PORT
|
||||
|
||||
/**
|
||||
* @ingroup msg
|
||||
* @brief
|
||||
* May be used to refer to a sequence number which should be
|
||||
* automatically set just before sending the message off.
|
||||
*
|
||||
* @note Requires the use of nl_send_auto()!
|
||||
*/
|
||||
#define NL_AUTO_SEQ 0
|
||||
|
||||
struct nl_msg;
|
||||
struct nl_tree;
|
||||
struct ucred;
|
||||
|
||||
extern int nlmsg_size(int);
|
||||
extern int nlmsg_total_size(int);
|
||||
extern int nlmsg_padlen(int);
|
||||
|
||||
extern void * nlmsg_data(const struct nlmsghdr *);
|
||||
extern int nlmsg_datalen(const struct nlmsghdr *);
|
||||
extern void * nlmsg_tail(const struct nlmsghdr *);
|
||||
|
||||
/* attribute access */
|
||||
extern struct nlattr * nlmsg_attrdata(const struct nlmsghdr *, int);
|
||||
extern int nlmsg_attrlen(const struct nlmsghdr *, int);
|
||||
|
||||
/* message parsing */
|
||||
extern int nlmsg_valid_hdr(const struct nlmsghdr *, int);
|
||||
extern int nlmsg_ok(const struct nlmsghdr *, int);
|
||||
extern struct nlmsghdr * nlmsg_next(struct nlmsghdr *, int *);
|
||||
extern int nlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
|
||||
int, struct nla_policy *);
|
||||
extern struct nlattr * nlmsg_find_attr(struct nlmsghdr *, int, int);
|
||||
extern int nlmsg_validate(struct nlmsghdr *, int, int,
|
||||
struct nla_policy *);
|
||||
|
||||
extern struct nl_msg * nlmsg_alloc(void);
|
||||
extern struct nl_msg * nlmsg_alloc_size(size_t);
|
||||
extern struct nl_msg * nlmsg_alloc_simple(int, int);
|
||||
extern void nlmsg_set_default_size(size_t);
|
||||
extern struct nl_msg * nlmsg_inherit(struct nlmsghdr *);
|
||||
extern struct nl_msg * nlmsg_convert(struct nlmsghdr *);
|
||||
extern void * nlmsg_reserve(struct nl_msg *, size_t, int);
|
||||
extern int nlmsg_append(struct nl_msg *, void *, size_t, int);
|
||||
extern int nlmsg_expand(struct nl_msg *, size_t);
|
||||
|
||||
extern struct nlmsghdr * nlmsg_put(struct nl_msg *, uint32_t, uint32_t,
|
||||
int, int, int);
|
||||
extern struct nlmsghdr * nlmsg_hdr(struct nl_msg *);
|
||||
extern void nlmsg_get(struct nl_msg *);
|
||||
extern void nlmsg_free(struct nl_msg *);
|
||||
|
||||
/* attribute modification */
|
||||
extern void nlmsg_set_proto(struct nl_msg *, int);
|
||||
extern int nlmsg_get_proto(struct nl_msg *);
|
||||
extern size_t nlmsg_get_max_size(struct nl_msg *);
|
||||
extern void nlmsg_set_src(struct nl_msg *, struct sockaddr_nl *);
|
||||
extern struct sockaddr_nl *nlmsg_get_src(struct nl_msg *);
|
||||
extern void nlmsg_set_dst(struct nl_msg *, struct sockaddr_nl *);
|
||||
extern struct sockaddr_nl *nlmsg_get_dst(struct nl_msg *);
|
||||
extern void nlmsg_set_creds(struct nl_msg *, struct ucred *);
|
||||
extern struct ucred * nlmsg_get_creds(struct nl_msg *);
|
||||
|
||||
extern char * nl_nlmsgtype2str(int, char *, size_t);
|
||||
extern int nl_str2nlmsgtype(const char *);
|
||||
|
||||
extern char * nl_nlmsg_flags2str(int, char *, size_t);
|
||||
|
||||
extern int nl_msg_parse(struct nl_msg *,
|
||||
void (*cb)(struct nl_object *, void *),
|
||||
void *);
|
||||
|
||||
extern void nl_msg_dump(struct nl_msg *, FILE *);
|
||||
|
||||
/**
|
||||
* @name Iterators
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup msg
|
||||
* Iterate over a stream of attributes in a message
|
||||
* @arg pos loop counter, set to current attribute
|
||||
* @arg nlh netlink message header
|
||||
* @arg hdrlen length of family header
|
||||
* @arg rem initialized to len, holds bytes currently remaining in stream
|
||||
*/
|
||||
#define nlmsg_for_each_attr(pos, nlh, hdrlen, rem) \
|
||||
nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
|
||||
nlmsg_attrlen(nlh, hdrlen), rem)
|
||||
|
||||
/**
|
||||
* Iterate over a stream of messages
|
||||
* @arg pos loop counter, set to current message
|
||||
* @arg head head of message stream
|
||||
* @arg len length of message stream
|
||||
*/
|
||||
#define nlmsg_for_each(pos, head, len) \
|
||||
for (int rem = len, pos = head; \
|
||||
nlmsg_ok(pos, rem); \
|
||||
pos = nlmsg_next(pos, &rem))
|
||||
|
||||
#define nlmsg_for_each_msg(pos, head, len, rem) \
|
||||
nlmsg_for_each(pos, head, len)
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* netlink/netfilter/ct.h Conntrack
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2007 Philip Craig <philipc@snapgear.com>
|
||||
* Copyright (c) 2007 Secure Computing Corporation
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CT_H_
|
||||
#define NETLINK_CT_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/addr.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/msg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nfnl_ct;
|
||||
|
||||
struct nfnl_ct_timestamp {
|
||||
uint64_t start;
|
||||
uint64_t stop;
|
||||
};
|
||||
|
||||
extern struct nl_object_ops ct_obj_ops;
|
||||
|
||||
extern struct nfnl_ct * nfnl_ct_alloc(void);
|
||||
extern int nfnl_ct_alloc_cache(struct nl_sock *, struct nl_cache **);
|
||||
|
||||
extern int nfnlmsg_ct_group(struct nlmsghdr *);
|
||||
extern int nfnlmsg_ct_parse(struct nlmsghdr *, struct nfnl_ct **);
|
||||
|
||||
extern void nfnl_ct_get(struct nfnl_ct *);
|
||||
extern void nfnl_ct_put(struct nfnl_ct *);
|
||||
|
||||
extern int nfnl_ct_dump_request(struct nl_sock *);
|
||||
|
||||
extern int nfnl_ct_build_add_request(const struct nfnl_ct *, int,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_ct_add(struct nl_sock *, const struct nfnl_ct *, int);
|
||||
|
||||
extern int nfnl_ct_build_delete_request(const struct nfnl_ct *, int,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_ct_del(struct nl_sock *, const struct nfnl_ct *, int);
|
||||
|
||||
extern int nfnl_ct_build_query_request(const struct nfnl_ct *, int,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_ct_query(struct nl_sock *, const struct nfnl_ct *, int);
|
||||
|
||||
extern void nfnl_ct_set_family(struct nfnl_ct *, uint8_t);
|
||||
extern uint8_t nfnl_ct_get_family(const struct nfnl_ct *);
|
||||
|
||||
extern void nfnl_ct_set_proto(struct nfnl_ct *, uint8_t);
|
||||
extern int nfnl_ct_test_proto(const struct nfnl_ct *);
|
||||
extern uint8_t nfnl_ct_get_proto(const struct nfnl_ct *);
|
||||
|
||||
extern void nfnl_ct_set_tcp_state(struct nfnl_ct *, uint8_t);
|
||||
extern int nfnl_ct_test_tcp_state(const struct nfnl_ct *);
|
||||
extern uint8_t nfnl_ct_get_tcp_state(const struct nfnl_ct *);
|
||||
extern char * nfnl_ct_tcp_state2str(uint8_t, char *, size_t);
|
||||
extern int nfnl_ct_str2tcp_state(const char *name);
|
||||
|
||||
extern void nfnl_ct_set_status(struct nfnl_ct *, uint32_t);
|
||||
extern void nfnl_ct_unset_status(struct nfnl_ct *, uint32_t);
|
||||
extern int nfnl_ct_test_status(const struct nfnl_ct *ct);
|
||||
extern uint32_t nfnl_ct_get_status(const struct nfnl_ct *);
|
||||
extern char * nfnl_ct_status2str(int, char *, size_t);
|
||||
extern int nfnl_ct_str2status(const char *);
|
||||
|
||||
extern void nfnl_ct_set_timeout(struct nfnl_ct *, uint32_t);
|
||||
extern int nfnl_ct_test_timeout(const struct nfnl_ct *);
|
||||
extern uint32_t nfnl_ct_get_timeout(const struct nfnl_ct *);
|
||||
|
||||
extern void nfnl_ct_set_mark(struct nfnl_ct *, uint32_t);
|
||||
extern int nfnl_ct_test_mark(const struct nfnl_ct *);
|
||||
extern uint32_t nfnl_ct_get_mark(const struct nfnl_ct *);
|
||||
|
||||
extern void nfnl_ct_set_use(struct nfnl_ct *, uint32_t);
|
||||
extern int nfnl_ct_test_use(const struct nfnl_ct *);
|
||||
extern uint32_t nfnl_ct_get_use(const struct nfnl_ct *);
|
||||
|
||||
extern void nfnl_ct_set_id(struct nfnl_ct *, uint32_t);
|
||||
extern int nfnl_ct_test_id(const struct nfnl_ct *);
|
||||
extern uint32_t nfnl_ct_get_id(const struct nfnl_ct *);
|
||||
|
||||
extern void nfnl_ct_set_zone(struct nfnl_ct *, uint16_t);
|
||||
extern int nfnl_ct_test_zone(const struct nfnl_ct *);
|
||||
extern uint16_t nfnl_ct_get_zone(const struct nfnl_ct *);
|
||||
|
||||
extern int nfnl_ct_set_src(struct nfnl_ct *, int, struct nl_addr *);
|
||||
extern struct nl_addr * nfnl_ct_get_src(const struct nfnl_ct *, int);
|
||||
|
||||
extern int nfnl_ct_set_dst(struct nfnl_ct *, int, struct nl_addr *);
|
||||
extern struct nl_addr * nfnl_ct_get_dst(const struct nfnl_ct *, int);
|
||||
|
||||
extern void nfnl_ct_set_src_port(struct nfnl_ct *, int, uint16_t);
|
||||
extern int nfnl_ct_test_src_port(const struct nfnl_ct *, int);
|
||||
extern uint16_t nfnl_ct_get_src_port(const struct nfnl_ct *, int);
|
||||
|
||||
extern void nfnl_ct_set_dst_port(struct nfnl_ct *, int, uint16_t);
|
||||
extern int nfnl_ct_test_dst_port(const struct nfnl_ct *, int);
|
||||
extern uint16_t nfnl_ct_get_dst_port(const struct nfnl_ct *, int);
|
||||
|
||||
extern void nfnl_ct_set_icmp_id(struct nfnl_ct *, int, uint16_t);
|
||||
extern int nfnl_ct_test_icmp_id(const struct nfnl_ct *, int);
|
||||
extern uint16_t nfnl_ct_get_icmp_id(const struct nfnl_ct *, int);
|
||||
|
||||
extern void nfnl_ct_set_icmp_type(struct nfnl_ct *, int, uint8_t);
|
||||
extern int nfnl_ct_test_icmp_type(const struct nfnl_ct *, int);
|
||||
extern uint8_t nfnl_ct_get_icmp_type(const struct nfnl_ct *, int);
|
||||
|
||||
extern void nfnl_ct_set_icmp_code(struct nfnl_ct *, int, uint8_t);
|
||||
extern int nfnl_ct_test_icmp_code(const struct nfnl_ct *, int);
|
||||
extern uint8_t nfnl_ct_get_icmp_code(const struct nfnl_ct *, int);
|
||||
|
||||
extern void nfnl_ct_set_packets(struct nfnl_ct *, int, uint64_t);
|
||||
extern int nfnl_ct_test_packets(const struct nfnl_ct *, int);
|
||||
extern uint64_t nfnl_ct_get_packets(const struct nfnl_ct *,int);
|
||||
|
||||
extern void nfnl_ct_set_bytes(struct nfnl_ct *, int, uint64_t);
|
||||
extern int nfnl_ct_test_bytes(const struct nfnl_ct *, int);
|
||||
extern uint64_t nfnl_ct_get_bytes(const struct nfnl_ct *, int);
|
||||
|
||||
extern void nfnl_ct_set_timestamp(struct nfnl_ct *, uint64_t, uint64_t);
|
||||
extern int nfnl_ct_test_timestamp(const struct nfnl_ct *);
|
||||
extern const struct nfnl_ct_timestamp *nfnl_ct_get_timestamp(const struct nfnl_ct *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* netlink/netfilter/exp.h Conntrack Expectation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2007 Philip Craig <philipc@snapgear.com>
|
||||
* Copyright (c) 2007 Secure Computing Corporation
|
||||
* Copyright (c) 2012 Rich Fought <rich.fought@watchguard.com>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_EXP_H_
|
||||
#define NETLINK_EXP_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/addr.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/msg.h>
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nfnl_exp;
|
||||
|
||||
enum nfnl_exp_tuples {
|
||||
NFNL_EXP_TUPLE_EXPECT,
|
||||
NFNL_EXP_TUPLE_MASTER,
|
||||
NFNL_EXP_TUPLE_MASK,
|
||||
NFNL_EXP_TUPLE_NAT,
|
||||
NFNL_EXP_TUPLE_MAX
|
||||
};
|
||||
|
||||
extern struct nl_object_ops exp_obj_ops;
|
||||
|
||||
extern struct nfnl_exp * nfnl_exp_alloc(void);
|
||||
extern int nfnl_exp_alloc_cache(struct nl_sock *, struct nl_cache **);
|
||||
|
||||
extern int nfnlmsg_exp_group(struct nlmsghdr *);
|
||||
extern int nfnlmsg_exp_parse(struct nlmsghdr *, struct nfnl_exp **);
|
||||
|
||||
extern void nfnl_exp_get(struct nfnl_exp *);
|
||||
extern void nfnl_exp_put(struct nfnl_exp *);
|
||||
|
||||
extern int nfnl_exp_dump_request(struct nl_sock *);
|
||||
|
||||
extern int nfnl_exp_build_add_request(const struct nfnl_exp *, int,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_exp_add(struct nl_sock *, const struct nfnl_exp *, int);
|
||||
|
||||
extern int nfnl_exp_build_delete_request(const struct nfnl_exp *, int,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_exp_del(struct nl_sock *, const struct nfnl_exp *, int);
|
||||
|
||||
extern int nfnl_exp_build_query_request(const struct nfnl_exp *, int,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_exp_query(struct nl_sock *, const struct nfnl_exp *, int);
|
||||
|
||||
extern void nfnl_exp_set_family(struct nfnl_exp *, uint8_t);
|
||||
extern uint8_t nfnl_exp_get_family(const struct nfnl_exp *);
|
||||
|
||||
extern void nfnl_exp_set_timeout(struct nfnl_exp *, uint32_t);
|
||||
extern int nfnl_exp_test_timeout(const struct nfnl_exp *);
|
||||
extern uint32_t nfnl_exp_get_timeout(const struct nfnl_exp *);
|
||||
|
||||
extern void nfnl_exp_set_id(struct nfnl_exp *, uint32_t);
|
||||
extern int nfnl_exp_test_id(const struct nfnl_exp *);
|
||||
extern uint32_t nfnl_exp_get_id(const struct nfnl_exp *);
|
||||
|
||||
extern int nfnl_exp_set_helper_name(struct nfnl_exp *, void *);
|
||||
extern int nfnl_exp_test_helper_name(const struct nfnl_exp *);
|
||||
extern const char * nfnl_exp_get_helper_name(const struct nfnl_exp *);
|
||||
|
||||
extern void nfnl_exp_set_zone(struct nfnl_exp *, uint16_t);
|
||||
extern int nfnl_exp_test_zone(const struct nfnl_exp *);
|
||||
extern uint16_t nfnl_exp_get_zone(const struct nfnl_exp *);
|
||||
|
||||
extern void nfnl_exp_set_flags(struct nfnl_exp *, uint32_t);
|
||||
extern int nfnl_exp_test_flags(const struct nfnl_exp *);
|
||||
extern uint32_t nfnl_exp_get_flags(const struct nfnl_exp *);
|
||||
|
||||
extern void nfnl_exp_set_class(struct nfnl_exp *, uint32_t);
|
||||
extern int nfnl_exp_test_class(const struct nfnl_exp *);
|
||||
extern uint32_t nfnl_exp_get_class(const struct nfnl_exp *);
|
||||
|
||||
extern int nfnl_exp_set_fn(struct nfnl_exp *, void *);
|
||||
extern int nfnl_exp_test_fn(const struct nfnl_exp *);
|
||||
extern const char * nfnl_exp_get_fn(const struct nfnl_exp *);
|
||||
|
||||
extern void nfnl_exp_set_nat_dir(struct nfnl_exp *, uint8_t);
|
||||
extern int nfnl_exp_test_nat_dir(const struct nfnl_exp *);
|
||||
extern uint8_t nfnl_exp_get_nat_dir(const struct nfnl_exp *);
|
||||
|
||||
// The int argument specifies which nfnl_exp_dir (expect, master, mask or nat)
|
||||
// Expectation objects only use orig, not reply
|
||||
|
||||
extern int nfnl_exp_set_src(struct nfnl_exp *, int, struct nl_addr *);
|
||||
extern int nfnl_exp_test_src(const struct nfnl_exp *, int);
|
||||
extern struct nl_addr * nfnl_exp_get_src(const struct nfnl_exp *, int);
|
||||
|
||||
extern int nfnl_exp_set_dst(struct nfnl_exp *, int, struct nl_addr *);
|
||||
extern int nfnl_exp_test_dst(const struct nfnl_exp *, int);
|
||||
extern struct nl_addr * nfnl_exp_get_dst(const struct nfnl_exp *, int);
|
||||
|
||||
extern void nfnl_exp_set_l4protonum(struct nfnl_exp *, int, uint8_t);
|
||||
extern int nfnl_exp_test_l4protonum(const struct nfnl_exp *, int);
|
||||
extern uint8_t nfnl_exp_get_l4protonum(const struct nfnl_exp *, int);
|
||||
|
||||
extern void nfnl_exp_set_ports(struct nfnl_exp *, int, uint16_t, uint16_t);
|
||||
extern int nfnl_exp_test_ports(const struct nfnl_exp *, int);
|
||||
extern uint16_t nfnl_exp_get_src_port(const struct nfnl_exp *, int);
|
||||
extern uint16_t nfnl_exp_get_dst_port(const struct nfnl_exp *, int);
|
||||
|
||||
extern void nfnl_exp_set_icmp(struct nfnl_exp *, int, uint16_t, uint8_t, uint8_t);
|
||||
extern int nfnl_exp_test_icmp(const struct nfnl_exp *, int);
|
||||
extern uint16_t nfnl_exp_get_icmp_id(const struct nfnl_exp *, int);
|
||||
extern uint8_t nfnl_exp_get_icmp_type(const struct nfnl_exp *, int);
|
||||
extern uint8_t nfnl_exp_get_icmp_code(const struct nfnl_exp *, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* netlink/netfilter/log.h Netfilter Log
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2007 Philip Craig <philipc@snapgear.com>
|
||||
* Copyright (c) 2007 Secure Computing Corporation
|
||||
* Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_LOG_H_
|
||||
#define NETLINK_LOG_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nl_sock;
|
||||
struct nlmsghdr;
|
||||
struct nfnl_log;
|
||||
|
||||
extern struct nl_object_ops log_obj_ops;
|
||||
|
||||
enum nfnl_log_copy_mode {
|
||||
NFNL_LOG_COPY_NONE,
|
||||
NFNL_LOG_COPY_META,
|
||||
NFNL_LOG_COPY_PACKET,
|
||||
};
|
||||
|
||||
enum nfnl_log_flags {
|
||||
NFNL_LOG_FLAG_SEQ = 0x1,
|
||||
NFNL_LOG_FLAG_SEQ_GLOBAL = 0x2,
|
||||
};
|
||||
|
||||
/* General */
|
||||
extern struct nfnl_log * nfnl_log_alloc(void);
|
||||
extern int nfnlmsg_log_parse(struct nlmsghdr *,
|
||||
struct nfnl_log **);
|
||||
|
||||
extern void nfnl_log_get(struct nfnl_log *);
|
||||
extern void nfnl_log_put(struct nfnl_log *);
|
||||
|
||||
/* Attributes */
|
||||
extern void nfnl_log_set_group(struct nfnl_log *, uint16_t);
|
||||
extern int nfnl_log_test_group(const struct nfnl_log *);
|
||||
extern uint16_t nfnl_log_get_group(const struct nfnl_log *);
|
||||
|
||||
extern void nfnl_log_set_copy_mode(struct nfnl_log *,
|
||||
enum nfnl_log_copy_mode);
|
||||
extern int nfnl_log_test_copy_mode(const struct nfnl_log *);
|
||||
extern enum nfnl_log_copy_mode nfnl_log_get_copy_mode(const struct nfnl_log *);
|
||||
|
||||
extern char * nfnl_log_copy_mode2str(enum nfnl_log_copy_mode,
|
||||
char *, size_t);
|
||||
extern enum nfnl_log_copy_mode nfnl_log_str2copy_mode(const char *);
|
||||
|
||||
extern void nfnl_log_set_copy_range(struct nfnl_log *, uint32_t);
|
||||
extern int nfnl_log_test_copy_range(const struct nfnl_log *);
|
||||
extern uint32_t nfnl_log_get_copy_range(const struct nfnl_log *);
|
||||
|
||||
extern void nfnl_log_set_flush_timeout(struct nfnl_log *, uint32_t);
|
||||
extern int nfnl_log_test_flush_timeout(const struct nfnl_log *);
|
||||
extern uint32_t nfnl_log_get_flush_timeout(const struct nfnl_log *);
|
||||
|
||||
extern void nfnl_log_set_alloc_size(struct nfnl_log *, uint32_t);
|
||||
extern int nfnl_log_test_alloc_size(const struct nfnl_log *);
|
||||
extern uint32_t nfnl_log_get_alloc_size(const struct nfnl_log *);
|
||||
|
||||
extern void nfnl_log_set_queue_threshold(struct nfnl_log *, uint32_t);
|
||||
extern int nfnl_log_test_queue_threshold(const struct nfnl_log *);
|
||||
extern uint32_t nfnl_log_get_queue_threshold(const struct nfnl_log *);
|
||||
|
||||
extern void nfnl_log_set_flags(struct nfnl_log *, unsigned int);
|
||||
extern void nfnl_log_unset_flags(struct nfnl_log *, unsigned int);
|
||||
extern unsigned int nfnl_log_get_flags(const struct nfnl_log *);
|
||||
|
||||
extern char * nfnl_log_flags2str(unsigned int, char *, size_t);
|
||||
extern unsigned int nfnl_log_str2flags(const char *);
|
||||
|
||||
extern int nfnl_log_build_pf_bind(uint8_t, struct nl_msg **);
|
||||
extern int nfnl_log_pf_bind(struct nl_sock *, uint8_t);
|
||||
|
||||
extern int nfnl_log_build_pf_unbind(uint8_t, struct nl_msg **);
|
||||
extern int nfnl_log_pf_unbind(struct nl_sock *, uint8_t);
|
||||
|
||||
extern int nfnl_log_build_create_request(const struct nfnl_log *,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_log_create(struct nl_sock *, const struct nfnl_log *);
|
||||
|
||||
extern int nfnl_log_build_change_request(const struct nfnl_log *,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_log_change(struct nl_sock *, const struct nfnl_log *);
|
||||
|
||||
extern int nfnl_log_build_delete_request(const struct nfnl_log *,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_log_delete(struct nl_sock *, const struct nfnl_log *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* netlink/netfilter/log_msg.h Netfilter Log Message
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2007 Philip Craig <philipc@snapgear.com>
|
||||
* Copyright (c) 2007 Secure Computing Corporation
|
||||
* Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_LOG_MSG_H_
|
||||
#define NETLINK_LOG_MSG_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nlmsghdr;
|
||||
struct nfnl_log_msg;
|
||||
|
||||
extern struct nl_object_ops log_msg_obj_ops;
|
||||
|
||||
/* General */
|
||||
extern struct nfnl_log_msg *nfnl_log_msg_alloc(void);
|
||||
extern int nfnlmsg_log_msg_parse(struct nlmsghdr *,
|
||||
struct nfnl_log_msg **);
|
||||
|
||||
extern void nfnl_log_msg_get(struct nfnl_log_msg *);
|
||||
extern void nfnl_log_msg_put(struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_family(struct nfnl_log_msg *, uint8_t);
|
||||
extern uint8_t nfnl_log_msg_get_family(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_hwproto(struct nfnl_log_msg *, uint16_t);
|
||||
extern int nfnl_log_msg_test_hwproto(const struct nfnl_log_msg *);
|
||||
extern uint16_t nfnl_log_msg_get_hwproto(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_hook(struct nfnl_log_msg *, uint8_t);
|
||||
extern int nfnl_log_msg_test_hook(const struct nfnl_log_msg *);
|
||||
extern uint8_t nfnl_log_msg_get_hook(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_mark(struct nfnl_log_msg *, uint32_t);
|
||||
extern int nfnl_log_msg_test_mark(const struct nfnl_log_msg *);
|
||||
extern uint32_t nfnl_log_msg_get_mark(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_timestamp(struct nfnl_log_msg *,
|
||||
struct timeval *);
|
||||
extern const struct timeval *nfnl_log_msg_get_timestamp(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_indev(struct nfnl_log_msg *, uint32_t);
|
||||
extern uint32_t nfnl_log_msg_get_indev(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_outdev(struct nfnl_log_msg *, uint32_t);
|
||||
extern uint32_t nfnl_log_msg_get_outdev(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_physindev(struct nfnl_log_msg *, uint32_t);
|
||||
extern uint32_t nfnl_log_msg_get_physindev(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_physoutdev(struct nfnl_log_msg *, uint32_t);
|
||||
extern uint32_t nfnl_log_msg_get_physoutdev(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_hwaddr(struct nfnl_log_msg *, uint8_t *, int);
|
||||
extern const uint8_t * nfnl_log_msg_get_hwaddr(const struct nfnl_log_msg *, int *);
|
||||
|
||||
extern int nfnl_log_msg_set_payload(struct nfnl_log_msg *, uint8_t *, int);
|
||||
extern const void * nfnl_log_msg_get_payload(const struct nfnl_log_msg *, int *);
|
||||
|
||||
extern int nfnl_log_msg_set_prefix(struct nfnl_log_msg *, void *);
|
||||
extern const char * nfnl_log_msg_get_prefix(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_uid(struct nfnl_log_msg *, uint32_t);
|
||||
extern int nfnl_log_msg_test_uid(const struct nfnl_log_msg *);
|
||||
extern uint32_t nfnl_log_msg_get_uid(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_gid(struct nfnl_log_msg *, uint32_t);
|
||||
extern int nfnl_log_msg_test_gid(const struct nfnl_log_msg *);
|
||||
extern uint32_t nfnl_log_msg_get_gid(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_seq(struct nfnl_log_msg *, uint32_t);
|
||||
extern int nfnl_log_msg_test_seq(const struct nfnl_log_msg *);
|
||||
extern uint32_t nfnl_log_msg_get_seq(const struct nfnl_log_msg *);
|
||||
|
||||
extern void nfnl_log_msg_set_seq_global(struct nfnl_log_msg *, uint32_t);
|
||||
extern int nfnl_log_msg_test_seq_global(const struct nfnl_log_msg *);
|
||||
extern uint32_t nfnl_log_msg_get_seq_global(const struct nfnl_log_msg *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* netlink/netfilter/netfilter.h Netfilter generic functions
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_NETFILTER_H_
|
||||
#define NETLINK_NETFILTER_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern char * nfnl_verdict2str(unsigned int, char *, size_t);
|
||||
extern unsigned int nfnl_str2verdict(const char *);
|
||||
|
||||
extern char * nfnl_inet_hook2str(unsigned int, char *, size_t);
|
||||
extern unsigned int nfnl_str2inet_hook(const char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* netlink/nfnl/nfnl.h Netfilter Netlink
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2007 Philip Craig <philipc@snapgear.com>
|
||||
* Copyright (c) 2007 Secure Computing Corporation
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_NFNL_H_
|
||||
#define NETLINK_NFNL_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NFNL_HDRLEN NLMSG_ALIGN(sizeof(struct nfgenmsg))
|
||||
#define NFNLMSG_TYPE(subsys, subtype) (((subsys) << 8) | (subtype))
|
||||
|
||||
extern int nfnl_connect(struct nl_sock *);
|
||||
|
||||
extern uint8_t nfnlmsg_subsys(struct nlmsghdr *);
|
||||
extern uint8_t nfnlmsg_subtype(struct nlmsghdr *);
|
||||
extern uint8_t nfnlmsg_family(struct nlmsghdr *);
|
||||
extern uint16_t nfnlmsg_res_id(struct nlmsghdr *);
|
||||
|
||||
extern int nfnl_send_simple(struct nl_sock *, uint8_t, uint8_t,
|
||||
int, uint8_t, uint16_t);
|
||||
extern struct nl_msg * nfnlmsg_alloc_simple(uint8_t, uint8_t, int,
|
||||
uint8_t, uint16_t);
|
||||
extern int nfnlmsg_put(struct nl_msg *, uint32_t, uint32_t,
|
||||
uint8_t, uint8_t, int, uint8_t, uint16_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* netlink/netfilter/queue.h Netfilter Queue
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2007, 2008 Patrick McHardy <kaber@trash.net>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_QUEUE_H_
|
||||
#define NETLINK_QUEUE_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nl_sock;
|
||||
struct nlmsghdr;
|
||||
struct nfnl_queue;
|
||||
|
||||
extern struct nl_object_ops queue_obj_ops;
|
||||
|
||||
enum nfnl_queue_copy_mode {
|
||||
NFNL_QUEUE_COPY_NONE,
|
||||
NFNL_QUEUE_COPY_META,
|
||||
NFNL_QUEUE_COPY_PACKET,
|
||||
};
|
||||
|
||||
/* General */
|
||||
extern struct nl_sock * nfnl_queue_socket_alloc(void);
|
||||
|
||||
extern struct nfnl_queue * nfnl_queue_alloc(void);
|
||||
|
||||
extern void nfnl_queue_get(struct nfnl_queue *);
|
||||
extern void nfnl_queue_put(struct nfnl_queue *);
|
||||
|
||||
/* Attributes */
|
||||
extern void nfnl_queue_set_group(struct nfnl_queue *, uint16_t);
|
||||
extern int nfnl_queue_test_group(const struct nfnl_queue *);
|
||||
extern uint16_t nfnl_queue_get_group(const struct nfnl_queue *);
|
||||
|
||||
extern void nfnl_queue_set_maxlen(struct nfnl_queue *, uint32_t);
|
||||
extern int nfnl_queue_test_maxlen(const struct nfnl_queue *);
|
||||
extern uint32_t nfnl_queue_get_maxlen(const struct nfnl_queue *);
|
||||
|
||||
extern void nfnl_queue_set_copy_mode(struct nfnl_queue *,
|
||||
enum nfnl_queue_copy_mode);
|
||||
extern int nfnl_queue_test_copy_mode(const struct nfnl_queue *);
|
||||
extern enum nfnl_queue_copy_mode nfnl_queue_get_copy_mode(const struct nfnl_queue *);
|
||||
|
||||
extern char * nfnl_queue_copy_mode2str(enum nfnl_queue_copy_mode,
|
||||
char *, size_t);
|
||||
extern enum nfnl_queue_copy_mode nfnl_queue_str2copy_mode(const char *);
|
||||
|
||||
extern void nfnl_queue_set_copy_range(struct nfnl_queue *,
|
||||
uint32_t);
|
||||
extern int nfnl_queue_test_copy_range(const struct nfnl_queue *);
|
||||
extern uint32_t nfnl_queue_get_copy_range(const struct nfnl_queue *);
|
||||
|
||||
extern int nfnl_queue_build_pf_bind(uint8_t, struct nl_msg **);
|
||||
extern int nfnl_queue_pf_bind(struct nl_sock *, uint8_t);
|
||||
|
||||
extern int nfnl_queue_build_pf_unbind(uint8_t, struct nl_msg **);
|
||||
extern int nfnl_queue_pf_unbind(struct nl_sock *, uint8_t);
|
||||
|
||||
extern int nfnl_queue_build_create_request(const struct nfnl_queue *,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_queue_create(struct nl_sock *,
|
||||
const struct nfnl_queue *);
|
||||
|
||||
extern int nfnl_queue_build_change_request(const struct nfnl_queue *,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_queue_change(struct nl_sock *,
|
||||
const struct nfnl_queue *);
|
||||
|
||||
extern int nfnl_queue_build_delete_request(const struct nfnl_queue *,
|
||||
struct nl_msg **);
|
||||
extern int nfnl_queue_delete(struct nl_sock *,
|
||||
const struct nfnl_queue *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* netlink/netfilter/queue_msg.h Netfilter Queue Messages
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2007, 2008 Patrick McHardy <kaber@trash.net>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_QUEUE_MSG_H_
|
||||
#define NETLINK_QUEUE_MSG_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nl_sock;
|
||||
struct nlmsghdr;
|
||||
struct nfnl_queue_msg;
|
||||
|
||||
extern struct nl_object_ops queue_msg_obj_ops;
|
||||
|
||||
/* General */
|
||||
extern struct nfnl_queue_msg * nfnl_queue_msg_alloc(void);
|
||||
extern int nfnlmsg_queue_msg_parse(struct nlmsghdr *,
|
||||
struct nfnl_queue_msg **);
|
||||
|
||||
extern void nfnl_queue_msg_get(struct nfnl_queue_msg *);
|
||||
extern void nfnl_queue_msg_put(struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_group(struct nfnl_queue_msg *, uint16_t);
|
||||
extern int nfnl_queue_msg_test_group(const struct nfnl_queue_msg *);
|
||||
extern uint16_t nfnl_queue_msg_get_group(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_family(struct nfnl_queue_msg *, uint8_t);
|
||||
extern int nfnl_queue_msg_test_family(const struct nfnl_queue_msg *);
|
||||
extern uint8_t nfnl_queue_msg_get_family(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_packetid(struct nfnl_queue_msg *, uint32_t);
|
||||
extern int nfnl_queue_msg_test_packetid(const struct nfnl_queue_msg *);
|
||||
extern uint32_t nfnl_queue_msg_get_packetid(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_hwproto(struct nfnl_queue_msg *, uint16_t);
|
||||
extern int nfnl_queue_msg_test_hwproto(const struct nfnl_queue_msg *);
|
||||
extern uint16_t nfnl_queue_msg_get_hwproto(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_hook(struct nfnl_queue_msg *, uint8_t);
|
||||
extern int nfnl_queue_msg_test_hook(const struct nfnl_queue_msg *);
|
||||
extern uint8_t nfnl_queue_msg_get_hook(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_mark(struct nfnl_queue_msg *, uint32_t);
|
||||
extern int nfnl_queue_msg_test_mark(const struct nfnl_queue_msg *);
|
||||
extern uint32_t nfnl_queue_msg_get_mark(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_timestamp(struct nfnl_queue_msg *,
|
||||
struct timeval *);
|
||||
extern int nfnl_queue_msg_test_timestamp(const struct nfnl_queue_msg *);
|
||||
extern const struct timeval * nfnl_queue_msg_get_timestamp(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_indev(struct nfnl_queue_msg *, uint32_t);
|
||||
extern int nfnl_queue_msg_test_indev(const struct nfnl_queue_msg *);
|
||||
extern uint32_t nfnl_queue_msg_get_indev(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_outdev(struct nfnl_queue_msg *, uint32_t);
|
||||
extern int nfnl_queue_msg_test_outdev(const struct nfnl_queue_msg *);
|
||||
extern uint32_t nfnl_queue_msg_get_outdev(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_physindev(struct nfnl_queue_msg *, uint32_t);
|
||||
extern int nfnl_queue_msg_test_physindev(const struct nfnl_queue_msg *);
|
||||
extern uint32_t nfnl_queue_msg_get_physindev(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_physoutdev(struct nfnl_queue_msg *, uint32_t);
|
||||
extern int nfnl_queue_msg_test_physoutdev(const struct nfnl_queue_msg *);
|
||||
extern uint32_t nfnl_queue_msg_get_physoutdev(const struct nfnl_queue_msg *);
|
||||
|
||||
extern void nfnl_queue_msg_set_hwaddr(struct nfnl_queue_msg *, uint8_t *, int);
|
||||
extern int nfnl_queue_msg_test_hwaddr(const struct nfnl_queue_msg *);
|
||||
extern const uint8_t * nfnl_queue_msg_get_hwaddr(const struct nfnl_queue_msg *, int *);
|
||||
|
||||
extern int nfnl_queue_msg_set_payload(struct nfnl_queue_msg *, uint8_t *, int);
|
||||
extern int nfnl_queue_msg_test_payload(const struct nfnl_queue_msg *);
|
||||
extern const void * nfnl_queue_msg_get_payload(const struct nfnl_queue_msg *, int *);
|
||||
|
||||
extern void nfnl_queue_msg_set_verdict(struct nfnl_queue_msg *,
|
||||
unsigned int);
|
||||
extern int nfnl_queue_msg_test_verdict(const struct nfnl_queue_msg *);
|
||||
extern unsigned int nfnl_queue_msg_get_verdict(const struct nfnl_queue_msg *);
|
||||
|
||||
extern struct nl_msg * nfnl_queue_msg_build_verdict(const struct nfnl_queue_msg *);
|
||||
extern int nfnl_queue_msg_send_verdict(struct nl_sock *,
|
||||
const struct nfnl_queue_msg *);
|
||||
extern int nfnl_queue_msg_send_verdict_batch(struct nl_sock *,
|
||||
const struct nfnl_queue_msg *);
|
||||
extern int nfnl_queue_msg_send_verdict_payload(struct nl_sock *,
|
||||
const struct nfnl_queue_msg *,
|
||||
const void *, unsigned );
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* netlink/netlink-compat.h Netlink Compatability
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_COMPAT_H_
|
||||
#define NETLINK_COMPAT_H_
|
||||
|
||||
#if !defined _LINUX_SOCKET_H && !defined _BITS_SOCKADDR_H
|
||||
typedef unsigned short sa_family_t;
|
||||
#endif
|
||||
|
||||
#ifndef IFNAMSIZ
|
||||
/** Maximum length of a interface name */
|
||||
#define IFNAMSIZ 16
|
||||
#endif
|
||||
|
||||
/* patch 2.4.x if_arp */
|
||||
#ifndef ARPHRD_INFINIBAND
|
||||
#define ARPHRD_INFINIBAND 32
|
||||
#endif
|
||||
|
||||
/* patch 2.4.x eth header file */
|
||||
#ifndef ETH_P_MPLS_UC
|
||||
#define ETH_P_MPLS_UC 0x8847
|
||||
#endif
|
||||
|
||||
#ifndef ETH_P_MPLS_MC
|
||||
#define ETH_P_MPLS_MC 0x8848
|
||||
#endif
|
||||
|
||||
#ifndef ETH_P_EDP2
|
||||
#define ETH_P_EDP2 0x88A2
|
||||
#endif
|
||||
|
||||
#ifndef ETH_P_HDLC
|
||||
#define ETH_P_HDLC 0x0019
|
||||
#endif
|
||||
|
||||
#ifndef AF_LLC
|
||||
#define AF_LLC 26
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,293 @@
|
||||
#ifndef __NETLINK_KERNEL_H_
|
||||
#define __NETLINK_KERNEL_H_
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
* FIXME: Goal is to preseve the documentation but make it simple
|
||||
* to keep linux/netlink.h in sync. Maybe use named documentation
|
||||
* sections.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Netlink socket address
|
||||
* @ingroup nl
|
||||
*/
|
||||
struct sockaddr_nl
|
||||
{
|
||||
/** socket family (AF_NETLINK) */
|
||||
sa_family_t nl_family;
|
||||
|
||||
/** Padding (unused) */
|
||||
unsigned short nl_pad;
|
||||
|
||||
/** Unique process ID */
|
||||
uint32_t nl_pid;
|
||||
|
||||
/** Multicast group subscriptions */
|
||||
uint32_t nl_groups;
|
||||
};
|
||||
|
||||
/**
|
||||
* @addtogroup msg
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Netlink message header
|
||||
*/
|
||||
struct nlmsghdr
|
||||
{
|
||||
/** Length of message including header and padding. */
|
||||
uint32_t nlmsg_len;
|
||||
|
||||
/** Message type (content type) */
|
||||
uint16_t nlmsg_type;
|
||||
|
||||
/** Message flags */
|
||||
uint16_t nlmsg_flags;
|
||||
|
||||
/** Sequence number of message \see core_sk_seq_num. */
|
||||
uint32_t nlmsg_seq;
|
||||
|
||||
/** Netlink port */
|
||||
uint32_t nlmsg_pid;
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Standard message flags
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Must be set on all request messages (typically from user space to
|
||||
* kernel space).
|
||||
*/
|
||||
#define NLM_F_REQUEST 1
|
||||
|
||||
/**
|
||||
* Indicates the message is part of a multipart message terminated
|
||||
* by NLMSG_DONE.
|
||||
*/
|
||||
#define NLM_F_MULTI 2
|
||||
|
||||
/**
|
||||
* Request for an acknowledgment on success.
|
||||
*/
|
||||
#define NLM_F_ACK 4
|
||||
|
||||
/**
|
||||
* Echo this request
|
||||
*/
|
||||
#define NLM_F_ECHO 8
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Additional message flags for GET requests
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return the complete table instead of a single entry.
|
||||
*/
|
||||
#define NLM_F_ROOT 0x100
|
||||
|
||||
/**
|
||||
* Return all entries matching criteria passed in message content.
|
||||
*/
|
||||
#define NLM_F_MATCH 0x200
|
||||
|
||||
/**
|
||||
* Return an atomic snapshot of the table being referenced. This
|
||||
* may require special privileges because it has the potential to
|
||||
* interrupt service in the FE for a longer time.
|
||||
*/
|
||||
#define NLM_F_ATOMIC 0x400
|
||||
|
||||
/**
|
||||
* Dump all entries
|
||||
*/
|
||||
#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Additional messsage flags for NEW requests
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Replace existing matching config object with this request.
|
||||
*/
|
||||
#define NLM_F_REPLACE 0x100
|
||||
|
||||
/**
|
||||
* Don't replace the config object if it already exists.
|
||||
*/
|
||||
#define NLM_F_EXCL 0x200
|
||||
|
||||
/**
|
||||
* Create config object if it doesn't already exist.
|
||||
*/
|
||||
#define NLM_F_CREATE 0x400
|
||||
|
||||
/**
|
||||
* Add to the end of the object list.
|
||||
*/
|
||||
#define NLM_F_APPEND 0x800
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Standard Message types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* No operation, message must be ignored
|
||||
*/
|
||||
#define NLMSG_NOOP 0x1
|
||||
|
||||
/**
|
||||
* The message signals an error and the payload contains a nlmsgerr
|
||||
* structure. This can be looked at as a NACK and typically it is
|
||||
* from FEC to CPC.
|
||||
*/
|
||||
#define NLMSG_ERROR 0x2
|
||||
|
||||
/**
|
||||
* Message terminates a multipart message.
|
||||
*/
|
||||
#define NLMSG_DONE 0x3
|
||||
|
||||
/**
|
||||
* The message signals that data got lost
|
||||
*/
|
||||
#define NLMSG_OVERRUN 0x4
|
||||
|
||||
/**
|
||||
* Lower limit of reserved message types
|
||||
*/
|
||||
#define NLMSG_MIN_TYPE 0x10
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Netlink error message header
|
||||
*/
|
||||
struct nlmsgerr
|
||||
{
|
||||
/** Error code (errno number) */
|
||||
int error;
|
||||
|
||||
/** Original netlink message causing the error */
|
||||
struct nlmsghdr msg;
|
||||
};
|
||||
|
||||
struct nl_pktinfo
|
||||
{
|
||||
__u32 group;
|
||||
};
|
||||
|
||||
/**
|
||||
* Netlink alignment constant, all boundries within messages must be align to this.
|
||||
*
|
||||
* See \ref core_msg_fmt_align for more information on message alignment.
|
||||
*/
|
||||
#define NLMSG_ALIGNTO 4
|
||||
|
||||
/**
|
||||
* Returns \p len properly aligned to NLMSG_ALIGNTO.
|
||||
*
|
||||
* See \ref core_msg_fmt_align for more information on message alignment.
|
||||
*/
|
||||
#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
|
||||
|
||||
/**
|
||||
* Length of a netlink message header including padding.
|
||||
*
|
||||
* See \ref core_msg_fmt_align for more information on message alignment.
|
||||
*/
|
||||
#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @addtogroup attr
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Netlink attribute structure
|
||||
*
|
||||
* @code
|
||||
* <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)-->
|
||||
* +---------------------+- - -+- - - - - - - - - -+- - -+
|
||||
* | Header | Pad | Payload | Pad |
|
||||
* | (struct nlattr) | ing | | ing |
|
||||
* +---------------------+- - -+- - - - - - - - - -+- - -+
|
||||
* <-------------- nlattr->nla_len -------------->
|
||||
* @endcode
|
||||
*/
|
||||
struct nlattr {
|
||||
/**
|
||||
* Attribute length in bytes including header
|
||||
*/
|
||||
__u16 nla_len;
|
||||
|
||||
/**
|
||||
* Netlink attribute type
|
||||
*/
|
||||
__u16 nla_type;
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Attribute Type Flags
|
||||
*
|
||||
* @code
|
||||
* nla_type (16 bits)
|
||||
* +---+---+-------------------------------+
|
||||
* | N | O | Attribute Type |
|
||||
* +---+---+-------------------------------+
|
||||
* N := Carries nested attributes
|
||||
* O := Payload stored in network byte order
|
||||
* @endcode
|
||||
*
|
||||
* @note The N and O flag are mutually exclusive.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
#define NLA_F_NESTED (1 << 15)
|
||||
#define NLA_F_NET_BYTEORDER (1 << 14)
|
||||
#define NLA_TYPE_MASK ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER)
|
||||
|
||||
/** @} */
|
||||
|
||||
#define NLA_ALIGNTO 4
|
||||
|
||||
/**
|
||||
* Returns \p len properly aligned to NLA_ALIGNTO.
|
||||
*
|
||||
* See \ref core_msg_fmt_align for more information on message alignment.
|
||||
*/
|
||||
#define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))
|
||||
|
||||
/**
|
||||
* Length of a netlink attribute header including padding.
|
||||
*
|
||||
* See \ref core_msg_fmt_align for more information on message alignment.
|
||||
*/
|
||||
#define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif
|
||||
#endif /* __LINUX_NETLINK_H */
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* netlink/netlink.h Netlink Interface
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_NETLINK_H_
|
||||
#define NETLINK_NETLINK_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <netdb.h>
|
||||
#include <netlink/netlink-compat.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/genetlink.h>
|
||||
#include <linux/netfilter/nfnetlink.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netlink/version.h>
|
||||
#include <netlink/errno.h>
|
||||
#include <netlink/types.h>
|
||||
#include <netlink/handlers.h>
|
||||
#include <netlink/socket.h>
|
||||
#include <netlink/object.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ucred;
|
||||
struct nl_cache_ops;
|
||||
struct nl_parser_param;
|
||||
struct nl_object;
|
||||
struct nl_sock;
|
||||
|
||||
extern int nl_debug;
|
||||
extern struct nl_dump_params nl_debug_dp;
|
||||
|
||||
/* Connection Management */
|
||||
extern int nl_connect(struct nl_sock *, int);
|
||||
extern void nl_close(struct nl_sock *);
|
||||
|
||||
/* Send */
|
||||
extern int nl_sendto(struct nl_sock *, void *, size_t);
|
||||
extern int nl_sendmsg(struct nl_sock *, struct nl_msg *,
|
||||
struct msghdr *);
|
||||
extern int nl_send(struct nl_sock *, struct nl_msg *);
|
||||
extern int nl_send_iovec(struct nl_sock *, struct nl_msg *,
|
||||
struct iovec *, unsigned);
|
||||
extern void nl_complete_msg(struct nl_sock *,
|
||||
struct nl_msg *);
|
||||
extern void nl_auto_complete(struct nl_sock *,
|
||||
struct nl_msg *);
|
||||
extern int nl_send_auto(struct nl_sock *, struct nl_msg *);
|
||||
extern int nl_send_auto_complete(struct nl_sock *,
|
||||
struct nl_msg *);
|
||||
extern int nl_send_sync(struct nl_sock *, struct nl_msg *);
|
||||
extern int nl_send_simple(struct nl_sock *, int, int,
|
||||
void *, size_t);
|
||||
|
||||
/* Receive */
|
||||
extern int nl_recv(struct nl_sock *,
|
||||
struct sockaddr_nl *, unsigned char **,
|
||||
struct ucred **);
|
||||
|
||||
extern int nl_recvmsgs(struct nl_sock *, struct nl_cb *);
|
||||
extern int nl_recvmsgs_report(struct nl_sock *, struct nl_cb *);
|
||||
|
||||
extern int nl_recvmsgs_default(struct nl_sock *);
|
||||
|
||||
extern int nl_wait_for_ack(struct nl_sock *);
|
||||
|
||||
extern int nl_pickup(struct nl_sock *,
|
||||
int (*parser)(struct nl_cache_ops *,
|
||||
struct sockaddr_nl *,
|
||||
struct nlmsghdr *,
|
||||
struct nl_parser_param *),
|
||||
struct nl_object **);
|
||||
/* Netlink Family Translations */
|
||||
extern char * nl_nlfamily2str(int, char *, size_t);
|
||||
extern int nl_str2nlfamily(const char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* netlink/object-api.h Object API
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_DUMMY_OBJECT_API_H_
|
||||
#define NETLINK_DUMMY_OBJECT_API_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/utils.h>
|
||||
#include <netlink/object.h>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* netlink/object.c Generic Cacheable Object
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_OBJECT_H_
|
||||
#define NETLINK_OBJECT_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/utils.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct nl_cache;
|
||||
struct nl_object;
|
||||
struct nl_object_ops;
|
||||
|
||||
#define OBJ_CAST(ptr) ((struct nl_object *) (ptr))
|
||||
|
||||
/* General */
|
||||
extern struct nl_object * nl_object_alloc(struct nl_object_ops *);
|
||||
extern int nl_object_alloc_name(const char *,
|
||||
struct nl_object **);
|
||||
extern void nl_object_free(struct nl_object *);
|
||||
extern struct nl_object * nl_object_clone(struct nl_object *obj);
|
||||
extern int nl_object_update(struct nl_object *dst,
|
||||
struct nl_object *src);
|
||||
extern void nl_object_get(struct nl_object *);
|
||||
extern void nl_object_put(struct nl_object *);
|
||||
extern int nl_object_shared(struct nl_object *);
|
||||
extern void nl_object_dump(struct nl_object *,
|
||||
struct nl_dump_params *);
|
||||
extern void nl_object_dump_buf(struct nl_object *, char *, size_t);
|
||||
extern int nl_object_identical(struct nl_object *,
|
||||
struct nl_object *);
|
||||
extern uint32_t nl_object_diff(struct nl_object *,
|
||||
struct nl_object *);
|
||||
extern int nl_object_match_filter(struct nl_object *,
|
||||
struct nl_object *);
|
||||
extern char * nl_object_attrs2str(struct nl_object *,
|
||||
uint32_t attrs, char *buf,
|
||||
size_t);
|
||||
extern char * nl_object_attr_list(struct nl_object *,
|
||||
char *, size_t);
|
||||
extern void nl_object_keygen(struct nl_object *,
|
||||
uint32_t *, uint32_t);
|
||||
|
||||
/* Marks */
|
||||
extern void nl_object_mark(struct nl_object *);
|
||||
extern void nl_object_unmark(struct nl_object *);
|
||||
extern int nl_object_is_marked(struct nl_object *);
|
||||
|
||||
/* Access Functions */
|
||||
extern int nl_object_get_refcnt(struct nl_object *);
|
||||
extern struct nl_cache * nl_object_get_cache(struct nl_object *);
|
||||
extern const char * nl_object_get_type(const struct nl_object *);
|
||||
extern int nl_object_get_msgtype(const struct nl_object *);
|
||||
struct nl_object_ops * nl_object_get_ops(const struct nl_object *);
|
||||
uint32_t nl_object_get_id_attrs(struct nl_object *obj);
|
||||
|
||||
|
||||
static inline void * nl_object_priv(struct nl_object *obj)
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* netlink/route/cls/mirred.h mirred action
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Cong Wang <xiyou.wangcong@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_MIRRED_H_
|
||||
#define NETLINK_MIRRED_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/route/action.h>
|
||||
#include <linux/tc_act/tc_mirred.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int rtnl_mirred_set_action(struct rtnl_act *, int);
|
||||
extern int rtnl_mirred_get_action(struct rtnl_act *);
|
||||
extern int rtnl_mirred_set_ifindex(struct rtnl_act *, uint32_t);
|
||||
extern uint32_t rtnl_mirred_get_ifindex(struct rtnl_act *);
|
||||
extern int rtnl_mirred_set_policy(struct rtnl_act *, int);
|
||||
extern int rtnl_mirred_get_policy(struct rtnl_act *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* netlink/route/action.h Actions
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Cong Wang <xiyou.wangcong@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_ACTION_H_
|
||||
#define NETLINK_ACTION_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/route/tc.h>
|
||||
#include <netlink/utils.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct rtnl_act *rtnl_act_alloc(void);
|
||||
extern void rtnl_act_get(struct rtnl_act *);
|
||||
extern void rtnl_act_put(struct rtnl_act *);
|
||||
extern int rtnl_act_build_add_request(struct rtnl_act *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_act_add(struct nl_sock *, struct rtnl_act *, int);
|
||||
|
||||
extern int rtnl_act_build_change_request(struct rtnl_act *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_act_build_delete_request(struct rtnl_act *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_act_delete(struct nl_sock *, struct rtnl_act *,
|
||||
int);
|
||||
extern int rtnl_act_append(struct rtnl_act **, struct rtnl_act *);
|
||||
extern int rtnl_act_remove(struct rtnl_act **, struct rtnl_act *);
|
||||
extern int rtnl_act_fill(struct nl_msg *, int, struct rtnl_act *);
|
||||
extern void rtnl_act_put_all(struct rtnl_act **);
|
||||
extern int rtnl_act_parse(struct rtnl_act **, struct nlattr *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* netlink/route/addr.c rtnetlink addr layer
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2003-2006 Baruch Even <baruch@ev-en.org>,
|
||||
* Mediatrix Telecom, inc. <ericb@mediatrix.com>
|
||||
*/
|
||||
|
||||
#ifndef NETADDR_ADDR_H_
|
||||
#define NETADDR_ADDR_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/addr.h>
|
||||
#include <netlink/route/link.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct rtnl_addr;
|
||||
|
||||
/* General */
|
||||
extern struct rtnl_addr *rtnl_addr_alloc(void);
|
||||
extern void rtnl_addr_put(struct rtnl_addr *);
|
||||
|
||||
extern int rtnl_addr_alloc_cache(struct nl_sock *, struct nl_cache **);
|
||||
extern struct rtnl_addr *
|
||||
rtnl_addr_get(struct nl_cache *, int, struct nl_addr *);
|
||||
|
||||
extern int rtnl_addr_build_add_request(struct rtnl_addr *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_addr_add(struct nl_sock *, struct rtnl_addr *, int);
|
||||
|
||||
extern int rtnl_addr_build_delete_request(struct rtnl_addr *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_addr_delete(struct nl_sock *,
|
||||
struct rtnl_addr *, int);
|
||||
|
||||
extern char * rtnl_addr_flags2str(int, char *, size_t);
|
||||
extern int rtnl_addr_str2flags(const char *);
|
||||
|
||||
extern int rtnl_addr_set_label(struct rtnl_addr *, const char *);
|
||||
extern char * rtnl_addr_get_label(struct rtnl_addr *);
|
||||
|
||||
extern void rtnl_addr_set_ifindex(struct rtnl_addr *, int);
|
||||
extern int rtnl_addr_get_ifindex(struct rtnl_addr *);
|
||||
|
||||
extern void rtnl_addr_set_link(struct rtnl_addr *, struct rtnl_link *);
|
||||
extern struct rtnl_link *
|
||||
rtnl_addr_get_link(struct rtnl_addr *);
|
||||
|
||||
extern void rtnl_addr_set_family(struct rtnl_addr *, int);
|
||||
extern int rtnl_addr_get_family(struct rtnl_addr *);
|
||||
|
||||
extern void rtnl_addr_set_prefixlen(struct rtnl_addr *, int);
|
||||
extern int rtnl_addr_get_prefixlen(struct rtnl_addr *);
|
||||
|
||||
extern void rtnl_addr_set_scope(struct rtnl_addr *, int);
|
||||
extern int rtnl_addr_get_scope(struct rtnl_addr *);
|
||||
|
||||
extern void rtnl_addr_set_flags(struct rtnl_addr *, unsigned int);
|
||||
extern void rtnl_addr_unset_flags(struct rtnl_addr *, unsigned int);
|
||||
extern unsigned int rtnl_addr_get_flags(struct rtnl_addr *);
|
||||
|
||||
extern int rtnl_addr_set_local(struct rtnl_addr *,
|
||||
struct nl_addr *);
|
||||
extern struct nl_addr *rtnl_addr_get_local(struct rtnl_addr *);
|
||||
|
||||
extern int rtnl_addr_set_peer(struct rtnl_addr *, struct nl_addr *);
|
||||
extern struct nl_addr *rtnl_addr_get_peer(struct rtnl_addr *);
|
||||
|
||||
extern int rtnl_addr_set_broadcast(struct rtnl_addr *, struct nl_addr *);
|
||||
extern struct nl_addr *rtnl_addr_get_broadcast(struct rtnl_addr *);
|
||||
|
||||
extern int rtnl_addr_set_multicast(struct rtnl_addr *, struct nl_addr *);
|
||||
extern struct nl_addr *rtnl_addr_get_multicast(struct rtnl_addr *);
|
||||
|
||||
extern int rtnl_addr_set_anycast(struct rtnl_addr *, struct nl_addr *);
|
||||
extern struct nl_addr *rtnl_addr_get_anycast(struct rtnl_addr *);
|
||||
|
||||
extern uint32_t rtnl_addr_get_valid_lifetime(struct rtnl_addr *);
|
||||
extern void rtnl_addr_set_valid_lifetime(struct rtnl_addr *, uint32_t);
|
||||
extern uint32_t rtnl_addr_get_preferred_lifetime(struct rtnl_addr *);
|
||||
extern void rtnl_addr_set_preferred_lifetime(struct rtnl_addr *, uint32_t);
|
||||
extern uint32_t rtnl_addr_get_create_time(struct rtnl_addr *);
|
||||
extern uint32_t rtnl_addr_get_last_update_time(struct rtnl_addr *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* netlink/route/class.h Traffic Classes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CLASS_H_
|
||||
#define NETLINK_CLASS_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/tc.h>
|
||||
#include <netlink/route/qdisc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct rtnl_class;
|
||||
|
||||
extern struct rtnl_class *
|
||||
rtnl_class_alloc(void);
|
||||
extern void rtnl_class_put(struct rtnl_class *);
|
||||
|
||||
extern int rtnl_class_alloc_cache(struct nl_sock *, int,
|
||||
struct nl_cache **);
|
||||
extern struct rtnl_class *
|
||||
rtnl_class_get(struct nl_cache *, int, uint32_t);
|
||||
|
||||
extern struct rtnl_qdisc *
|
||||
rtnl_class_leaf_qdisc(struct rtnl_class *,
|
||||
struct nl_cache *);
|
||||
|
||||
extern int rtnl_class_build_add_request(struct rtnl_class *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_class_add(struct nl_sock *, struct rtnl_class *,
|
||||
int);
|
||||
|
||||
extern int rtnl_class_build_delete_request(struct rtnl_class *,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_class_delete(struct nl_sock *,
|
||||
struct rtnl_class *);
|
||||
|
||||
/* deprecated functions */
|
||||
extern void rtnl_class_foreach_child(struct rtnl_class *,
|
||||
struct nl_cache *,
|
||||
void (*cb)(struct nl_object *,
|
||||
void *),
|
||||
void *)
|
||||
__attribute__((deprecated));
|
||||
extern void rtnl_class_foreach_cls(struct rtnl_class *,
|
||||
struct nl_cache *,
|
||||
void (*cb)(struct nl_object *,
|
||||
void *),
|
||||
void *)
|
||||
__attribute__((deprecated));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* netlink/route/classifier.h Classifiers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CLASSIFIER_H_
|
||||
#define NETLINK_CLASSIFIER_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/route/tc.h>
|
||||
#include <netlink/utils.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct rtnl_cls *rtnl_cls_alloc(void);
|
||||
extern void rtnl_cls_put(struct rtnl_cls *);
|
||||
|
||||
extern int rtnl_cls_alloc_cache(struct nl_sock *, int, uint32_t,
|
||||
struct nl_cache **);
|
||||
|
||||
extern int rtnl_cls_build_add_request(struct rtnl_cls *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_cls_add(struct nl_sock *, struct rtnl_cls *, int);
|
||||
extern int rtnl_cls_change(struct nl_sock *, struct rtnl_cls *, int);
|
||||
|
||||
extern int rtnl_cls_build_change_request(struct rtnl_cls *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_cls_build_delete_request(struct rtnl_cls *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_cls_delete(struct nl_sock *, struct rtnl_cls *,
|
||||
int);
|
||||
|
||||
extern void rtnl_cls_set_prio(struct rtnl_cls *, uint16_t);
|
||||
extern uint16_t rtnl_cls_get_prio(struct rtnl_cls *);
|
||||
|
||||
extern void rtnl_cls_set_protocol(struct rtnl_cls *, uint16_t);
|
||||
extern uint16_t rtnl_cls_get_protocol(struct rtnl_cls *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* netlink/route/cls/basic.h Basic Classifier
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008-2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_BASIC_H_
|
||||
#define NETLINK_BASIC_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/classifier.h>
|
||||
#include <netlink/route/cls/ematch.h>
|
||||
#include <netlink/route/action.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void rtnl_basic_set_target(struct rtnl_cls *, uint32_t);
|
||||
extern uint32_t rtnl_basic_get_target(struct rtnl_cls *);
|
||||
extern void rtnl_basic_set_ematch(struct rtnl_cls *,
|
||||
struct rtnl_ematch_tree *);
|
||||
extern struct rtnl_ematch_tree *rtnl_basic_get_ematch(struct rtnl_cls *);
|
||||
extern int rtnl_basic_add_action(struct rtnl_cls *, struct rtnl_act *);
|
||||
extern int rtnl_basic_del_action(struct rtnl_cls *, struct rtnl_act *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* netlink/route/cls/cgroup.h Control Groups Classifier
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2009-2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CLS_CGROUP_H_
|
||||
#define NETLINK_CLS_CGROUP_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/route/classifier.h>
|
||||
#include <netlink/route/cls/ematch.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void rtnl_cgroup_set_ematch(struct rtnl_cls *,
|
||||
struct rtnl_ematch_tree *);
|
||||
struct rtnl_ematch_tree * rtnl_cgroup_get_ematch(struct rtnl_cls *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* netlink/route/cls/ematch.h Extended Matches
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008-2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CLS_EMATCH_H_
|
||||
#define NETLINK_CLS_EMATCH_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/msg.h>
|
||||
#include <netlink/route/classifier.h>
|
||||
#include <linux/pkt_cls.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* FIXME: Should be moved to the kernel header at some point */
|
||||
#define RTNL_EMATCH_PROGID 2
|
||||
|
||||
struct rtnl_ematch;
|
||||
struct rtnl_ematch_tree;
|
||||
|
||||
/**
|
||||
* Extended Match Operations
|
||||
*/
|
||||
struct rtnl_ematch_ops
|
||||
{
|
||||
int eo_kind;
|
||||
const char * eo_name;
|
||||
size_t eo_minlen;
|
||||
size_t eo_datalen;
|
||||
|
||||
int (*eo_parse)(struct rtnl_ematch *, void *, size_t);
|
||||
void (*eo_dump)(struct rtnl_ematch *,
|
||||
struct nl_dump_params *);
|
||||
int (*eo_fill)(struct rtnl_ematch *, struct nl_msg *);
|
||||
void (*eo_free)(struct rtnl_ematch *);
|
||||
struct nl_list_head eo_list;
|
||||
};
|
||||
|
||||
extern int rtnl_ematch_register(struct rtnl_ematch_ops *);
|
||||
extern struct rtnl_ematch_ops * rtnl_ematch_lookup_ops(int);
|
||||
extern struct rtnl_ematch_ops * rtnl_ematch_lookup_ops_by_name(const char *);
|
||||
|
||||
extern struct rtnl_ematch * rtnl_ematch_alloc(void);
|
||||
extern int rtnl_ematch_add_child(struct rtnl_ematch *,
|
||||
struct rtnl_ematch *);
|
||||
extern void rtnl_ematch_unlink(struct rtnl_ematch *);
|
||||
extern void rtnl_ematch_free(struct rtnl_ematch *);
|
||||
|
||||
extern void * rtnl_ematch_data(struct rtnl_ematch *);
|
||||
extern void rtnl_ematch_set_flags(struct rtnl_ematch *,
|
||||
uint16_t);
|
||||
extern void rtnl_ematch_unset_flags(struct rtnl_ematch *,
|
||||
uint16_t);
|
||||
extern uint16_t rtnl_ematch_get_flags(struct rtnl_ematch *);
|
||||
extern int rtnl_ematch_set_ops(struct rtnl_ematch *,
|
||||
struct rtnl_ematch_ops *);
|
||||
extern int rtnl_ematch_set_kind(struct rtnl_ematch *,
|
||||
uint16_t);
|
||||
extern int rtnl_ematch_set_name(struct rtnl_ematch *,
|
||||
const char *);
|
||||
|
||||
extern struct rtnl_ematch_tree *rtnl_ematch_tree_alloc(uint16_t);
|
||||
extern void rtnl_ematch_tree_free(struct rtnl_ematch_tree *);
|
||||
extern void rtnl_ematch_tree_add(struct rtnl_ematch_tree *,
|
||||
struct rtnl_ematch *);
|
||||
|
||||
extern int rtnl_ematch_parse_attr(struct nlattr *,
|
||||
struct rtnl_ematch_tree **);
|
||||
extern int rtnl_ematch_fill_attr(struct nl_msg *, int,
|
||||
struct rtnl_ematch_tree *);
|
||||
extern void rtnl_ematch_tree_dump(struct rtnl_ematch_tree *,
|
||||
struct nl_dump_params *);
|
||||
|
||||
|
||||
extern int rtnl_ematch_parse_expr(const char *, char **,
|
||||
struct rtnl_ematch_tree **);
|
||||
|
||||
extern char * rtnl_ematch_offset2txt(uint8_t, uint16_t,
|
||||
char *, size_t);
|
||||
extern char * rtnl_ematch_opnd2txt(uint8_t, char *, size_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* netlink/route/cls/ematch/cmp.h Simple Comparison
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2008-2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CLS_EMATCH_CMP_H_
|
||||
#define NETLINK_CLS_EMATCH_CMP_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/cls/ematch.h>
|
||||
#include <linux/tc_ematch/tc_em_cmp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void rtnl_ematch_cmp_set(struct rtnl_ematch *,
|
||||
struct tcf_em_cmp *);
|
||||
extern struct tcf_em_cmp *
|
||||
rtnl_ematch_cmp_get(struct rtnl_ematch *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* netlink/route/cls/ematch/meta.h Metadata Match
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CLS_EMATCH_META_H_
|
||||
#define NETLINK_CLS_EMATCH_META_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/cls/ematch.h>
|
||||
#include <linux/tc_ematch/tc_em_meta.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct rtnl_meta_value;
|
||||
|
||||
extern struct rtnl_meta_value * rtnl_meta_value_alloc_int(uint64_t);
|
||||
extern struct rtnl_meta_value * rtnl_meta_value_alloc_var(void *, size_t);
|
||||
extern struct rtnl_meta_value * rtnl_meta_value_alloc_id(uint8_t, uint16_t,
|
||||
uint8_t, uint64_t);
|
||||
extern void rtnl_meta_value_put(struct rtnl_meta_value *);
|
||||
|
||||
extern void rtnl_ematch_meta_set_lvalue(struct rtnl_ematch *,
|
||||
struct rtnl_meta_value *);
|
||||
void rtnl_ematch_meta_set_rvalue(struct rtnl_ematch *,
|
||||
struct rtnl_meta_value *);
|
||||
extern void rtnl_ematch_meta_set_operand(struct rtnl_ematch *, uint8_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* netlink/route/cls/ematch/nbyte.h N-Byte Comparison
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CLS_EMATCH_NBYTE_H_
|
||||
#define NETLINK_CLS_EMATCH_NBYTE_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/cls/ematch.h>
|
||||
#include <linux/tc_ematch/tc_em_nbyte.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void rtnl_ematch_nbyte_set_offset(struct rtnl_ematch *,
|
||||
uint8_t, uint16_t);
|
||||
extern uint16_t rtnl_ematch_nbyte_get_offset(struct rtnl_ematch *);
|
||||
extern uint8_t rtnl_ematch_nbyte_get_layer(struct rtnl_ematch *);
|
||||
extern void rtnl_ematch_nbyte_set_pattern(struct rtnl_ematch *,
|
||||
uint8_t *, size_t);
|
||||
extern uint8_t * rtnl_ematch_nbyte_get_pattern(struct rtnl_ematch *);
|
||||
extern size_t rtnl_ematch_nbyte_get_len(struct rtnl_ematch *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* netlink/route/cls/ematch/text.h Text Search
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CLS_EMATCH_TEXT_H_
|
||||
#define NETLINK_CLS_EMATCH_TEXT_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/cls/ematch.h>
|
||||
#include <linux/tc_ematch/tc_em_text.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void rtnl_ematch_text_set_from(struct rtnl_ematch *,
|
||||
uint8_t, uint16_t);
|
||||
extern uint16_t rtnl_ematch_text_get_from_offset(struct rtnl_ematch *);
|
||||
extern uint8_t rtnl_ematch_text_get_from_layer(struct rtnl_ematch *);
|
||||
extern void rtnl_ematch_text_set_to(struct rtnl_ematch *,
|
||||
uint8_t, uint16_t);
|
||||
extern uint16_t rtnl_ematch_text_get_to_offset(struct rtnl_ematch *);
|
||||
extern uint8_t rtnl_ematch_text_get_to_layer(struct rtnl_ematch *);
|
||||
extern void rtnl_ematch_text_set_pattern(struct rtnl_ematch *,
|
||||
char *, size_t);
|
||||
extern char * rtnl_ematch_text_get_pattern(struct rtnl_ematch *);
|
||||
extern size_t rtnl_ematch_text_get_len(struct rtnl_ematch *);
|
||||
extern void rtnl_ematch_text_set_algo(struct rtnl_ematch *, const char *);
|
||||
extern char * rtnl_ematch_text_get_algo(struct rtnl_ematch *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* netlink/route/cls/fw.h fw classifier
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2006 Petr Gotthard <petr.gotthard@siemens.com>
|
||||
* Copyright (c) 2006 Siemens AG Oesterreich
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_FW_H_
|
||||
#define NETLINK_FW_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/classifier.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int rtnl_fw_set_classid(struct rtnl_cls *, uint32_t);
|
||||
extern int rtnl_fw_set_mask(struct rtnl_cls *, uint32_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* netlink/route/cls/police.h Policer
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_CLS_POLICE_H_
|
||||
#define NETLINK_CLS_POLICE_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern char * nl_police2str(int, char *, size_t);
|
||||
extern int nl_str2police(const char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* netlink/route/cls/u32.h u32 classifier
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_U32_H_
|
||||
#define NETLINK_U32_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/route/classifier.h>
|
||||
#include <netlink/route/action.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void rtnl_u32_set_handle(struct rtnl_cls *, int, int, int);
|
||||
extern int rtnl_u32_set_classid(struct rtnl_cls *, uint32_t);
|
||||
extern int rtnl_u32_set_divisor(struct rtnl_cls *, uint32_t);
|
||||
extern int rtnl_u32_set_link(struct rtnl_cls *, uint32_t);
|
||||
extern int rtnl_u32_set_hashtable(struct rtnl_cls *, uint32_t);
|
||||
extern int rtnl_u32_set_hashmask(struct rtnl_cls *, uint32_t, uint32_t);
|
||||
extern int rtnl_u32_set_cls_terminal(struct rtnl_cls *);
|
||||
|
||||
extern int rtnl_u32_set_flags(struct rtnl_cls *, int);
|
||||
extern int rtnl_u32_add_key(struct rtnl_cls *, uint32_t, uint32_t,
|
||||
int, int);
|
||||
extern int rtnl_u32_get_key(struct rtnl_cls *, uint8_t, uint32_t *, uint32_t *,
|
||||
int *, int *);
|
||||
extern int rtnl_u32_add_key_uint8(struct rtnl_cls *, uint8_t, uint8_t,
|
||||
int, int);
|
||||
extern int rtnl_u32_add_key_uint16(struct rtnl_cls *, uint16_t, uint16_t,
|
||||
int, int);
|
||||
extern int rtnl_u32_add_key_uint32(struct rtnl_cls *, uint32_t, uint32_t,
|
||||
int, int);
|
||||
extern int rtnl_u32_add_key_in_addr(struct rtnl_cls *, const struct in_addr *,
|
||||
uint8_t, int, int);
|
||||
extern int rtnl_u32_add_key_in6_addr(struct rtnl_cls *, const struct in6_addr *,
|
||||
uint8_t, int, int);
|
||||
extern int rtnl_u32_add_action(struct rtnl_cls *, struct rtnl_act *);
|
||||
extern int rtnl_u32_del_action(struct rtnl_cls *, struct rtnl_act *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* netlink/route/link.h Links (Interfaces)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_LINK_H_
|
||||
#define NETLINK_LINK_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/cache.h>
|
||||
#include <netlink/addr.h>
|
||||
#include <linux/if.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @struct rtnl_link link.h "netlink/route/link.h"
|
||||
* @brief Link object
|
||||
* @implements nl_object
|
||||
* @ingroup link
|
||||
*
|
||||
* @copydoc private_struct
|
||||
*/
|
||||
struct rtnl_link;
|
||||
|
||||
/**
|
||||
* @ingroup link
|
||||
*/
|
||||
typedef enum {
|
||||
RTNL_LINK_RX_PACKETS, /*!< Packets received */
|
||||
RTNL_LINK_TX_PACKETS, /*!< Packets sent */
|
||||
RTNL_LINK_RX_BYTES, /*!< Bytes received */
|
||||
RTNL_LINK_TX_BYTES, /*!< Bytes sent */
|
||||
RTNL_LINK_RX_ERRORS, /*!< Receive errors */
|
||||
RTNL_LINK_TX_ERRORS, /*!< Send errors */
|
||||
RTNL_LINK_RX_DROPPED, /*!< Received packets dropped */
|
||||
RTNL_LINK_TX_DROPPED, /*!< Packets dropped during transmit */
|
||||
RTNL_LINK_RX_COMPRESSED, /*!< Compressed packets received */
|
||||
RTNL_LINK_TX_COMPRESSED, /*!< Compressed packets sent */
|
||||
RTNL_LINK_RX_FIFO_ERR, /*!< Receive FIFO errors */
|
||||
RTNL_LINK_TX_FIFO_ERR, /*!< Send FIFO errors */
|
||||
RTNL_LINK_RX_LEN_ERR, /*!< Length errors */
|
||||
RTNL_LINK_RX_OVER_ERR, /*!< Over errors */
|
||||
RTNL_LINK_RX_CRC_ERR, /*!< CRC errors */
|
||||
RTNL_LINK_RX_FRAME_ERR, /*!< Frame errors */
|
||||
RTNL_LINK_RX_MISSED_ERR, /*!< Missed errors */
|
||||
RTNL_LINK_TX_ABORT_ERR, /*!< Aborted errors */
|
||||
RTNL_LINK_TX_CARRIER_ERR, /*!< Carrier errors */
|
||||
RTNL_LINK_TX_HBEAT_ERR, /*!< Heartbeat errors */
|
||||
RTNL_LINK_TX_WIN_ERR, /*!< Window errors */
|
||||
RTNL_LINK_COLLISIONS, /*!< Send collisions */
|
||||
RTNL_LINK_MULTICAST, /*!< Multicast */
|
||||
RTNL_LINK_IP6_INPKTS, /*!< IPv6 SNMP InReceives */
|
||||
RTNL_LINK_IP6_INHDRERRORS, /*!< IPv6 SNMP InHdrErrors */
|
||||
RTNL_LINK_IP6_INTOOBIGERRORS, /*!< IPv6 SNMP InTooBigErrors */
|
||||
RTNL_LINK_IP6_INNOROUTES, /*!< IPv6 SNMP InNoRoutes */
|
||||
RTNL_LINK_IP6_INADDRERRORS, /*!< IPv6 SNMP InAddrErrors */
|
||||
RTNL_LINK_IP6_INUNKNOWNPROTOS, /*!< IPv6 SNMP InUnknownProtos */
|
||||
RTNL_LINK_IP6_INTRUNCATEDPKTS, /*!< IPv6 SNMP InTruncatedPkts */
|
||||
RTNL_LINK_IP6_INDISCARDS, /*!< IPv6 SNMP InDiscards */
|
||||
RTNL_LINK_IP6_INDELIVERS, /*!< IPv6 SNMP InDelivers */
|
||||
RTNL_LINK_IP6_OUTFORWDATAGRAMS, /*!< IPv6 SNMP OutForwDatagrams */
|
||||
RTNL_LINK_IP6_OUTPKTS, /*!< IPv6 SNMP OutRequests */
|
||||
RTNL_LINK_IP6_OUTDISCARDS, /*!< IPv6 SNMP OutDiscards */
|
||||
RTNL_LINK_IP6_OUTNOROUTES, /*!< IPv6 SNMP OutNoRoutes */
|
||||
RTNL_LINK_IP6_REASMTIMEOUT, /*!< IPv6 SNMP ReasmTimeout */
|
||||
RTNL_LINK_IP6_REASMREQDS, /*!< IPv6 SNMP ReasmReqds */
|
||||
RTNL_LINK_IP6_REASMOKS, /*!< IPv6 SNMP ReasmOKs */
|
||||
RTNL_LINK_IP6_REASMFAILS, /*!< IPv6 SNMP ReasmFails */
|
||||
RTNL_LINK_IP6_FRAGOKS, /*!< IPv6 SNMP FragOKs */
|
||||
RTNL_LINK_IP6_FRAGFAILS, /*!< IPv6 SNMP FragFails */
|
||||
RTNL_LINK_IP6_FRAGCREATES, /*!< IPv6 SNMP FragCreates */
|
||||
RTNL_LINK_IP6_INMCASTPKTS, /*!< IPv6 SNMP InMcastPkts */
|
||||
RTNL_LINK_IP6_OUTMCASTPKTS, /*!< IPv6 SNMP OutMcastPkts */
|
||||
RTNL_LINK_IP6_INBCASTPKTS, /*!< IPv6 SNMP InBcastPkts */
|
||||
RTNL_LINK_IP6_OUTBCASTPKTS, /*!< IPv6 SNMP OutBcastPkts */
|
||||
RTNL_LINK_IP6_INOCTETS, /*!< IPv6 SNMP InOctets */
|
||||
RTNL_LINK_IP6_OUTOCTETS, /*!< IPv6 SNMP OutOctets */
|
||||
RTNL_LINK_IP6_INMCASTOCTETS, /*!< IPv6 SNMP InMcastOctets */
|
||||
RTNL_LINK_IP6_OUTMCASTOCTETS, /*!< IPv6 SNMP OutMcastOctets */
|
||||
RTNL_LINK_IP6_INBCASTOCTETS, /*!< IPv6 SNMP InBcastOctets */
|
||||
RTNL_LINK_IP6_OUTBCASTOCTETS, /*!< IPv6 SNMP OutBcastOctets */
|
||||
RTNL_LINK_ICMP6_INMSGS, /*!< ICMPv6 SNMP InMsgs */
|
||||
RTNL_LINK_ICMP6_INERRORS, /*!< ICMPv6 SNMP InErrors */
|
||||
RTNL_LINK_ICMP6_OUTMSGS, /*!< ICMPv6 SNMP OutMsgs */
|
||||
RTNL_LINK_ICMP6_OUTERRORS, /*!< ICMPv6 SNMP OutErrors */
|
||||
RTNL_LINK_ICMP6_CSUMERRORS, /*!< ICMPv6 SNMP InCsumErrors */
|
||||
RTNL_LINK_IP6_CSUMERRORS, /*!< IPv6 SNMP InCsumErrors */
|
||||
RTNL_LINK_IP6_NOECTPKTS, /*!< IPv6 SNMP InNoECTPkts */
|
||||
RTNL_LINK_IP6_ECT1PKTS, /*!< IPv6 SNMP InECT1Pkts */
|
||||
RTNL_LINK_IP6_ECT0PKTS, /*!< IPv6 SNMP InECT0Pkts */
|
||||
RTNL_LINK_IP6_CEPKTS, /*!< IPv6 SNMP InCEPkts */
|
||||
__RTNL_LINK_STATS_MAX,
|
||||
} rtnl_link_stat_id_t;
|
||||
|
||||
#define RTNL_LINK_STATS_MAX (__RTNL_LINK_STATS_MAX - 1)
|
||||
|
||||
extern struct nla_policy rtln_link_policy[];
|
||||
|
||||
extern struct rtnl_link *rtnl_link_alloc(void);
|
||||
extern void rtnl_link_put(struct rtnl_link *);
|
||||
|
||||
extern int rtnl_link_alloc_cache(struct nl_sock *, int, struct nl_cache **);
|
||||
extern struct rtnl_link *rtnl_link_get(struct nl_cache *, int);
|
||||
extern struct rtnl_link *rtnl_link_get_by_name(struct nl_cache *, const char *);
|
||||
|
||||
|
||||
extern int rtnl_link_build_add_request(struct rtnl_link *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_link_add(struct nl_sock *, struct rtnl_link *, int);
|
||||
extern int rtnl_link_build_change_request(struct rtnl_link *,
|
||||
struct rtnl_link *, int,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_link_change(struct nl_sock *, struct rtnl_link *,
|
||||
struct rtnl_link *, int);
|
||||
|
||||
extern int rtnl_link_build_delete_request(const struct rtnl_link *,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_link_delete(struct nl_sock *, const struct rtnl_link *);
|
||||
extern int rtnl_link_build_get_request(int, const char *,
|
||||
struct nl_msg **);
|
||||
extern int rtnl_link_get_kernel(struct nl_sock *, int, const char *,
|
||||
struct rtnl_link **);
|
||||
|
||||
/* Name <-> Index Translations */
|
||||
extern char * rtnl_link_i2name(struct nl_cache *, int, char *, size_t);
|
||||
extern int rtnl_link_name2i(struct nl_cache *, const char *);
|
||||
|
||||
/* Name <-> Statistic Translations */
|
||||
extern char * rtnl_link_stat2str(int, char *, size_t);
|
||||
extern int rtnl_link_str2stat(const char *);
|
||||
|
||||
/* Link Flags Translations */
|
||||
extern char * rtnl_link_flags2str(int, char *, size_t);
|
||||
extern int rtnl_link_str2flags(const char *);
|
||||
|
||||
extern char * rtnl_link_operstate2str(uint8_t, char *, size_t);
|
||||
extern int rtnl_link_str2operstate(const char *);
|
||||
|
||||
extern char * rtnl_link_mode2str(uint8_t, char *, size_t);
|
||||
extern int rtnl_link_str2mode(const char *);
|
||||
|
||||
/* Carrier State Translations */
|
||||
extern char * rtnl_link_carrier2str(uint8_t, char *, size_t);
|
||||
extern int rtnl_link_str2carrier(const char *);
|
||||
|
||||
/* Access Functions */
|
||||
extern void rtnl_link_set_qdisc(struct rtnl_link *, const char *);
|
||||
extern char * rtnl_link_get_qdisc(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_name(struct rtnl_link *, const char *);
|
||||
extern char * rtnl_link_get_name(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_group(struct rtnl_link *, uint32_t);
|
||||
extern uint32_t rtnl_link_get_group(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_flags(struct rtnl_link *, unsigned int);
|
||||
extern void rtnl_link_unset_flags(struct rtnl_link *, unsigned int);
|
||||
extern unsigned int rtnl_link_get_flags(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_mtu(struct rtnl_link *, unsigned int);
|
||||
extern unsigned int rtnl_link_get_mtu(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_txqlen(struct rtnl_link *, unsigned int);
|
||||
extern unsigned int rtnl_link_get_txqlen(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_ifindex(struct rtnl_link *, int);
|
||||
extern int rtnl_link_get_ifindex(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_family(struct rtnl_link *, int);
|
||||
extern int rtnl_link_get_family(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_arptype(struct rtnl_link *, unsigned int);
|
||||
extern unsigned int rtnl_link_get_arptype(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_addr(struct rtnl_link *, struct nl_addr *);
|
||||
extern struct nl_addr *rtnl_link_get_addr(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_broadcast(struct rtnl_link *, struct nl_addr *);
|
||||
extern struct nl_addr *rtnl_link_get_broadcast(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_link(struct rtnl_link *, int);
|
||||
extern int rtnl_link_get_link(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_master(struct rtnl_link *, int);
|
||||
extern int rtnl_link_get_master(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_carrier(struct rtnl_link *, uint8_t);
|
||||
extern uint8_t rtnl_link_get_carrier(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_operstate(struct rtnl_link *, uint8_t);
|
||||
extern uint8_t rtnl_link_get_operstate(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_linkmode(struct rtnl_link *, uint8_t);
|
||||
extern uint8_t rtnl_link_get_linkmode(struct rtnl_link *);
|
||||
|
||||
extern const char * rtnl_link_get_ifalias(struct rtnl_link *);
|
||||
extern void rtnl_link_set_ifalias(struct rtnl_link *, const char *);
|
||||
|
||||
extern int rtnl_link_get_num_vf(struct rtnl_link *, uint32_t *);
|
||||
|
||||
extern uint64_t rtnl_link_get_stat(struct rtnl_link *, rtnl_link_stat_id_t);
|
||||
extern int rtnl_link_set_stat(struct rtnl_link *, rtnl_link_stat_id_t,
|
||||
const uint64_t);
|
||||
|
||||
extern int rtnl_link_set_type(struct rtnl_link *, const char *);
|
||||
extern char * rtnl_link_get_type(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_promiscuity(struct rtnl_link *, uint32_t);
|
||||
extern uint32_t rtnl_link_get_promiscuity(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_num_tx_queues(struct rtnl_link *, uint32_t);
|
||||
extern uint32_t rtnl_link_get_num_tx_queues(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_num_rx_queues(struct rtnl_link *, uint32_t);
|
||||
extern uint32_t rtnl_link_get_num_rx_queues(struct rtnl_link *);
|
||||
|
||||
extern struct nl_data * rtnl_link_get_phys_port_id(struct rtnl_link *);
|
||||
|
||||
extern void rtnl_link_set_ns_fd(struct rtnl_link *, int);
|
||||
extern int rtnl_link_get_ns_fd(struct rtnl_link *);
|
||||
extern void rtnl_link_set_ns_pid(struct rtnl_link *, pid_t);
|
||||
extern pid_t rtnl_link_get_ns_pid(struct rtnl_link *);
|
||||
|
||||
extern int rtnl_link_enslave_ifindex(struct nl_sock *, int, int);
|
||||
extern int rtnl_link_enslave(struct nl_sock *, struct rtnl_link *,
|
||||
struct rtnl_link *);
|
||||
extern int rtnl_link_release_ifindex(struct nl_sock *, int);
|
||||
extern int rtnl_link_release(struct nl_sock *, struct rtnl_link *);
|
||||
extern int rtnl_link_fill_info(struct nl_msg *, struct rtnl_link *);
|
||||
extern int rtnl_link_info_parse(struct rtnl_link *, struct nlattr **);
|
||||
|
||||
|
||||
/* deprecated */
|
||||
extern int rtnl_link_set_info_type(struct rtnl_link *, const char *) __attribute__((deprecated));
|
||||
extern char * rtnl_link_get_info_type(struct rtnl_link *) __attribute__((deprecated));
|
||||
extern void rtnl_link_set_weight(struct rtnl_link *, unsigned int) __attribute__((deprecated));
|
||||
extern unsigned int rtnl_link_get_weight(struct rtnl_link *) __attribute__((deprecated));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* netlink/route/link/api.h Link Modules API
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_DUMMY_LINK_API_H_
|
||||
#define NETLINK_DUMMY_LINK_API_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/link.h>
|
||||
|
||||
#warning "You are including a deprecated header file, include <netlink/route/link.h>."
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* netlink/route/link/bonding.h Bonding Interface
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2011-2013 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_LINK_BONDING_H_
|
||||
#define NETLINK_LINK_BONDING_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/link.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct rtnl_link *rtnl_link_bond_alloc(void);
|
||||
|
||||
extern int rtnl_link_bond_add(struct nl_sock *, const char *,
|
||||
struct rtnl_link *);
|
||||
|
||||
extern int rtnl_link_bond_enslave_ifindex(struct nl_sock *, int, int);
|
||||
extern int rtnl_link_bond_enslave(struct nl_sock *, struct rtnl_link *,
|
||||
struct rtnl_link *);
|
||||
|
||||
extern int rtnl_link_bond_release_ifindex(struct nl_sock *, int);
|
||||
extern int rtnl_link_bond_release(struct nl_sock *, struct rtnl_link *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* netlink/route/link/bridge.h Bridge
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_LINK_BRIDGE_H_
|
||||
#define NETLINK_LINK_BRIDGE_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/link.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Bridge flags
|
||||
* @ingroup bridge
|
||||
*/
|
||||
enum rtnl_link_bridge_flags {
|
||||
RTNL_BRIDGE_HAIRPIN_MODE = 0x0001,
|
||||
RTNL_BRIDGE_BPDU_GUARD = 0x0002,
|
||||
RTNL_BRIDGE_ROOT_BLOCK = 0x0004,
|
||||
RTNL_BRIDGE_FAST_LEAVE = 0x0008,
|
||||
};
|
||||
|
||||
extern struct rtnl_link *rtnl_link_bridge_alloc(void);
|
||||
|
||||
extern int rtnl_link_is_bridge(struct rtnl_link *);
|
||||
extern int rtnl_link_bridge_has_ext_info(struct rtnl_link *);
|
||||
|
||||
extern int rtnl_link_bridge_set_port_state(struct rtnl_link *, uint8_t );
|
||||
extern int rtnl_link_bridge_get_port_state(struct rtnl_link *);
|
||||
|
||||
extern int rtnl_link_bridge_set_priority(struct rtnl_link *, uint16_t);
|
||||
extern int rtnl_link_bridge_get_priority(struct rtnl_link *);
|
||||
|
||||
extern int rtnl_link_bridge_set_cost(struct rtnl_link *, uint32_t);
|
||||
extern int rtnl_link_bridge_get_cost(struct rtnl_link *, uint32_t *);
|
||||
|
||||
extern int rtnl_link_bridge_unset_flags(struct rtnl_link *, unsigned int);
|
||||
extern int rtnl_link_bridge_set_flags(struct rtnl_link *, unsigned int);
|
||||
extern int rtnl_link_bridge_get_flags(struct rtnl_link *);
|
||||
|
||||
extern char * rtnl_link_bridge_flags2str(int, char *, size_t);
|
||||
extern int rtnl_link_bridge_str2flags(const char *);
|
||||
|
||||
extern int rtnl_link_bridge_add(struct nl_sock *sk, const char *name);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* netlink/route/link/can.h CAN interface
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2012 Benedikt Spranger <b.spranger@linutronix.de>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_LINK_CAN_H_
|
||||
#define NETLINK_LINK_CAN_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink/route/link.h>
|
||||
#include <linux/can/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int rtnl_link_is_can(struct rtnl_link *link);
|
||||
|
||||
extern char *rtnl_link_can_ctrlmode2str(int, char *, size_t);
|
||||
extern int rtnl_link_can_str2ctrlmode(const char *);
|
||||
|
||||
extern int rtnl_link_can_restart(struct rtnl_link *);
|
||||
extern int rtnl_link_can_freq(struct rtnl_link *, uint32_t *);
|
||||
extern int rtnl_link_can_state(struct rtnl_link *, uint32_t *);
|
||||
|
||||
extern int rtnl_link_can_berr_rx(struct rtnl_link *);
|
||||
extern int rtnl_link_can_berr_tx(struct rtnl_link *);
|
||||
extern int rtnl_link_can_berr(struct rtnl_link *, struct can_berr_counter *);
|
||||
|
||||
extern int rtnl_link_can_get_bt_const(struct rtnl_link *,
|
||||
struct can_bittiming_const *);
|
||||
extern int rtnl_link_can_get_bittiming(struct rtnl_link *,
|
||||
struct can_bittiming *);
|
||||
extern int rtnl_link_can_set_bittiming(struct rtnl_link *,
|
||||
struct can_bittiming *);
|
||||
|
||||
extern int rtnl_link_can_get_bitrate(struct rtnl_link *, uint32_t *);
|
||||
extern int rtnl_link_can_set_bitrate(struct rtnl_link *, uint32_t);
|
||||
|
||||
extern int rtnl_link_can_get_sample_point(struct rtnl_link *, uint32_t *);
|
||||
extern int rtnl_link_can_set_sample_point(struct rtnl_link *, uint32_t);
|
||||
|
||||
extern int rtnl_link_can_get_restart_ms(struct rtnl_link *, uint32_t *);
|
||||
extern int rtnl_link_can_set_restart_ms(struct rtnl_link *, uint32_t);
|
||||
|
||||
extern int rtnl_link_can_get_ctrlmode(struct rtnl_link *, uint32_t *);
|
||||
extern int rtnl_link_can_set_ctrlmode(struct rtnl_link *, uint32_t);
|
||||
extern int rtnl_link_can_unset_ctrlmode(struct rtnl_link *, uint32_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* netlink/route/link/inet.h INET Link Module
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2010 Thomas Graf <tgraf@suug.ch>
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_LINK_INET_H_
|
||||
#define NETLINK_LINK_INET_H_
|
||||
|
||||
#include <netlink/netlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char * rtnl_link_inet_devconf2str(int, char *, size_t);
|
||||
extern int rtnl_link_inet_str2devconf(const char *);
|
||||
|
||||
extern int rtnl_link_inet_get_conf(struct rtnl_link *,
|
||||
const unsigned int, uint32_t *);
|
||||
extern int rtnl_link_inet_set_conf(struct rtnl_link *,
|
||||
const unsigned int, uint32_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user