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 ...
随机推荐
- centos 升级内核方法
方法1:rpm安装方式 rpm安装包可以通过这个网站下载: 这个是CentOS6 x64 : http://elrepo.org/linux/kernel/el6/x86_64/RPMS/ 这个是Ce ...
- contents() 查找匹配元素内部所有的子节点(包括文本节点)。如果元素是一个iframe,则查找文档内容
contents() V1.2概述 查找匹配元素内部所有的子节点(包括文本节点).如果元素是一个iframe,则查找文档内容 示例 描述:大理石平台检定规程 查找所有文本节点并加粗 HTML 代码 ...
- BZOJ 2165: 大楼 倍增Floyd
卡了一上午常数,本地13s,可是bzoj 就是过不去~ #include <bits/stdc++.h> #define N 102 #define M 55 #define ll lon ...
- 洛谷P1436 棋盘分割
洛谷题目链接 动态规划: 我们设状态$f[i][j][o][p][k]$表示一个矩形,左上角顶点坐标为$(i,j)$,右下角顶点坐标为$(o,p)$时分割了$k$次,也就是说现在是$k+1$块 我们考 ...
- UVALive 7308 Tom and Jerry 猫抓老鼠 物理题
题目链接: 就是一个老鼠在环上一速度v开始绕环走,一只猫从圆心出发,任意时刻圆心,猫,老鼠三者在一条直线上,且速度也是v,求多久后猫抓到老鼠. #include <cstdio> #inc ...
- [Luogu] 排序机械臂
https://www.luogu.org/problemnew/solution/P3165 预处理 我们会发现一个问题:高度是无序的,而splay中要求有序,否则kth不能正确求解.不需要求高度, ...
- 【java设计模式】-03抽象工厂模式
抽象工厂 简述 抽象工厂模式(Abstract Factory Pattern):提供一个创建一系列相关或相互依赖对象的接口,而无须指定它们具体的类.在抽象工厂模式中,接口是负责创建一个相关对象的工厂 ...
- 【java设计模式】-02工厂模式
工厂模式简述 工厂模式(Factory Pattern)是 Java 中最常用的设计模式之一.这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式. 在工厂模式中,我们在创建对象时不会对客 ...
- django快速实现完整登录系统,把登陆注册串在一起并增加cookie(六)
1.使用之前创建的项目和应用 mysite3 account 2.使用之前的数据库构造 class User(models.Model): username=models.CharField(max ...
- RabbitMQ 简使用案例
第一步导入依赖 : <dependency> <groupId>com.rabbitmq</groupId> <artifactId>amqp-clie ...