完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用的是和声2.03b。对于我的网络接口,我使用DHCP客户端连同一个回退到一个固定的默认IP地址。通常,当网络接口被初始化或者当它正在进行NETWON和NetUp来改变配置时,它首先尝试通过DHCP获得IP地址。如果它没有得到一个IP,它等待大约10秒,直到它开始使用固定默认IP地址。在此之前,它没有地址,而不是这种行为,我希望网络接口总是可以立即使用固定的默认回退IP地址。然后几秒钟后,如果收到了一个提议,它就应该从DHCP租约地址转换为IP。我可以想到四种方法:方法1——TCPIpH.DHCPyEnable():不使用TCPipPixPixStAcKyNETUP()。然后等待,直到TCPipIsStaskStaseUs()返回SysStasuSuxRead和TCPIpHyStaskNeTestUp(Neth:=)真。之后调用TCPIpH.dHCPyEnable()。(也请参阅TCPIpH.DHCPYEnable()的成功要求是什么?)方法2:TCPIpHyStaskIpdialAlsieIe()或TCPIpHyStaskYNETUP()通常使用TcPIPpNETWorksObjultDHCPUcliton启动标记。然后等待,直到TCPipIsStaskStaseUs()返回SysStasuSuxRead和TCPIpHyStaskNeTestUp(Neth:=)真。之后,调用TCPIPSISTACKNETWorkAddiSsSSET()来设置固定的默认地址。方法3——TCPIpH.DHCPitimeOutt和TCPIpH.DHCPUIITHEFLYTMO:在10到0中更改StRySCONFIG.H(或MHC)中的TCPIpH.DHCPUTIOUT。在StaskIn.c中,它将将TCPIPDHCIPITATA.DHCPTMO设置为TCPIpH.DHCPUTIMOUT。但是,在函数中的DHCP。C中,有一个检查:要么我必须删除那个检查,要么我也必须将TCPIpH.DHCPGiNITHiFieltTMO更改为0。这在DHCPU.Buy.h中定义,我需要编辑。更改后的DHCPTMO导致O.DHCPCHECKRUNFECVER EVER()立即发送TCPIPStAdxAddiSersServEvices(PNETIF、TCPIPSHSTACKADADESRSX Service EXDHCPC、TCPIPPSTACKYADADESRSX Service EVER RUNIORIVER),它设置了固定默认IP。方法4:TCPIpH.DHCPIRealEdvestTimeOutSoT():直接在TCPIpH栈之后SyPrimalIsIZE()或TCPIPPSTACKYNETUP()调用TCPIpH.DHCPIQuestEtTimeOutSuter()。但是,TCPIpH.DHCPIQuestTimeOutSoT()要求IntTMO是一个值,它不是零:因此,这将要求我删除DHCP.c中的IntTMO的检查。更改的DHCPTMO导致O.DHCPCHECKRUNFACKEVER()立即发送一个TCPIPSISTACKADADESServServEvices(PNETIF,TCPIPSYSTACKADADESRSSER)VICEYDHCPC,TCPIPSISTACKADADRESS1 Service EVETIGRUNIORIVER,它设置固定默认IP。问题:-对于每种方法:这个想法是正确的吗?是否缺少一些细节(例如额外的检查)?还是不应该这样工作?-是否有另一种方法使接口立即与固定默认IP地址一起出现?-你会推荐哪种方法,为什么?
以上来自于百度翻译 以下为原文 I'm using HARMony 2.03b. For my network interface I use the DHCP client together with a fallback to a fixed default IP address. Normally when the network interface is initialized or when it is doing a NetDown and NetUp to change the config, it tries first to get an IP address via DHCP. If it doesn't get an IP it waits for about 10 seconds until it starts using the fixed default IP address. Before that, it doesn't have an address. Instead of this behavior I would like to have the network interface always immediately available with the fixed default fallback IP address. And then a few seconds later it should change to the IP from the DHCP lease address if you have received an offer. I can think of four ways of doing this: Method 1 - TCPIP_DHCP_Enable(): Do TCPIP_STACK_Initialize() or TCPIP_STACK_NetUp() without the TCPIP_NETWORK_CONFIG_DHCP_CLIENT_ON startFlag. Then wait until TCPIP_STACK_Status() returns SYS_STATUS_READY and TCPIP_STACK_NetIsUp(netH) == true. And after that call TCPIP_DHCP_Enable(). (see also thread What are the requirements for TCPIP_DHCP_Enable() to succeed? ) Method 2 - TCPIP_STACK_NetworkAddressSet(): Do TCPIP_STACK_Initialize() or TCPIP_STACK_NetUp() normally with the TCPIP_NETWORK_CONFIG_DHCP_CLIENT_ON startFlag. Then wait until TCPIP_STACK_Status() returns SYS_STATUS_READY and TCPIP_STACK_NetIsUp(netH) == true. Directly after that call TCPIP_STACK_NetworkAddressSet() to set the fixed default address. Method 3 - TCPIP_DHCP_TIMEOUT and TCPIP_DHCP_INIT_FAIL_TMO: Change TCPIP_DHCP_TIMEOUT in system_config.h (or MHC) from 10 to 0. In system_init.c it will set tcpipDHCPInitData.dhcpTmo to TCPIP_DHCP_TIMEOUT. However, in dhcp.c in function TCPIP_DHCP_Initialize() there is a check: // use a safe value for the fail timeout pClient->tOpFailTmo = (pDhcpConfig->dhcpTmo < 1) ? TCPIP_DHCP_INIT_FAIL_TMO : (uint16_t)pDhcpConfig->dhcpTmo; Because of this either I would have to remove that check, or I would also have to change TCPIP_DHCP_INIT_FAIL_TMO to 0. This is defined in dhcp_private.h which I would need to edit. The changed dhcpTmo causes _DHCPCheckRunFailEvent() to send out immediately an TCPIP_STACK_AddressServiceEvent(pNetIf, TCPIP_STACK_ADDRESS_SERVICE_DHCPC, TCPIP_STACK_ADDRESS_SERVICE_EVENT_RUN_FAIL), which sets the fixed default IP. Method 4 - TCPIP_DHCP_RequestTimeoutSet(): Directly after TCPIP_STACK_Initialize() or TCPIP_STACK_NetUp() call TCPIP_DHCP_RequestTimeoutSet(). However, TCPIP_DHCP_RequestTimeoutSet() requires initTmo to be a value, which is not zero: bool TCPIP_DHCP_RequestTimeoutSet(TCPIP_NET_HANDLE hNet, uint16_t initTmo, uint16_t dhcpBaseTmo) { TCPIP_NET_IF* pNetIf = _TCPIPStackHandleToNetUp(hNet); if(DHCPClients && pNetIf && initTmo) { DHCP_CLIENT_VARS* pClient = DHCPClients + TCPIP_STACK_NetIxGet(pNetIf); pClient->tOpFailTmo = initTmo; So this would require me to remove the check for initTmo in dhcp.c. The changed dhcpTmo causes _DHCPCheckRunFailEvent() to send out immediately an TCPIP_STACK_AddressServiceEvent(pNetIf, TCPIP_STACK_ADDRESS_SERVICE_DHCPC, TCPIP_STACK_ADDRESS_SERVICE_EVENT_RUN_FAIL), which sets the fixed default IP. Questions: - For each of the methods: Is the idea correct? Are some details (e.g. additional checks) missing? Or is it not supposed to work like that? - Is there another method to make the interface come up immediately with the fixed default IP address? - Which of the methods would you recommend and why? |
|
相关推荐
3个回答
|
|
对于您所需要的,我建议使用方法1:启动接口而不启动DHCP(即FravaTcPIP.NETWorksObjultDHCPEclipse未设置)。一旦接口准备就绪,即TCPIPpStaskNeReRead()返回true(这将发生得相当快),启动DHCP客户端。这将给你所需要的,这就是预期的行为。= 0。行为类似于许多系统(Linux,Windows):如果启动DHCP的接口,则必须等待,直到获得租约或超时过期。使用StimeTimeOut==0意味着启动DHCP而不等待DHCP服务器,这实际上是从没有DHCP开始。请让我们知道这种方法是否适用于您,如果有任何问题。
以上来自于百度翻译 以下为原文 For what you need I'd recommend using the method #1: start the interface without starting DHCP (i.e. the flag TCPIP_NETWORK_CONFIG_DHCP_CLIENT_ON not set). Once the interface is ready i.e. TCPIP_STACK_NetIsReady() returns true (which will happen fairly fast), start the DHCP client. This will give you what you need and this is the intended behavior. Those timeouts need to be != 0. The behavior is similar to many systems (Linux, Windows): if you start the interface with DHCP you have to wait until a lease is obtained or the timeout expired. Using a start timeout == 0 means start DHCP without waiting for DHCP server, which is practically start with no DHCP. Please let us know if this approach works for you and if there are any issues. |
|
|
|
谢谢你的回答,雷纳德。这对我来说是有效的,我已经开始实施方法1。几秒钟(超时机制)在TCPIpHistaKyNETUP()之后,OrtPIPPyStaskIpIrimalIZE()启动DHCP。到目前为止,我只是通过检查TCPIPSISTACKEngItSub()来实现它,而不是由您建议的OffTCPIPSISTACKEnTiSRead()。我现在把它改成了USECTPIPSTACKEnTiReRead()。两个都为我工作。在超时之后,而TCPIpH.DHCCPIISEnabDeEE()返回false时,我尝试重复TCPIpH.DHCPyEnable()。详细地说,我检查了5个条件:堆栈已就绪(TCPIPSHSTACKSTATUS())ReutsSysStasuSuxRead已准备好网络接口(TCPIPPSTACKE-NETISRADYY()返回true)我的用户已经配置了DHCP(在我自己的设置)。DHCP还没有运行(TCPIPPH DHCPUISISABLE(NETH)返回false)我的明星T超时已经发生,如果它们都满足了,那么我调用CaltTCPIpDHCPUnabl(NETH)。即使TCPIpH.DHCPGEnable()会失败,实现也会重复它,直到它运行。但到目前为止,我从来没有使用这个实现SuncCPIPdHCPyEnable()失败(返回false)。我会在调试日志中看到它的。
以上来自于百度翻译 以下为原文 Thanks for the response, rainad. This works for me. I have already started to implement method #1. A few seconds (by a timeout mechanism) after TCPIP_STACK_NetUp() or TCPIP_STACK_Initialize() I'm starting DHCP. So far I had implemented it only with checking for TCPIP_STACK_NetIsUp() instead of TCPIP_STACK_NetIsReady() as suggested by you. I changed it now to use TCPIP_STACK_NetIsReady(). Both works for me. After my timeout occurred and while TCPIP_DHCP_IsEnabled() returns false, I try repeatedly TCPIP_DHCP_Enable(). In detail, I check for 5 conditions:
|
|
|
|
很高兴听到它对你有用。您描述的指令序列看起来不错。是的,如果用静态IP地址启动接口,TCPIpH.DHCPYNEABLE()不应该失败。请让我们知道是否还有其他问题。
以上来自于百度翻译 以下为原文 Good to hear it's working for you. The sequence of instructions that you describe looks good to me. Yes, TCPIP_DHCP_Enable() shouldn't fail if the interface was started with static IP address. Please let us know if any other issues. |
|
|
|
只有小组成员才能发言,加入小组>>
5139 浏览 9 评论
1987 浏览 8 评论
1917 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3158 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2215 浏览 5 评论
708浏览 1评论
598浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
480浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
609浏览 0评论
505浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-8 15:31 , Processed in 1.347157 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号