#ifndef CONNECTOR_H_ #define CONNECTOR_H_ extern int CONNECTOR_VERSION_1_20170704; typedef unsigned long ulong64; typedef unsigned int uint32; typedef enum { APPD_SENDBACK=0, //前端向应用层数据回传数据 APPD_FILE=1, //多链接文件关联模块向应用层数据分发 }APPD_HEADER_TYPE; typedef enum { DEST_APPD=0, //数据分发程序appd DEST_WM=1, //webmail二级关联程序WM DEST_MLFA=2, //文件关联程序mlfa }APPD_DESTINATION; typedef enum { COMPLETE=0, FRAG=1, FRAG_END=2, }APPD_MSG_TYPE; typedef struct _appd_basic_t { APPD_HEADER_TYPE appd_type; //应用层数据还是文件数据 const char* service_name; //服务类型名称,'\0'结束 APPD_DESTINATION destination; //数据接收程序 ulong64* streamid; //动态数组指针,流id uint32 streamid_num; struct ipaddr* addr; //动态数组指针, 流四元组 uint32 addr_num; }appd_basic_t; #ifdef __cplusplus extern "C" { #endif /*初始化,获得connector句柄, 每一个数据流调用一次*/ //void* connector_start(appd_basic_t* baisc_info); void* connector_start(appd_basic_t* baisc_info, const struct streaminfo *a_tcp); /* msg_type:数据类型 COMPLETE FRAG FRAG_END*/ void connector(void* handler, APPD_MSG_TYPE msg_type, void* simple_opt_handle, void* nested_opt_handle); /*每一个数据流结束调用*/ void connector_finish(void* handler); /*简单选项调用以下三个函数*/ /*1. 设置简单选项的个数,返回simple_opt_handle*/ void* connector_create_simple_opt(uint32 max_size); /*2. 填充选项*/ int connector_append_simple_opt(void* simple_opt_handle, const char* opt_name, char* opt_value, uint32 opt_len); /*3. 释放*/ void connector_free_simple_opt(void** simple_opt_handle); /*嵌套选项调用以下六个函数*/ /*1. 创建并且设置嵌套选项的总个数,返回nested_opt_handle*/ void* connector_create_nested_opt(uint32 max_size); /*2. 创建并且设置某个嵌套选项的名称以及内层选项的个数,返回nested_unit_handle*/ void* connector_create_nested_opt_unit(const char* nested_unit_name, uint32 max_size); /*3.填充单个嵌套选项的内层选项*/ /*opt_unit_handle 是connector_create_nested_opt_unit的返回值*/ /*返回值 0 OK -1 ERROR*/ int connector_append_nested_opt_unit(void* nested_unit_handle, const char* subopt_name, char* subopt_value, uint32 subopt_len); /*4. 将单个嵌套选项追加至嵌套选项句柄nested_opt_handle中*/ /*返回值 0 OK -1 ERROR*/ int connector_append_nested_opt(void* nested_opt_handle, void* nested_unit_handle); /*5. 释放单个嵌套选项*/ void connector_free_nested_opt_unit(void** nested_unit_handle); /*6. 释放*/ void connector_free_nested_opt(void** nested_opt_handle); #ifdef __cplusplus } #endif #endif