DHCP processing semaphore added
This commit is contained in:
parent
b45e8cd81d
commit
025f6d09b9
@ -16,6 +16,7 @@ static struct {
|
||||
cbd desc;
|
||||
uint32_t tranId;
|
||||
EthInterface *intf;
|
||||
ETHLIB_OS_SEM_TYPE procSem;
|
||||
} s;
|
||||
|
||||
static const uint8_t DHCP_MAGIC_COOKIE[] = {99, 130, 83, 99};
|
||||
@ -248,6 +249,8 @@ void dhcp_request(ip4_addr reqAddr, ip4_addr dhcpServerAddr) {
|
||||
}
|
||||
|
||||
static void dhcp_process(DhcpProps *props, DhcpOption *opts) {
|
||||
ETHLIB_OS_SEM_WAIT(&s.procSem); // LOCK!
|
||||
|
||||
switch (s.state) {
|
||||
case DHCP_INIT:
|
||||
dhcp_discover(); // send discover message
|
||||
@ -309,6 +312,8 @@ static void dhcp_process(DhcpProps *props, DhcpOption *opts) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ETHLIB_OS_SEM_POST(&s.procSem); // RELEASE!
|
||||
}
|
||||
|
||||
static int dhcp_resp_cb(const Pckt *pckt, PcktSieveLayerTag tag) {
|
||||
@ -329,6 +334,8 @@ void dhcp_start() {
|
||||
}
|
||||
|
||||
void dhcp_initiate(EthInterface *intf) {
|
||||
ETHLIB_OS_SEM_CREATE(&s.procSem);
|
||||
ETHLIB_OS_SEM_POST(&s.procSem);
|
||||
s.state = DHCP_INIT;
|
||||
s.buf = dynmem_alloc(DHCP_MIN_PACKET_SIZE);
|
||||
s.desc = udp_new_connblock(intf, IPv4_ANY_ADDR, DHCP_CLIENT_PORT, dhcp_resp_cb);
|
||||
|
Loading…
x
Reference in New Issue
Block a user