/* ARGSUSED */ static void ipc_action_timeout(iu_tq_t *tq, void *arg) { dhcp_smach_t *dsmp = arg; struct ipc_action *ia = &dsmp->dsm_ia; dsmp->dsm_dflags &= ~DHCP_IF_BUSY; ia->ia_tid = -1; dhcpmsg(MSG_VERBOSE, "ipc timeout waiting for agent to complete " "%s (command %d) for %s", dhcp_ipc_type_to_string(ia->ia_cmd), ia->ia_cmd, dsmp->dsm_name); send_error_reply(ia, DHCP_IPC_E_TIMEOUT); async_finish(dsmp); release_smach(dsmp); }
void ipc_action_finish(dhcp_smach_t *dsmp, int reason) { struct ipc_action *ia = &dsmp->dsm_ia; dsmp->dsm_dflags &= ~DHCP_IF_BUSY; if (dsmp->dsm_ia.ia_fd == -1) { dhcpmsg(MSG_ERROR, "ipc_action_finish: attempted to finish unknown action " "on %s", dsmp->dsm_name); return; } dhcpmsg(MSG_DEBUG, "ipc_action_finish: finished %s (command %d) on %s: %d", dhcp_ipc_type_to_string(ia->ia_cmd), (int)ia->ia_cmd, dsmp->dsm_name, reason); /* * if we can't cancel this timer, we're really in the * twilight zone. however, as long as we don't drop the * reference to the state machine, it shouldn't hurt us */ if (dsmp->dsm_ia.ia_tid != -1 && iu_cancel_timer(tq, dsmp->dsm_ia.ia_tid, NULL) == 1) { dsmp->dsm_ia.ia_tid = -1; release_smach(dsmp); } if (reason == 0) send_ok_reply(ia); else send_error_reply(ia, reason); async_finish(dsmp); }
int dhcp_extending(struct ifslist *ifsp) { dhcp_pkt_t *dpkt; if (ifsp->if_state == BOUND) { ifsp->if_neg_monosec = monosec(); ifsp->if_state = RENEWING; ifsp->if_bad_offers = 0; ifsp->if_sent = 0; ifsp->if_received = 0; } dhcpmsg(MSG_DEBUG, "dhcp_extending: registering dhcp_acknak on %s", ifsp->if_name); if (register_acknak(ifsp) == 0) { ipc_action_finish(ifsp, DHCP_IPC_E_MEMORY); async_finish(ifsp); dhcpmsg(MSG_WARNING, "dhcp_extending: cannot register " "dhcp_acknak for %s, not sending renew request", ifsp->if_name); return (0); } /* * assemble DHCPREQUEST message. The max dhcp message size * option is set to the interface max, minus the size of the udp and * ip headers. */ dpkt = init_pkt(ifsp, REQUEST); dpkt->pkt->ciaddr.s_addr = ifsp->if_addr.s_addr; add_pkt_opt16(dpkt, CD_MAX_DHCP_SIZE, htons(ifsp->if_max - sizeof (struct udpiphdr))); add_pkt_opt32(dpkt, CD_LEASE_TIME, htonl(DHCP_PERM)); add_pkt_opt(dpkt, CD_CLASS_ID, class_id, class_id_len); add_pkt_opt(dpkt, CD_REQUEST_LIST, ifsp->if_prl, ifsp->if_prllen); /* * if_reqhost was set for this interface in dhcp_selecting() * if the REQUEST_HOSTNAME option was set and a host name was * found. */ if (ifsp->if_reqhost != NULL) { add_pkt_opt(dpkt, CD_HOSTNAME, ifsp->if_reqhost, strlen(ifsp->if_reqhost)); } add_pkt_opt(dpkt, CD_END, NULL, 0); /* * if we can't send the packet, leave the event handler registered * anyway, since we're not expecting to get any other types of * packets in other than ACKs/NAKs anyway. */ return (send_pkt(ifsp, dpkt, ifsp->if_server.s_addr, NULL)); }