libnet 函数列表

libnet提供的接口函数按其作用可分为四类:

* 内存管理(分配和释放)函数

* 地址解析函数

* 数据包构造函数

* 数据包发送函数

以下分别列出这些接口函数及其功能(其参数含义简单易懂,不再解释)

内存管理函数

单数据包内存初始化:

int libnet_init_packet(u_short packet_size, u_char **buf);

单数据包内存释放:

void libnet_destroy_packet(u_char **buf);

多数据包内存初始化:

int libnet_init_packet_arena(struct libnet_arena **arena,u_short packet_num, u_short packet_size);

访问多数据包内存中的下一个数据包:

u_char *libnet_next_packet_from_arena(struct libnet_arena **arena,u_short packet_size);

多数据包内存释放:

void libnet_destroy_packet_arena(struct libnet_arena **arena);

地址解析函数

解析主机名:

u_char *libnet_host_lookup(u_long ip, u_short use_name);

解析主机名(可重入函数):

void libnet_host_lookup_r(u_long ip, u_short use_name, u_char *buf);

域名解析:

u_long libnet_name_resolve(u_char *ip, u_short use_name);

获取接口设备IP地址:

u_long libnet_get_ipaddr(struct libnet_link_int *l,const u_char *device, const u_char *ebuf);

获取接口设备硬件地址:

struct ether_addr *libnet_get_hwaddr(struct libnet_link_int *l,const u_char *device,const u_char *ebuf);

数据包构造函数

ARP协议数据包:

int libnet_build_arp(u_short hrdw, u_short prot, u_short h_len,u_short p_len, u_short op, u_char *s_ha,

u_char *s_pa, u_char *t_ha, u_char *t_pa,const u_char *payload, int payload_len,u_char *packet_buf);

DNS协议数据包:

int libnet_build_dns(u_short id, u_short flags, u_short num_q,u_short num_answ_rr, u_short num_auth_rr,

u_short num_add_rr, const u_char * payload,int payload_len, u_char *packet_buf);

以太网协议数据包:

int libnet_build_ethernet(u_char *daddr, u_char *saddr, u_short id,const u_char *payload, int payload_len,

u_char *packet_buf);

ICMP协议数据包(ICMP_ECHO / ICMP_ECHOREPLY):

int libnet_build_icmp_echo(u_char type, u_char code, u_short id,

u_short seq, const u_char *payload,int payload_len, u_char *packet_buf);

ICMP协议数据包(ICMP_MASKREQ / ICMP_MASKREPLY):

int libnet_build_icmp_mask(u_char type, u_char code, u_short id,

u_short seq, u_long mask,const u_char *payload, int payload_len,

u_char *packet_buf);

ICMP协议数据包(ICMP_UNREACH):

int libnet_build_icmp_unreach(u_char type, u_char code,

u_short orig_len, u_char orig_tos,u_short orig_id, u_short orig_frag,

u_char orig_ttl, u_char orig_prot,u_long orig_saddr, u_long orig_daddr,

const u_char *payload, int payload_len,u_char *packet_buf);

ICMP协议数据包(ICMP_TIMEXCEED):

int libnet_build_icmp_timeexceed(u_char type, u_char code,

u_short orig_len, u_char orig_tos,u_short orig_id, u_short orig_frag,

u_char orig_ttl, u_char orig_prot,u_long orig_saddr, u_long orig_daddr,

const u_char *payload, int payload_len,u_char *packet_buf);

ICMP协议数据包(ICMP_REDIRECT):

int libnet_build_icmp_redirect(u_char type, u_char code, u_long gateway,

u_short orig_len, u_char orig_tos,u_short orig_id, u_short orig_frag,

u_char orig_ttl, u_char orig_prot,u_long orig_saddr, u_long orig_daddr,

const u_char *payload, int payload_len,u_char *packet_buf);

ICMP协议数据包(ICMP_TSTAMP / ICMP_TSTAMPREPLY):

int libnet_build_icmp_timestamp(u_char type, u_char code, u_short id,

u_short seq, n_time otime, n_time rtime,n_time ttime, const u_char *payload,

int payload_len, u_char *packet_buf);

IGMP协议数据包:

int libnet_build_igmp(u_char type, u_char code, u_long ip,

const u_char *payload, int payload_len,u_char *packet_buf);

IP协议数据包:

int libnet_build_ip(u_short len, u_char tos, u_short ip_id, u_short frag,u_char ttl, u_char protocol, u_long saddr, u_long daddr, const u_char *payload, int payload_len,u_char *packet_buf);

OSPF路由协议数据包:

int libnet_build_ospf(u_short len, u_char type, u_long router_id,u_long area_id, u_short auth_type,

const char *payload, int payload_s, u_char *buf);

OSPF路由协议数据包(Hello):

int libnet_build_ospf_hello(u_long netmask, u_short interval,

u_char options, u_char priority,u_int dead_interval, u_long des_router,

u_long backup, u_long neighbor,const char *payload, int payload_s,u_char *buf);

OSPF路由协议数据包(DataBase Description (DBD)):

int libnet_build_ospf_dbd(u_short len, u_char options, u_char type,

u_int sequence_num, const char *payload,int payload_s, u_char *buf);

OSPF路由协议数据包(Link State Request (LSR)):

int libnet_build_ospf_lsr(u_int type, u_int ls_id, u_long adv_router,

const char *payload, int payload_s,u_char *buf);

OSPF路由协议数据包(Link State Update (LSU)):

int libnet_build_ospf_lsu(u_int num, const char *payload,int payload_s, u_char *buf);

OSPF路由协议数据包(Link State Acknowledgement (LSA)):

int libnet_build_ospf_lsa(u_short age, u_char options, u_char type,u_int ls_id, u_long adv_router, u_int sequence_num, u_short len,const char *payload, int payload_s,u_char *buf);

OSPF路由协议数据包(OSPF Link Sate NetworkLink State Router):

int libnet_build_ospf_lsa_net(u_long netmask, u_int router_id,

const char *payload, int payload_s,u_char *buf);

OSPF路由协议数据包(Link State Router):

int libnet_build_ospf_lsa_rtr(u_short flags, u_short num, u_int id,

u_int data, u_char type, u_char tos,u_short metric, const char *payload,int payload_s, u_char *buf);

OSPF路由协议数据包(Link State Summary):

int libnet_build_ospf_lsa_sum(u_long netmask, u_int metric, u_int tos,

const char *payload, int payload_s,u_char *buf);

OSPF路由协议数据包(Link State AS External):

int libnet_build_ospf_lsa_as(u_long netmask, u_int metric,

u_long fwd_addr, u_int tag,const char *payload, int payload_s,u_char *buf);

RIP路由协议数据包:

int libnet_build_rip(u_char cmd, u_char ver, u_short domain,

u_short addr_fam, u_short route_tag, u_long ip,u_long mask, u_long next_hop, u_long metric,

const u_char *payload, int payload_len,u_char *packet_buf);

TCP协议数据包:

int libnet_build_tcp(u_short th_sport, u_short th_dport, u_long th_seq,

u_long th_ack, u_char th_flags, u_short th_win,u_short th_urg, const u_char *payload,int payload_len, u_char *packet_buf);

UDP协议数据包:

int libnet_build_udp(u_short sport, u_short dport, const u_char *payload,int payload_len, u_char *packet_buf);

IP协议数据包选项:

int libnet_insert_ipo(struct ipoption *opt, u_char opt_len,u_char *packet_buf);

TCP协议数据包选项:

int libnet_insert_tcpo(struct tcpoption *opt, u_char opt_len,u_char *packet_buf);

数据包发送函数

打开raw socket:

int libnet_open_raw_sock(int protocol);

关闭raw socket:

int libnet_close_raw_sock(int socket);

选择接口设备:

int libnet_select_device(struct sockaddr_in *sin,

u_char **device, u_char *ebuf);

打开链路层接口设备:

struct libnet_link_int *libnet_open_link_interface(char *device,char *ebuf);

关闭链路层接口设备:

int libnet_close_link_interface(struct libnet_link_int *l);

发送IP数据包:

int libnet_write_ip(int socket, u_char *packet, int packet_size);

发送链路层数据包:

int libnet_write_link_layer(struct libnet_link_int *l,const u_char *device, u_char *packet,int packet_size);

检验和计算:

int libnet_do_checksum(u_char *packet, int protocol, int packet_size);

相关的支持函数

随机数种子生成器:

int libnet_seed_prand();

获取随机数:

u_long libnet_get_prand(int modulus);

16进制数据输出:

void libnet_hex_dump(u_char * buf, int len, int swap, FILE *stream);

端口列表链初始化:

int libnet_plist_chain_new(struct libnet_plist_chain **plist,char *token_list);

获取端口列表链的下一项(端口范围):

int libnet_plist_chain_next_pair(struct libnet_plist_chain *plist,u_short *bport, u_short *eport);

端口列表链输出显示:

int libnet_plist_chain_dump(struct libnet_plist_chain *plist);

获取端口列表链:

u_char *libnet_plist_chain_dump_string(struct libnet_plist_chain *plist);

端口列表链内存释放:

void libnet_plist_chain_free(struct libnet_plist_chain *plist);

转自:底层网络开发库之libnet

时间: 2024-08-01 10:46:22

libnet 函数列表的相关文章

虚函数列表: 取出方法 // 虚函数工作原理和(虚)继承类的内存占用大小计算 32位机器上 sizeof(void *) // 4byte

#include <iostream> using namespace std; class A { public: A(){} virtual void geta(){ cout << "A:A" <<endl; } virtual void getb(){ cout << "A:B" <<endl; } }; class B :public A{ public: B(){} virtual void g

“虐心”的获取C++函数列表

今天在这里和大家分享一下如何获取c++文件中的函数列表,问题和灵感来自于同事小W自开发的C++代码覆盖率工具,原理是通过给现有的代码进行打桩,在运行到该函数的时候对该函数进行标记,最终统计得到代码的函数覆盖度. 如图:程序的源代码 经过打桩后的代码 原理大致如下,这里就不给大家详细介绍了. 那么问题的重点来了,如何解析并且获取cpp文件中的函数呢? 首先想到的方法是的利用编译原理的思想通过添加规则的方法去获取函数,如:对"{","}","(",&

untra edit 显示文件函数列表

UltraEdit的函数列表竟然不显示函数,那这功能要它何用,应该如何才能让函数显示出来呢? 1:先查看一下UE的菜单:视图-->查看方式(语法高亮类型)-->选择相应的语言(我们用的是C,嗯嗯这个步骤有快捷键哦) 2:如果显示是上面的情况,则需要修改配置:高级-->配置(导航)-->编辑器显示-->语法高亮-->文档的完整路径名称.选择你安装的文件UE根目录下的WORDFILE.UEW文件或者 wordfile 目录. 3:视图-->环境,选择“Power Us

ida idc函数列表全集

下面是函数描述信息中的约定: 'ea' 线性地址 'success' 0表示函数失败:反之为1 'void'表示函数返回的是没有意义的值(总是0) AddBptEx AddBpt AddCodeXref AddConstEx AddEntryPoint AddEnum AddHotkey AddSourceFile AddStrucEx AddStrucMember AltOp Analysis AnalyzeArea AppendFchunk ApplySig AskAddr AskFile

《zw版&#183;delphi与halcon系列原创教程》zw版_THImagex控件函数列表

<zw版·delphi与halcon系列原创教程>zw版_THImagex控件函数列表 Halcon虽然庞大,光HALCONXLib_TLB.pas文件,源码就要7w多行,但核心控件就是两个: THImagex,图像数据控件,v11版,包括488个函数和子程序 THOperatorSetX,操作主接口控件,v11版,包括1929个子程序 以上两大核心控件,已经删除个别delphi内部属性函数,不影响日常使用. 其他控件,基本上,都是为配合两个控件,提供数据类型支持.辅助功能.已经一些特殊应用(

8.1.4 在 F# 中使用函数列表

首先,我们声明一个表示有关客户信息的类型:客户有很多属性,因此,用F# 的记录类型表示最自然的选择,我们在前一章已经看过.清单 8.4 显示了类型声明,和所创建样本客户的代码. 清单 8.4 Client 记录类型和样本值 (F# Interactive) > type Client = { Name : string; Income : int;YearsInJob : int UsesCreditCard : bool;CriminalRecord : bool };; type Clien

LoadRunner中的Web 函数列表

web test LoadRunner fuction_list D:\Program Files (x86)\Mercury Interactive\Mercury LoadRunner\bin>ls -l *.chm -rw-rw-rw-   1 user     group       25893 May 20  2004 FuncRef.chm -rw-rw-rw-   1 user     group       29443 May 20  2004 RPM_Configuration

gcc attribute 初始化函数列表

gcc的__attribute__编译属性有很多子项,用于改变作用对象的特性.这里讨论section子项的作用. __attribute__的section子项使用方式为: ? 1 __attribute__((section("section_name"))) 其作用是将作用的函数或数据放入指定名为"section_name"的段. 看以下程序片段: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2

C++ 链式继承下的虚函数列表

目录 1.虚函数列表的位置 2.虚函数列表的内容 3.链式继承中虚函数列表的内容 ? 注: 虚函数列表 又称为虚表, vtbl , 指向它的指针称为vptr, vs2019中称为__vfptr 操作系统: windows 10 专业版 64位 编译器: Visual Studio 2019 Community ? 1.虚函数列表的位置 结论 编译器一般会保证指向虚函数列表的指针存在于对象实例中最前面的位置 而虚函数列表中的内容, 就是多个函数指针 代码验证: 首先声明一个基类Base和一个派生类