[strongswan] strongswan METHOD宏
使用METHOD宏的函数定义:
METHOD(message_t, get_message_id, uint32_t,
private_message_t *this)
{
return this->message_id;
}
METHOD宏的定义:
/**
* Method declaration/definition macro, providing private and public interface.
*
* Defines a method name with this as first parameter and a return value ret,
* and an alias for this method with a _ prefix, having the this argument
* safely casted to the public interface iface.
* _name is provided a function pointer, but will get optimized out by GCC.
*/
#define METHOD(iface, name, ret, this, ...) \
static ret name(union {iface *_public; this;} \
__attribute__((transparent_union)), ##__VA_ARGS__); \
static typeof(name) *_##name = (typeof(name)*)name; \
static ret name(this, ##__VA_ARGS__)
将METHOD宏展开后的定义:
static uint32_t get_message_id(union {message_t *_public; private_message_t *this;} __attribute__((transparent_union)));
static typeof(get_message_id)* _get_message_id = (typeof(get_message_id)*)get_message_id;
static uint32_t get_message_id(private_message_t *this)
关于transparent_union的定义:
http://nanjingabcdefg.is-programmer.com/categories/5966/posts
[strongswan] strongswan METHOD宏的更多相关文章
- [ipsec][strongswan] strongswan源码分析--(一)SA整体分析
strongswan SA分析(一) 1 概念 下面主要介绍两个本文将要阐述的核心概念.他们是SA和SP.注意,这不是一篇不需要背景知识的文章.作者认为你适合阅读接下来内容的的前提是,你已经具备了一下 ...
- [ipsec][strongswan] strongswan源码分析--(五)plugin的配置文件的添加方法与管理架构解析
前言 我们知道,strongswan是基于插件式管理的.不同的插件有不同的配置文件,在这下面, 我们以netlink的插件为例:etc/strongswan.d/charon/kernel-netli ...
- [strongswan] strongswan是如何实现与xfrm之间的trap机制的
目录 strongswan与xfrm之间的trap机制 0. 1. 前言 2. 描述 2.1 none 2.2 trap 3. 实验与过程 3.1 trap实验 3.2 none实验 4 背景知识 5 ...
- [ipsec][strongswan] strongswan源码分析-- (三) xfrm与strongswan内核接口分析
目录 strongwan sa分析(三) xfrm与strongswan内核接口分析 1. strongswan的实现 2. 交互机制 4. xfrm的消息通信的实现 strongwan sa分析(三 ...
- [ipsec][strongswan] strongswan源码分析-- (二)rekey/reauth机制分析
目录 strongwan sa分析(二) 名词约定 rekey/reauth 机制分析 1 概述 2 reauth 3 CHILD SA rekey 4 IKE SA rekey 5 其他 stron ...
- [ipsec][strongswan] strongswan源码分析--(〇)总体架构图
history: 2019-06-05, 增加配置文件解析部分. 2019-06-05,增加plugin优先级排序部分. charon进程初始化阶段的流程图 约定: 实线代表流程图. 虚线代表调用栈, ...
- [ipsec][strongswan]strongswan源码分析--(零)引子
目录 strongswan sa 资料 编译 启动 进程信息 结构 架构图与插件 配置运行 传统配置方法 新的配置方法 其他配置方法 详细的配置文档 配置示例 用法 加密库 libgmp libcry ...
- [ipsec][strongswan] strongswan源码分析--(四)plugin加载优先级原理
前言 如前所述, 我们知道,strongswan以插件功能来提供各种各样的功能.插件之间彼此相互提供功能,同时也有可能提供重复的功能. 这个时候,便需要一个优先级关系,来保证先后加载顺序. 方法 在配 ...
- [dev][crypto][strongswan] 有关strongswan的forward policy的源码分析
一 默认情况下,我们使用strongswan建立了一个ipsec隧道之后,建立的policy如下: [root@D129 OUTPUT]# ip xfrm policy src dst dir pty ...
随机推荐
- windows下使用git和github建立远程仓库
转自(http://www.bubuko.com/infodetail-430228.html) 从昨天开始就在看git的使用,因为在Windows下很多命令行操作都比较坑爹,但是今天再走了无数弯路之 ...
- 在visual studio 2013中编译Lua5.3.1
注:以下是基于 别人的教程或笔记来操作并按照自己的操作记录的纯文字版编译和hello lua过程. 原图文版链接: 原文链接 1.创建空的解决方案: 文件->新建->项目->其他项目 ...
- java----SAX解析XML
XML: 可扩展标记语言 1.充当显示数据 2.储存数据 3.传输数据 SAX: 水电费 基于事假驱动,顺序读写,速度快 不能任意读取节点,灵活性差 解析时,占用内存小 import org.xml. ...
- Elasticsearch先聚合再按时间排序返回需要的字段
{ "query": { "bool": { "must": [ { "term": { "area_code ...
- sklearn交叉验证2-【老鱼学sklearn】
过拟合 过拟合相当于一个人只会读书,却不知如何利用知识进行变通. 相当于他把考试题目背得滚瓜烂熟,但一旦环境稍微有些变化,就死得很惨. 从图形上看,类似下图的最右图: 从数学公式上来看,这个曲线应该是 ...
- cmake教程
1 教程 cmake界的hello world[2] 进阶的入门教程参考[3] 2 引用 [1] cmake官网 [2] 在 linux 下使用 CMake 构建应用程序 [3] Valgrind官网
- 2.使用RNN做诗歌生成
诗歌生成比分类问题要稍微麻烦一些,而且第一次使用RNN做文本方面的问题,还是有很多概念性的东西~~~ 数据下载: 链接:https://pan.baidu.com/s/1uCDup7U5rGuIlIb ...
- Promise(interesting)
// 最主要的是理解setTimeout和(浏览器执行程序 || resolve执行位置)的顺序就能吃透了 //(MD 楞是看了我2个小时时间 真的是费脑洞︿( ̄︶ ̄)︿)X.then.then 以下 ...
- S0.2 灰度图
目录 灰度图定义 灰度图优点 RGB转灰度算法(OpenCV3) 量化 算法公式 OpenCV自带函数实现 综合比较 灰度图定义 对于单色(灰度)图像而言,每个像素的亮度用一个数值来表示,通常数值范围 ...
- CentOS下的Mysql的安装和使用
1.使用安装命令 :yum -y install mysql mysql-server mysql-devel 安装完成却发现Myserver安装缺失,在网上找原因,原来是因为CentOS 7上把My ...