- dhcp: send secs

- test: send burst of 3

git-svn-id: http://moon:8086/svn/mips@216 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2021-11-24 19:58:34 +00:00
parent 96499e4142
commit eb8ff9ad74
2 changed files with 13 additions and 8 deletions
+2 -1
View File
@@ -5,6 +5,7 @@
//
// -------------------------------------------------------------------------
#include <string.h>
#include <time.h>
#include <libsys/libsys.h>
#include "ethernet.h"
#include "ipv4.h"
@@ -32,7 +33,7 @@ void DHCP_request_send(packet_t *pPacket, uint32_t dhcp_msg_type, uint8_t *mac_a
pDHCP->htype = TYPE_HW_ETH10;
pDHCP->hlen = 6;
pDHCP->hops = 0;
pDHCP->secs = 0;
pDHCP->secs = clock()/CLOCKS_PER_SEC;
pDHCP->flags = DHCP_FLAGS_BROADCAST;
memcpy(pDHCP->chaddr, mac_addr_src, pDHCP->hlen);
+11 -7
View File
@@ -338,13 +338,17 @@ int main()
DHCP *pDHCP;
if (dhcp_state == 1)
{
printf("---------------------------------------------------------------\n");
printf("- Send DHCP Discover ------------------------------------------\n");
printf("---------------------------------------------------------------\n");
Eth_pkt_create(&packet, TYPE_PROTO_IP, eth_myself, eth_bcst);
DHCP_request_send(&packet, DHCP_MSG_DHCPDISCOVER, eth_myself, ip_zero, ip_bcast, NULL);
PrintBuffer8((uint8_t*)packet.pkt_buf, 16, packet.size);
Eth_pkt_send(&packet);
for (int kk=0; kk < 3; kk++)
{
printf("---------------------------------------------------------------\n");
printf("- Send DHCP Discover ------------------------------------------\n");
printf("---------------------------------------------------------------\n");
Eth_pkt_create(&packet, TYPE_PROTO_IP, eth_myself, eth_bcst);
DHCP_request_send(&packet, DHCP_MSG_DHCPDISCOVER, eth_myself, ip_zero, ip_bcast, NULL);
PrintBuffer8((uint8_t*)packet.pkt_buf, 16, packet.size);
Eth_pkt_send(&packet);
sleep(3000);
}
dhcp_state = 0;
}