DHCP proc semaphor replaced with mutex
This commit is contained in:
parent
025f6d09b9
commit
a6ee1d3fe5
@ -16,7 +16,7 @@ static struct {
|
|||||||
cbd desc;
|
cbd desc;
|
||||||
uint32_t tranId;
|
uint32_t tranId;
|
||||||
EthInterface *intf;
|
EthInterface *intf;
|
||||||
ETHLIB_OS_SEM_TYPE procSem;
|
ETHLIB_OS_MTX_TYPE procMtx;
|
||||||
} s;
|
} s;
|
||||||
|
|
||||||
static const uint8_t DHCP_MAGIC_COOKIE[] = {99, 130, 83, 99};
|
static const uint8_t DHCP_MAGIC_COOKIE[] = {99, 130, 83, 99};
|
||||||
@ -249,7 +249,7 @@ void dhcp_request(ip4_addr reqAddr, ip4_addr dhcpServerAddr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void dhcp_process(DhcpProps *props, DhcpOption *opts) {
|
static void dhcp_process(DhcpProps *props, DhcpOption *opts) {
|
||||||
ETHLIB_OS_SEM_WAIT(&s.procSem); // LOCK!
|
ETHLIB_OS_MTX_LOCK(&s.procMtx); // LOCK!
|
||||||
|
|
||||||
switch (s.state) {
|
switch (s.state) {
|
||||||
case DHCP_INIT:
|
case DHCP_INIT:
|
||||||
@ -313,7 +313,7 @@ static void dhcp_process(DhcpProps *props, DhcpOption *opts) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ETHLIB_OS_SEM_POST(&s.procSem); // RELEASE!
|
ETHLIB_OS_MTX_UNLOCK(&s.procMtx); // RELEASE!
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dhcp_resp_cb(const Pckt *pckt, PcktSieveLayerTag tag) {
|
static int dhcp_resp_cb(const Pckt *pckt, PcktSieveLayerTag tag) {
|
||||||
@ -334,8 +334,7 @@ void dhcp_start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dhcp_initiate(EthInterface *intf) {
|
void dhcp_initiate(EthInterface *intf) {
|
||||||
ETHLIB_OS_SEM_CREATE(&s.procSem);
|
ETHLIB_OS_MTX_CREATE(&s.procMtx);
|
||||||
ETHLIB_OS_SEM_POST(&s.procSem);
|
|
||||||
s.state = DHCP_INIT;
|
s.state = DHCP_INIT;
|
||||||
s.buf = dynmem_alloc(DHCP_MIN_PACKET_SIZE);
|
s.buf = dynmem_alloc(DHCP_MIN_PACKET_SIZE);
|
||||||
s.desc = udp_new_connblock(intf, IPv4_ANY_ADDR, DHCP_CLIENT_PORT, dhcp_resp_cb);
|
s.desc = udp_new_connblock(intf, IPv4_ANY_ADDR, DHCP_CLIENT_PORT, dhcp_resp_cb);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user