当前位置: 首页 > news >正文

印度尼西亚网站后缀网络营销总结及体会

印度尼西亚网站后缀,网络营销总结及体会,书签制作简单漂亮图片,6月份去哪里旅游最好目录 参考文章:一、libnet库下载二、libnet库交叉编译安装三、应用程序交叉编译四、Ubuntu系统安装 libnet(非交叉编译)五、libnet使用六、开发板上测试 参考文章: libnet库下载、编译、示例、文档Linux 网络编程—— libnet 使用…

目录

  • 参考文章:
  • 一、libnet库下载
  • 二、libnet库交叉编译安装
  • 三、应用程序交叉编译
  • 四、Ubuntu系统安装 libnet(非交叉编译)
  • 五、libnet使用
  • 六、开发板上测试

参考文章:

  1. libnet库下载、编译、示例、文档
  2. Linux 网络编程—— libnet 使用指南
  3. libnet 函数列表

一、libnet库下载

  1. https://github.com/libnet/libnet/releases

二、libnet库交叉编译安装

  1. 配置交叉编译环境
    普通用户和root用户下都需要配置

  2. 从 GitHub下载最新版本 libnet-master.tar.gz 或 libnet-1.2.tar.gz,解压缩到当前目录:

     tar -xzvf ./libnet-master.tar.gz -C ./ 
    
  3. 使用 ./autogen.sh 生成 configure 脚本
    需要的工具套件:autoconf (>=2.69)、automake (>=1.14)、libtool (>=2.4.2)
    (1) 安装工具:

    sudo apt install autoconf automake libtool
    

    (2) 进入libnet-master目录,生成 configure 脚本

    cd libnet-master/
    
    ./autogen.sh
    

    说明:如果下载的是 Releases版本(如:libnet-1.2.tar.gz),不需要此步骤。

  4. 配置安装目录和交叉编译环境

    ./configure --prefix=xxx/xxx/install/ --host=arm-linux-gnueabihf
    

    配置结果:在这里插入图片描述

  5. 编译

    make
    
  6. 安装

    sudo make install
    

    安装结果:在这里插入图片描述
    在 install/lib/ 目录下生成如下文件:
    在这里插入图片描述

  7. 错误说明
    如果报如下错误,是因为root用户下未配置交叉编译环境,配置后即可
    ../libtool: line 1719: arm-linux-gnueabihf-ranlib: command not found

  8. cd 进入 install 安装目录,打包lib目录下动态库文件(libnet.so libnet.so.9 libnet.so.9.0.0)

    tar -zcvf libnet-1.2-install.tar.gz -C ./lib libnet.so libnet.so.9 libnet.so.9.0.0
    
  9. 将 libnet-1.2-install.tar.gz 压缩包拷贝到开发板上,解压
    新建文件夹:/usr/local/lib/libnet , 然后解压到该文件夹中

    sudo mkdir /usr/local/lib/libnet 
    
    sudo tar -zxvf libnet-1.2-install.tar.gz -C /usr/local/lib/libnet
    
  10. 开发板上添加库文件搜索路径
    打开ld.so.conf文件

    sudo vi /etc/ld.so.conf.d/libc.conf
    

    在 /etc/ld.so.conf 文件中添加库的搜索路径

    /usr/local/lib/libnet //根据自己的库路径添加
    

    然后 ldconfig 生成/etc/ld.so.cache,ldconfig -v 查看

    ldconfig
    

三、应用程序交叉编译

交叉编译应用程序:需要加 -lnet 选项,并指定头文件及动态库路径

arm-linux-gnueabihf-gcc ./libnet_test.c -o ./libnet_test -lnet -I/xxx/include/ -L/xxx/lib/
  1. 查看头文件及动态库路径
    Libnet 安装为一个库和一组包含文件。在您的程序中使用的主要包含文件是:

    #include <libnet.h>
    

    要获得头文件和库文件的正确搜索路径,请使用标准pkg-config工具:

    pkg-config --libs --static --cflags libnet 
    

    结果:

    -I/usr/local/include -L/usr/local/lib -lnet
    

    /usr/local/此处显示的路径为默认值。configure时,可以使用 --prefix 选项指定不同的路径。

  2. 编译需要添加 -lnet 选项

    gcc test.c -o test -lnet
    
  3. 基于 GNU autotools 的项目,请在以下内容中使用configure.ac

    # Check for required libraries
    PKG_CHECK_MODULES([libnet], [libnet >= 1.2])
    

    并在您的Makefile.am

    proggy_CFLAGS = $(libnet_CFLAGS)
    proggy_LDADD  = $(libnet_LIBS)
    

四、Ubuntu系统安装 libnet(非交叉编译)

  1. libnet 的安装

    sudo apt-get install libnet1-dev
    
  2. 应用程序编译

    gcc libnet_test.c -o libnet_test -lnet
    

五、libnet使用

参考:

  1. Linux 网络编程—— libnet 使用指南
  2. libnet 函数列表

六、开发板上测试

使用libnet库发送udp包测试程序(libnet_test.c):

#include <stdio.h>  
#include <stdlib.h>  
#include <string.h>  
#include <unistd.h>  
#include <libnet.h>  int main(int argc, char *argv[])  
{  char send_msg[1000] = "";  char err_buf[100] = "";  libnet_t *lib_net = NULL;  int lens = 0;  libnet_ptag_t lib_t = 0;  unsigned char src_mac[6] = {0x00,0x0a,0x35,0x00,0x10,0x01}; //发送者网卡地址unsigned char dst_mac[6] = {0xa4,0xbb,0x6d,0xc3,0x1d,0xce}; //接收者网卡地址char *src_ip_str = "192.168.10.10"; //源主机IP地址  char *dst_ip_str = "192.168.10.201"; //目的主机IP地址  unsigned long src_ip,dst_ip = 0;  lens = sprintf(send_msg, "%s", "this is for the udp test");lib_net = libnet_init(LIBNET_LINK_ADV, "eth0", err_buf); //初始化  if(NULL == lib_net)  {  perror("libnet_init");  exit(-1);  }  src_ip = libnet_name2addr4(lib_net,src_ip_str,LIBNET_RESOLVE); //将字符串类型的ip转换为顺序网络字节流  dst_ip = libnet_name2addr4(lib_net,dst_ip_str,LIBNET_RESOLVE);  lib_t = libnet_build_udp( //构造udp数据包  8080,  8080,  8+lens,  0,  send_msg,  lens,  lib_net,  0  );  lib_t = libnet_build_ipv4( //构造ip数据包  20+8+lens,  0,  500,  0,  10,  17,  0,  src_ip,  dst_ip,  NULL,  0,  lib_net,  0  );  lib_t = libnet_build_ethernet( //构造以太网数据包  (u_int8_t *)dst_mac,  (u_int8_t *)src_mac,  0x800,// 或者,ETHERTYPE_IP  NULL,0,  lib_net,  0  );  int res = 0;  res = libnet_write(lib_net); //发送数据包  if(-1 == res)  {  perror("libnet_write");  exit(-1);  }  libnet_destroy(lib_net); //销毁资源  printf("----ok-----\n");  return 0;  }  

交叉编译:

arm-linux-gnueabihf-gcc ./libnet_test.c -o ./libnet_test -lnet -I/home/osrc/Projects/tools/libnet/install/include/ -L/home/osrc/Projects/tools/libnet/install/lib

在开发板上运行,需要root账户权限

sudo ./libnet_test

在PC机上使用网络调试助手接收udp数据,结果如下:
在这里插入图片描述

http://www.15wanjia.com/news/8322.html

相关文章:

  • 可以免费做会计题的网站网站一级域名和二级域名区别
  • 安徽区块链虚拟币网站开发方案今日重庆重要消息
  • 免费建设dj网站百度搜索量怎么查
  • 刘家窑做网站头条号权重查询
  • wordpress拿站企业宣传册
  • 2023中央农村工作会议南昌seo外包公司
  • 首都规划建设委员会办公室网站长沙seo网络推广
  • 溧水区住房城乡建设局网站西安霸屏推广
  • 做外贸的数据网站有哪些沈阳seo技术
  • 网站开发费用记账百度平台推广该怎么做
  • 柳河县做网站百度产品推广怎么收费
  • 我在日本做动画视频网站51网站统计
  • 公司网站后台管理营销培训课程有哪些
  • 新疆营销型网站建设自媒体十大平台
  • 做sgs认证公司网站国内新闻最新消息简短
  • 做优秀网站学新媒体运营最好的培训学校
  • 用ps做网站网页第三波疫情将全面大爆发
  • 中国十大网站建设企业站长工具网站
  • 永州网站建设企业独立站seo建站系统
  • 淘宝客app定制seo计费系统源码
  • 太原网站制作在线青岛网站建设公司
  • 做的网站有营销效果吗广州白云区最新信息
  • 高端网站官网企业网站设计论文
  • 成都企业网站建设 四川冠辰科技个人主页网页设计
  • 北京自己怎样做网站如何修改百度上面的门店号码
  • 社区类网站开发廊坊seo推广公司
  • 新安县做网站成人英语培训
  • 做网站域名还重要吗产品推广策划方案怎么做
  • 电子商务网站开发形式选择有没有自动排名的软件
  • 网站开发设计选题背景经典软文