原创作品,转载请注明出处,严禁非法转载。如有错误,请留言!

email:40879506@qq.com

声明:本系列涉及的开源程序代码学习和研究,严禁用于商业目的。 如有任何问题,欢迎和我交流。(企鹅号:408797506)

应某位网友的要求,现在把第七篇(CWMP开源代码研究7——cwmp移植)重新整理代码,放在了github上,开放了除协议栈核心代码之外的所有代码。

github工程代码路径: https://github.com/eryunyong/DataModel

一. 环境
1.GNU/Linux Centos6.5操作系统(x86)
2.gcc

二. 下载代码

git  clone https://github.com/eryunyong/DataModel.git
三. 依赖包的安装
1. expat-2.1.0
1)进入目录
  cd dependence_pkt/expat-2.1.0/

2)创建安装的路径名tmp

mkdir tmp
3) 配置安装路径到tmp
  ./configure  --prefix=$PWD/tmp(如果是本地linux系统,只需要./configure)
4) 安装
  make;make install
5)拷贝tmp目录下相应的文件到需要的位置

(比如我的环境:cp tmp/include/expat* /usr/local/include/ -rf; cp tmp/lib/libexpat.so.1.6.0 /usr/local/lib/ -rf;ln -sf /usr/local/lib/libexpat.so.1.6.0 /usr/local/lib/libexpat.so)

2. curl-7.21.4

这里介绍源码包安装的方式,也可以使用apt-get install 或者yum install命令在线安装。

因为curl的安装包依赖于openssl以及在CWMP中要用到SSL证书的HTTPS安全方式,所以提前先安装上openssl
1)下载安装包openssl-1.0.2.tar.gz,路径http://distfiles.macports.org/openssl/
2)解压
  tar -xvf openssl-1.0.2.tar.gz
3) 进入目录
  cd openssl-1.0.2;mkdir tmp;mkdir tmp/openssl
4) 配置安装路径和配置文件路径
  ./config shared --prefix=$PWD/tmp --openssldir=$PWD/tmp/openssl(如果是本地linux系统,只需要./config shared)
5)安装
  make;make install
6) 拷贝tmp目录下相应的文件到需要的位置(参考前面)

安装curl

1)进入目录
  cd dependence_pkt/curl-7.21.4/

2)创建安装的路径名tmp

mkdir tmp
3) 配置安装路径到tmp
  ./configure --without-ssl  --prefix=$PWD/tmp(如果是本地linux系统,只需要./configure)
4) 安装
  make;make install
5)拷贝tmp目录下相应的文件到需要的位置

(比如我的环境:cp tmp/include/curl /usr/local/include/ -rf; cp tmp/lib/libcurl.so.4.2.0 /usr/local/lib/;ln -sf /usr/local/lib/libcurl.so.4.2.0 /usr/local/lib/libcurl.so)

四. 编译并安装

阅读Makefile,从中可以看出分步安装的步骤所执行的make命令:1. make uci 2. make uci_install 3. make device 4. make device_install 5. make cwmp_install(只提供x86的执行程序)

 ~/git_DataModel# cat Makefile
include Makefile.inc #CFLAGS += -D_GNU_SOURCE
CFLAGS += -I $(shell pwd)/include LDFLAGS += -luci -lcurl export CFLAGS LDFLAGS TARGET := device.so obj-y += src/ uci :
#############. make uci.so #####################
make -C $(shell pwd)/uci-0.1/ uci_install :
#############. install uci library and include and bin files #####################
cp $(shell pwd)/uci-0.1/libuci.so.0.1 /usr/lib/libuci.so.0.1
ln -sf /usr/lib/libuci.so.0.1 /usr/lib/libuci.so
cp $(shell pwd)/uci-0.1/uci.h $(shell pwd)/uci-0.1/uci_config.h $(shell pwd)/uci-0.1/uci_internal.h /usr/include/
cp $(shell pwd)/uci-0.1/uci /usr/bin/
device :
#############. make device.so #####################
make -C $(shell pwd)/ -f $(TOPDIR)/Makefile.build
$(CC) -o $(TARGET) -shared -fPIC built-in.o $(LDFLAGS) device_install:
#######. install device library and config for tr069 running test ##################
cp etc_config/* /etc/config/ -rf
cp device.so /usr/lib/
cwmp_install:
#######5. install cwmp core ##################
cp cwmp_x86/cwmp /usr/bin/ -rf
cp tr069.sh /sbin/tr069 -rf .PHONY: clean
clean:
rm -f $(shell find -name "*.o")
rm -f $(shell find -name "*.d")
rm -f $(TARGET)
make clean -C $(shell pwd)/uci-0.1/ .PHONY: distclean
distclean:
##########1. clear device and uci make #################
rm -f $(shell find -name "*.o")
rm -f $(shell find -name "*.d")
rm -f $(TARGET)
make clean -C $(shell pwd)/uci-0.1/
##########2. remove uci install #################
rm -rf /usr/lib/libuci.so.0.1 /usr/lib/libuci.so
rm -rf /usr/include/uci_internal.h /usr/include/uci_config.h /usr/include/uci.h
rm -rf /usr/bin/uci
##########3. remove device install #################
rm -rf /etc/config/*
rm -rf /usr/lib/device.so
##########4. remove cwmp core install #################
rm -rf /usr/bin/cwmp

此外,在git_DataModel目录下可以看到我已经写好了安装的脚本

 ~/git_DataModel# cat build_debug.sh
#!/bin/sh
make uci
make uci_install
make device
make device_install
make cwmp_install
#cp tr069.sh /sbin/tr069 -rf #make clean
#make distclean

五. 卸载

执行make distclean清除所有编译和安装程序

六. 测试

程序启动命令:cwmp -F /etc/config/cwmpd.conf &

或者使用脚本 tr069 start命令开启测试程序。

查看log的方法:tail -f /tmp/cwmp.log

 -- ::44.121 [DBUG] [Device] [device.c:get_param_by_name()] [] name=InternetGatewayDevice.WANDevice..WANConnectionDevice..WANIPConnection..ExternalIPAddress
-- ::44.122 [ERRO] [EB-MIG] [WANIPConnection.c:CpeGetWANIPConnection_ExternalIPAddress()] [] TODO.............support yourself WAN interface ip addr
-- ::44.122 [DBUG] [Event] [event.c:event_loop()] [] WAN IP=192.168.20.12
-- ::47.142 [DBUG] [Event] [event.c:event_loop()] [] resp=
-- ::47.143 [INFO] [Event] [event.c:event_loop()] [] recv=<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cwmp="urn:dslforum-org:cwmp-1-0"><SOAP-ENV:Header><cwmp:ID SOAP-ENV:mustUnderstand="">-</cwmp:ID></SOAP-ENV:Header><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><cwmp:GetParameterValues><ParameterNames SOAP-ENC:arrayType="xsd:string[1]"><string xsi:type="xsd:string">InternetGatewayDevice.ObjTest..TestEnabled</string></ParameterNames></cwmp:GetParameterValues></SOAP-ENV:Body></SOAP-ENV:Envelope>

从log看到错误的一行:[ERRO] [EB-MIG] [WANIPConnection.c:CpeGetWANIPConnection_ExternalIPAddress()] [0494] TODO.............support yourself WAN interface ip addr

意味着你需要根据自己的实际网卡地址修改WAN侧(设备或者CPE)的ip地址。

七. 根据实际网卡地址修改CPE地址

修改配置文件option cpe_ipaddr '192.168.20.12'

 git_DataModel/etc_config# vi /etc/config/cpeagent 

 config cpeagent tr069
option acsurl 'http://192.168.4.11:9090/ACS-server/ACS'
option cpeport ''
option cpe_ipaddr '192.168.20.12'
option auth ''
option cpeauth_user 'test'
option cpeauth_pass 'test'
option acsauth_user 'test'
option acsauth_pass 'test'
option enable ''
option acs_status ''
option inform_status ''
option bs_status ''
option cwmp_status '' config cpeagent managementserver
option PeriodicInformEnable ''
option PeriodicInformInterval ''
option PeriodicInformTime '' config cpeagent inform
option bootstarp ''

八. 交叉编译

  git工程只提供了X86平台的代码或者程序。参考上述步骤,应该很容易移植成功。
  如需交叉编译或者其他平台的移植,请提供交叉编译工具链,我会把编译后的cwmp 协议栈的程序发给你。

CWMP开源代码研究——git代码工程的更多相关文章

  1. oschina(开源中国)的Git代码托管平台使用教程

    oschina(开源中国)的Git代码托管平台使用教程 第一章 平台介绍 一. Git@OSC简介 开源中国的Git@OSC一个账号最多可以创建1000个项目,包含公有和私有,开源中国代码托管地址:h ...

  2. 一段markdown编辑器代码研究

    一段markdown编辑器代码研究 说明 代码在 https://github.com/dukeofharen/markdown-editor 之所以选择这个来分析是一方面是因为它的代码结构比较简单, ...

  3. CWMP开源代码研究1——开篇之作

    原创作品,转载请注明出处,严禁非法转载.如有错误,请留言! email:40879506@qq.com 声明:本系列涉及的开源程序代码学习和研究,严禁用于商业目的. 如有任何问题,欢迎和我交流.(企鹅 ...

  4. 用开源中国(oschina)Git管理代码(整合IntelliJ 13.1.5)

    简介 开源中国提供了Git服务(地址:http://git.oschina.net/),在速度上比国外的github要快很多.使用了一段时间,感觉很不错.oschina git提供了演示平台,可以运行 ...

  5. 开源Git代码托管平台

    开源Git代码托管平台主要参考有以下4个: 1.GitHub 很多开源项目都来自GitHub,但是GitHub只能新建公开的Git仓库,私有 仓库要收费.GitHub地址:https://github ...

  6. git 代码托管使用方法

    Git代码托管 1 准备材料 在coding,github这些代码托管网站上申请一个账户. Linux平台什么需要一个git,如ubuntu 需要 $ sudo apt-get install git ...

  7. 微软打造了全球最大的Git代码库

    丹棱君有话说:今年 2 月,微软宣布将用 Git 管理 Windows 源代码.随后,Visual Studio 宣布开发 “Git 虚拟文件系统(GVFS)”,并将在终极项目和超大型团队中推行 Gi ...

  8. 探讨 Git 代码托管平台的若干问题

    关于 Git 版本控制软件种类繁多,维基百科收录的最早的版本控制系统是 1972 年贝尔实验室开发的 Source Code Control System.1986 年 Concurrent Vers ...

  9. 探讨 Git 代码托管平台的若干问题 - 2019 版

    关于 Git 版本控制软件种类繁多,维基百科收录的最早的版本控制系统是 1972 年贝尔实验室开发的 Source Code Control System.1986 年 Concurrent Vers ...

随机推荐

  1. 权势二进制(51Nod 1413)

    一个十进制整数被叫做权势二进制,当他的十进制表示的时候只由0或1组成.例如0,1,101,110011都是权势二进制而2,12,900不是. 当给定一个n的时候,计算一下最少要多少个权势二进制相加才能 ...

  2. 0和5 (51Nod)

    小K手中有n张牌,每张牌上有一个一位数的数,这个字数不是0就是5.小K从这些牌在抽出任意张(不能抽0张),排成一行这样就组成了一个数.使得这个数尽可能大,而且可以被90整除. 注意: 1.这个数没有前 ...

  3. 用python来抓取“煎蛋网”上面的美女图片,尺度很大哦!哈哈

    所用Python环境为:python 3.3.2   用到的库为:urllib.request    re 废话不多说,先上代码: import urllib.request import re #获 ...

  4. codeforces#1159D. The minimal unique substring(打表找规律+构造)

    题目链接: https://codeforces.com/contest/1159/problem/D 题意: 构造一个长度为$n$的$01$串,最小特殊连续字串的长度为$k$ 也就是,存在最小的$k ...

  5. CodeForces 631D Messenger —— (kmp的应用)

    这题是一个kmp的应用,思路是有,但是代码实现能力太弱,细节考虑不全,敲了很长时间才AC.. 题意:字符串用如下的方法表示,例如aaabbbbcc表示为3-a,4-b,2-c.那么问t串在s串中出现了 ...

  6. Elasticsearch删除数据之_delete_by_query

    es参考版本:elasticsearch:5.5 _delete_by_query会删除所有query语句匹配上的文档,用法如下: curl -X POST "localhost:9200/ ...

  7. 在CUDA8.0下指定位置编译安装OpenCV3.1.0来实现GPU加速(Compiling OpenCV3.1.0 with CUDA8.0 support)

    在CUDA8.0下指定位置编译安装OpenCV3.1.0 一.本人电脑配置:ubuntu 14.04, NVIDIA GTX1060. 二.编译OpenCV3.1.0前,读者需要成功安装CUDA8.0 ...

  8. 预处理、const、static与sizeof-内联函数与宏有什么区别

    1:二者的区别如下: (1)内联函数在编译时展开,宏在预编译时展开. (2)在编译的时候,内联函数可以直接被镶嵌到目标代码中,而宏只是一个简单的文本替换. (3)内联函数可以完成诸如类型检测.语句是否 ...

  9. windows服务器安装nodejs实现自动计划

    直接官网打开:https://nodejs.org/en/ 下载相应的系统nodejs版本直接安装后,通过命令行window+r    输入node + web(目录)+\pubils\app.js  ...

  10. Python可变参数函数用法详解

    来自:http://c.biancheng.net/view/2257.html 很多编程语言都允许定义个数可变的参数,这样可以在调用函数时传入任意多个参数.Python 当然也不例外,Python ...