CWMP开源代码研究——git代码工程
原创作品,转载请注明出处,严禁非法转载。如有错误,请留言!
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代码工程的更多相关文章
- oschina(开源中国)的Git代码托管平台使用教程
oschina(开源中国)的Git代码托管平台使用教程 第一章 平台介绍 一. Git@OSC简介 开源中国的Git@OSC一个账号最多可以创建1000个项目,包含公有和私有,开源中国代码托管地址:h ...
- 一段markdown编辑器代码研究
一段markdown编辑器代码研究 说明 代码在 https://github.com/dukeofharen/markdown-editor 之所以选择这个来分析是一方面是因为它的代码结构比较简单, ...
- CWMP开源代码研究1——开篇之作
原创作品,转载请注明出处,严禁非法转载.如有错误,请留言! email:40879506@qq.com 声明:本系列涉及的开源程序代码学习和研究,严禁用于商业目的. 如有任何问题,欢迎和我交流.(企鹅 ...
- 用开源中国(oschina)Git管理代码(整合IntelliJ 13.1.5)
简介 开源中国提供了Git服务(地址:http://git.oschina.net/),在速度上比国外的github要快很多.使用了一段时间,感觉很不错.oschina git提供了演示平台,可以运行 ...
- 开源Git代码托管平台
开源Git代码托管平台主要参考有以下4个: 1.GitHub 很多开源项目都来自GitHub,但是GitHub只能新建公开的Git仓库,私有 仓库要收费.GitHub地址:https://github ...
- git 代码托管使用方法
Git代码托管 1 准备材料 在coding,github这些代码托管网站上申请一个账户. Linux平台什么需要一个git,如ubuntu 需要 $ sudo apt-get install git ...
- 微软打造了全球最大的Git代码库
丹棱君有话说:今年 2 月,微软宣布将用 Git 管理 Windows 源代码.随后,Visual Studio 宣布开发 “Git 虚拟文件系统(GVFS)”,并将在终极项目和超大型团队中推行 Gi ...
- 探讨 Git 代码托管平台的若干问题
关于 Git 版本控制软件种类繁多,维基百科收录的最早的版本控制系统是 1972 年贝尔实验室开发的 Source Code Control System.1986 年 Concurrent Vers ...
- 探讨 Git 代码托管平台的若干问题 - 2019 版
关于 Git 版本控制软件种类繁多,维基百科收录的最早的版本控制系统是 1972 年贝尔实验室开发的 Source Code Control System.1986 年 Concurrent Vers ...
随机推荐
- HDU - 5528Count a * b 数学公式推导
HDU - 5528Count a * b 照着这个写的,忘了哪个大佬博客里的了, 但很多初学者,像我一样可能不懂其中一些符号的意义,还有为什么可以这样推导,所以我自己又推导了一下,并用自己的观点解释 ...
- plotly绘图
import plotly.plotly as plt import plotly.offline as pltoff from plotly.graph_objs import * # 生成折线图 ...
- Ubuntu 16.04 一键安装P4开发环境记录
写在最前 P4开发环境安装可采用陈翔同学的一键安装脚本:p4Installer p4c-bm是P4-14的编译器,p4c是现在主流P4-16的编译器,bmv2是支持P4运行的软件交换机 系统环境 在安 ...
- C/C++程序基础-标准头文件的结构
1:标准头文件有如下结构,请解释. #ifndef _INCvxWorksh #define _INCvxWorksh#ifdef _cplusplus extern "C"{ # ...
- DDCTF-2019-writeup(7web+5misc)
一年前第一次参加了DDCTF,再次参加简单记录下web与misc的writeup Web Web1 滴~ 1.jpg参数可以包含文件,参数经过两次base64和一次16进制编码,将index.php编 ...
- Int和Integer(课上测试)
截图 第一段代码: 第二段代码: 两段代码出现不同结果的原因:Integer类型的取值范围为-128至128之间,小于128的数(图1)为正确,大于128的数(图2)为错误
- LeetCode 最长公共前缀(探索字节跳动)
题目描述 编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". 示例 1: 输入: ["flower","flow ...
- qt 元对象系统
元对象系统 Qt中的元对象系统是用来处理对象间通讯的信号/槽机制.运行时的类型信息和 动态属性系统. 它基于下列三类: QObject类: 类声明中的私有段中的Q_OBJECT宏: 元对象编译器(mo ...
- mysql:启动服务时遇到的问题
1.cmd命令: 在切换路径时,如果要切到另外一个磁盘,比如从C盘切到E盘,命令如下: cd /d 你要切换的路径 2.错误:“服务名无效” 问题原因:mysql服务没有安装.(参考:https:// ...
- moogdb操作
本文转载自 https://my.oschina.net/kakakaka/blog/347954 首先,下载mongdb对JAVA的支持,点击这里下载驱动包,这里博主下载的是2.10.1版. mon ...