- 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:
@@ -5,6 +5,7 @@
|
|||||||
//
|
//
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
#include <libsys/libsys.h>
|
#include <libsys/libsys.h>
|
||||||
#include "ethernet.h"
|
#include "ethernet.h"
|
||||||
#include "ipv4.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->htype = TYPE_HW_ETH10;
|
||||||
pDHCP->hlen = 6;
|
pDHCP->hlen = 6;
|
||||||
pDHCP->hops = 0;
|
pDHCP->hops = 0;
|
||||||
pDHCP->secs = 0;
|
pDHCP->secs = clock()/CLOCKS_PER_SEC;
|
||||||
pDHCP->flags = DHCP_FLAGS_BROADCAST;
|
pDHCP->flags = DHCP_FLAGS_BROADCAST;
|
||||||
memcpy(pDHCP->chaddr, mac_addr_src, pDHCP->hlen);
|
memcpy(pDHCP->chaddr, mac_addr_src, pDHCP->hlen);
|
||||||
|
|
||||||
|
|||||||
+11
-7
@@ -338,13 +338,17 @@ int main()
|
|||||||
DHCP *pDHCP;
|
DHCP *pDHCP;
|
||||||
if (dhcp_state == 1)
|
if (dhcp_state == 1)
|
||||||
{
|
{
|
||||||
printf("---------------------------------------------------------------\n");
|
for (int kk=0; kk < 3; kk++)
|
||||||
printf("- Send DHCP Discover ------------------------------------------\n");
|
{
|
||||||
printf("---------------------------------------------------------------\n");
|
printf("---------------------------------------------------------------\n");
|
||||||
Eth_pkt_create(&packet, TYPE_PROTO_IP, eth_myself, eth_bcst);
|
printf("- Send DHCP Discover ------------------------------------------\n");
|
||||||
DHCP_request_send(&packet, DHCP_MSG_DHCPDISCOVER, eth_myself, ip_zero, ip_bcast, NULL);
|
printf("---------------------------------------------------------------\n");
|
||||||
PrintBuffer8((uint8_t*)packet.pkt_buf, 16, packet.size);
|
Eth_pkt_create(&packet, TYPE_PROTO_IP, eth_myself, eth_bcst);
|
||||||
Eth_pkt_send(&packet);
|
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;
|
dhcp_state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user