94 lines
2.4 KiB
C
94 lines
2.4 KiB
C
/****************************************************************************/
|
||
/* Copyright (c) 2007,许继集团有限公司 */
|
||
/* All rights reserved. */
|
||
/* */
|
||
/* 模块描述: */
|
||
/** 数据链路层网络功能接口
|
||
* @file gsv_clnp.h */
|
||
/* */
|
||
/* 日期 作者 注释 */
|
||
/* 2008/6/6 DJF 创建文件 */
|
||
/****************************************************************************/
|
||
#ifndef GSMV_GSV_CLNP_INC
|
||
#define GSMV_GSV_CLNP_INC
|
||
|
||
#include "glbtypes.h"
|
||
#include "sysincs.h"
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
/**
|
||
* 网卡信息定义
|
||
*/
|
||
typedef struct
|
||
{
|
||
ST_INT index;
|
||
ST_CHAR * name;
|
||
ST_CHAR * desc;
|
||
ST_CHAR mac[6];
|
||
ST_INT fp; //网卡句柄
|
||
}GSV_ETH_INFO;
|
||
|
||
/**
|
||
* 初始化网络,获取所有网卡信息,给全局变量Eth_infos和Eth_num赋值,这里不打开网卡
|
||
*/
|
||
ST_VOID gsv_clnp_init( void );
|
||
|
||
/**
|
||
* 终止化网络,关闭所有网卡,释放Eth_infos和Eth_num
|
||
*/
|
||
ST_VOID gsv_clnp_uninit( void );
|
||
|
||
/**
|
||
* 打开网卡
|
||
* @param eth_name 网卡名称
|
||
* @param timeout 接收超时时限,如果<0,则网卡设为非阻塞模式,如果=0,则设为阻塞
|
||
* 模式,阻塞无限长时间,直到收到数据,>0时表示阻塞的最大时间
|
||
*/
|
||
ST_RET gsv_clnp_eth_open( ST_INT eth_index, ST_INT timeout );
|
||
|
||
/**
|
||
* 关闭网卡,释放套接口
|
||
*/
|
||
ST_VOID gsv_clnp_eth_close( ST_INT eth_index );
|
||
|
||
/**
|
||
* 设置抓包时过滤指定网卡发出的报文
|
||
* @param eth_index 网卡序号
|
||
*/
|
||
ST_RET gsv_clnp_filter_src_mac( ST_INT eth_index );
|
||
|
||
/**
|
||
* 发送数据
|
||
* @param msg 报文
|
||
* @param msg_len 报文长度
|
||
*/
|
||
ST_RET gsv_clnp_send( ST_INT eth_index, ST_UCHAR * msg, ST_INT msg_len );
|
||
|
||
/**
|
||
* 接收报文,一次处理完缓冲区中所有报文,然后返回收到的报文数
|
||
* @param len 传出参数,接收到的报文长度
|
||
* @return 报文地址
|
||
*/
|
||
const ST_UCHAR * gsv_clnp_recv( ST_INT eth_index, ST_INT * len );
|
||
|
||
/**
|
||
* 获取主机中所有网卡信息, 必须在gsv_clnp_init之后调用
|
||
* @param eth_infos 所有网卡信息,数组
|
||
* @return 网卡个数
|
||
*/
|
||
ST_INT gsv_find_all_eth( GSV_ETH_INFO ** eth_infos );
|
||
|
||
/**
|
||
* 获取主机mac地址
|
||
*/
|
||
ST_VOID gsv_get_eth_mac( ST_INT eth_index, ST_UCHAR * mac );
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif
|