int main(int argc, char **argv){ int dhcp_socket; int result; if(process_arguments(argc,argv)!=OK){ /*usage("Invalid command arguments supplied\n");*/ printf("Invalid command arguments supplied\n"); exit(STATE_UNKNOWN); } /* create socket for DHCP communications */ dhcp_socket=create_dhcp_socket(); /* get hardware address of client machine */ get_hardware_address(dhcp_socket,network_interface_name); /* send DHCPDISCOVER packet */ send_dhcp_discover(dhcp_socket); /* wait for a DHCPOFFER packet */ get_dhcp_offer(dhcp_socket); /* close socket we created */ close_dhcp_socket(dhcp_socket); /* determine state/plugin output to return */ result=get_results(); /* free allocated memory */ free_dhcp_offer_list(); free_requested_server_list(); return result; }
int main(int argc, char **argv){ int dhcp_socket; int result = STATE_UNKNOWN; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); /* Parse extra opts if any */ argv=np_extra_opts(&argc, argv, progname); if(process_arguments(argc,argv)!=OK){ usage4 (_("Could not parse arguments")); } /* this plugin almost certainly needs root permissions. */ np_warn_if_not_root(); /* create socket for DHCP communications */ dhcp_socket=create_dhcp_socket(); /* get hardware address of client machine */ if(user_specified_mac!=NULL) memcpy(client_hardware_address,user_specified_mac,6); else get_hardware_address(dhcp_socket,network_interface_name); if(unicast) /* get IP address of client machine */ get_ip_address(dhcp_socket,network_interface_name); /* send DHCPDISCOVER packet */ send_dhcp_discover(dhcp_socket); /* wait for a DHCPOFFER packet */ get_dhcp_offer(dhcp_socket); /* close socket we created */ close_dhcp_socket(dhcp_socket); /* determine state/plugin output to return */ result=get_results(); /* free allocated memory */ free_dhcp_offer_list(); free_requested_server_list(); return result; }