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 mysqli_field_tell() 函数
mysqli_field_tell() 函数返回字段指针的位置. 取得所有字段的字段信息,然后通过 mysqli_field_tell() 取得当前字段并输出字段名称.表格和最大长度: <?ph ...
- git branch/meger step(3)
# update last repositories git pull git log # create yourself repositories base on last repositories ...
- deepin linux安装为知笔记
sudo apt-get install wiznote
- JQuery动画之滑入滑出动画
1. 滑入动画(类似于商店的卷帘门) $(selector).slideDown(speed, 回调函数); 解释: 此语句实现的功能为, 在XX时间内, 下拉动画, 显现元素. 当 slideDow ...
- 百度AI接口调用
创建应用 登录网站 登录www.ai.baidu.com 进入控制台 进入语音技术 创建应用 管理应用 技术文档 SDK开发文档 接口能力 版本更新记录 注意事项 目前本SDK的功能同REST API ...
- Java线程之join
简述 Thread类的join方法用来使main线程进入阻塞状态,进而等待调用join方法的线程执行,join有三个重载方法: public final void join() 使主线程进入阻塞状态, ...
- 2016 Multi-University Training Contest 1 部分题解
第一场多校,出了一题,,没有挂零还算欣慰. 1001,求最小生成树和,确定了最小生成树后任意两点间的距离的最小数学期望.当时就有点矛盾,为什么是求最小的数学期望以及为什么题目给了每条边都不相等的条件. ...
- 利用Apache shiro SimpleHash 加密字符串
1.导入包 import org.apache.shiro.crypto.hash.SimpleHash; 1 2.代码 import org.apache.shiro.crypto.hash.Sim ...
- QList和QVector等容器的区别
QList和QVector等容器的区别. 1.大多数情况下可以用QList.像prepend()和insert()这种操作,通常QList比QVector快的多.这是因为QList是基于index标签 ...
- 配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示: [mysqld] character_set_server=utf8 init_connect='SET NAMES ...