博通Broadcom SDK源码学习与开发11——Cable Modem DHCP管理
作者:互联网
声明:原创作品,严禁用于商业目的。 本系列文章适合研发工程师,欢迎和我交流:408797506@qq.com(微信:408797506)
本系列文章将全面剖析以Bcm33xxx芯片开发Cablemodem产品的SDK源码为例,从编译系统到各个功能模块进行分析与探讨。
文章目录
本文介绍 Cable Modem 上DHCP相关的功能。
1. DHCP Server概览
(1) DhcpServerSnoop接收DHCP和ARP包,并向DhcpServerThread发送消息:AnnounceDhcpPacket,AnnounceArpPacket;
(2) DhcpServerThread接收到消息,调用DhcpServerIf类解析数据包,管理Timer定时事件;
(3) DhcpServerIf管理DHCP Lease的状态:New, Bound, Zombie,并向BcmCableHomeDhcpServerIpServiceAppIf发送Lease状态变化的事件;
(4) BcmCableHomeDhcpServerIpServiceAppIf将GUI配置的DHCP地址池范围与DHCP Lease建立对应关系,并根据GUI配置的变化和Lease状态的变化,维护两者的统一关系;
1.2 DHCP Request请求包流程
DHCP Server在接收到DHCP Request后,首先发送Arp Request验证分配的IP地址是否已被占用,如果1s钟内没有Arp响应则认为该IP可以被分配。流程如下:
1.2 DHCP SERVER配置过程
DHCP相关的配置,存储在BcmCdpNonVolSettings类的实例中;
2. DHCP SERVER启动过程
2.1 系统类
系统是BcmEmtaEpsCmDocsisSystem类:
BcmCableHomeDhcpServerIpServiceAppIf在BcmCableHomeCommonApplication中进行初始化,而BcmEpsCmDocsisApplication是BcmCableHomeCommonApplication的子类;
2.2 系统初始化
系统初始化时,CreateApplications,然后逐个调用Applications中的Initialize, Pre/PostDriverInitialize, DeInitialize方法;
2.3 DHCP Server初始化
DHCP Server初始化过程,如下图
3. DHCP SERVER相关源码文件
3.1 IpHelpers
Dhcp: 实现如下类:
DhcpPacket, DhcpLeaseSettings, DhcpOptionsRfc2132;
DhcpClientId/DhcpClientIf/DhcpClientLease/DhcpClientSnoop/DhcpClientThread;
DhcpServerIf/DhcpServerLease/DhcpServerSnoop/DhcpServerThread;
DhcpV6:
如DhcpV4,实现DhcpV6 Client/Server 的 If api, Snoop, Thread等实现DhcpV6基本功能的类;
Cdp: 实现SNMP中WanAddrEntryTable, LanAddrEntryTable 与系统Dhcp Lease的同步;
Dhcp/Server: 实现LanAddrEntry 的注册,查找,更新功能;内容包括与Snmp与NonVol存储及CapEntry之间的同步;
3.2 eRouter
Dhcp/Client: 实现eRouter Wan DhcpV6 Privisioning的功能;
Dhcp/Server: 提供DhcpV6 Server 管理的Api;DhcpV6ServerSettings及其管理功能;
4. DHCP GUI设置的过程
- 在GUI -> Basic -> DHCP中同时修改了Starting Local Address, Number of CPEs, Lease Time
- 在Handler中:
2.1 检测到start addr修改了,调用ReconfigureCableHomeDhcpServerService函数进行配置
2.2 检测到cpe nums修改了,调用ReconfigureCableHomeDhcpServerService函数进行配置
2.3 检测到lease time修改了,调用ReconfigureCableHomeDhcpServerService函数进行配置
2.4 Apply后:
2.4.1 在函数ReconfigureDhcpServerService中会调用ReconfigureCableHomeDhcpServerService函数进行配置
2.4.2 在函数HandleLanConfigurationChange中也会调用ReconfigureCableHomeDhcpServerService函数进行配置
标签:11,初始化,Cable,SERVER,源码,Dhcp,DHCP,Server,Lease 来源: https://blog.csdn.net/eryunyong/article/details/122772832