声明:原创作品,严禁用于商业目的。 本系列文章适合研发工程师,欢迎和我交流:408797506@qq.com(微信:408797506)
本系列文章将全面剖析以Bcm33xxx芯片开发Cablemodem产品的SDK源码为例,从编译系统到各个功能模块进行分析与探讨。
(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状态的变化,维护两者的统一关系;
DHCP Server在接收到DHCP Request后,首先发送Arp Request验证分配的IP地址是否已被占用,如果1s钟内没有Arp响应则认为该IP可以被分配。流程如下:
DHCP相关的配置,存储在BcmCdpNonVolSettings类的实例中;
系统是BcmEmtaEpsCmDocsisSystem类:
BcmCableHomeDhcpServerIpServiceAppIf在BcmCableHomeCommonApplication中进行初始化,而BcmEpsCmDocsisApplication是BcmCableHomeCommonApplication的子类;
系统初始化时,CreateApplications,然后逐个调用Applications中的Initialize, Pre/PostDriverInitialize, DeInitialize方法;
DHCP Server初始化过程,如下图
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之间的同步;
Dhcp/Client: 实现eRouter Wan DhcpV6 Privisioning的功能;
Dhcp/Server: 提供DhcpV6 Server 管理的Api;DhcpV6ServerSettings及其管理功能;