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 ...
随机推荐
- PHP实现yii项目转发有哪几种方法?
header("location: index.php"); 如果header后面有代码, 会执行, 如果不想执行, 则加上exit;或者die();等, 应该可以应用到yii项目 ...
- BZOJ 2440 [中山市选2011]完全平方数 二分+容斥
直接筛$\mu$?+爆算?再不行筛素数再筛个数?但不就是$\mu^2$的前缀和吗? 放...怕不是数论白学了$qwq$ 思路:二分+容斥 提交:两次(康了题解) 题解: 首先答案满足二分性质(递增), ...
- springboot热部署如果不行
如果热部署不行先看一眼 Project——>Build Automatically 看这个有没有打对勾,这是热部署的依赖
- 我爱网络流之最大流Dinic
直接上大佬博客: Dinic算法详解及实现来自小菲进修中 Dinic算法(研究总结,网络流)来自SYCstudio 模板步骤: 第一步,先bfs把图划分成分成分层图网络 第二步,dfs多次找增广路 当 ...
- [JZOJ6347]:ZYB玩字符串(DP+记忆化搜索)
题目描述 $ZYB$获得了一个神秘的非空字符串$p$. 初始时,串$S$是空的. $ZYB$会执行若干次这样的操作: $1.$选取$S$中的一个任意的位置(可以是最前面或者最后面) $2.$在这个位置 ...
- 数据结构-用C++实现一个二叉树,递归方法中序遍历
1:二叉排序树,又称二叉树.其定义为:二叉排序树或者空树,或者是满足如下性质的二叉树. (1)若它的左子树非空,则左子树上所有节点的值均小于根节点的值. (2)若它的右子树非空,则右子树上所有节点的值 ...
- Qt串口通信专题教程
查看以前的教程:Qt编写串口通信程序全程图文讲解 查看Wincom和Lincom介绍:Qt跨平台串口通信软件Wincom与Lincom 下载软件,文档和源码:资源下载 ——————————————20 ...
- react-hook设定定时器的方法
const useInterval = (callback, delay) => { const savedCallback = useRef(); // 保存新回调 useEffect(() ...
- python pip 使用
一.修改 pip 源 Windows 在用户目录下新建 pip\pip.ini 文件,如:C:\Users\Administrator\pip\pip.ini [global] index-url = ...
- leetcode-hard-ListNode-Copy List with Random Pointer-NO
mycode 报错:Node with val 1 was not copied but a reference to the original one. 其实我并没有弄懂对于ListNode而言咋样 ...