Code

Add newline after "Usage:" in --help
[nagiosplug.git] / plugins-root / check_dhcp.c
index 5781f758db2e2f5a3efbc6f2e0ab2c89b90b47a3..2a1875c405431048c3099a5ec8834ffd72599dcd 100644 (file)
@@ -6,8 +6,6 @@
 * Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)
 * Copyright (c) 2001-2007 Nagios Plugin Development Team
 * 
-* Last Modified: $Date$
-* 
 * Description:
 * 
 * This file contains the check_dhcp plugin
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
-* $Id$
 * 
 *****************************************************************************/
 
 const char *progname = "check_dhcp";
-const char *revision = "$Revision$";
 const char *copyright = "2001-2007";
 const char *email = "nagiosplug-devel@lists.sourceforge.net";
 
@@ -79,8 +75,8 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
 
 #elif defined(__sun__) || defined(__solaris__) || defined(__hpux__)
 
-#define INSAP 22 
-#define OUTSAP 24 
+#define INSAP 22
+#define OUTSAP 24
 
 #include <signal.h>
 #include <ctype.h>
@@ -90,17 +86,17 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
 
 #define bcopy(source, destination, length) memcpy(destination, source, length)
 
-#define AREA_SZ 5000           /* buffer length in bytes */ 
+#define AREA_SZ 5000           /* buffer length in bytes */
 static u_long ctl_area[AREA_SZ];
 static u_long dat_area[AREA_SZ];
 static struct strbuf ctl = {AREA_SZ, 0, (char *)ctl_area};
 static struct strbuf dat = {AREA_SZ, 0, (char *)dat_area};
 
-#define GOT_CTRL 1 
-#define GOT_DATA 2 
-#define GOT_BOTH 3 
-#define GOT_INTR 4 
-#define GOT_ERR 128 
+#define GOT_CTRL 1
+#define GOT_DATA 2
+#define GOT_BOTH 3
+#define GOT_INTR 4
+#define GOT_ERR 128
 
 #define u_int8_t        uint8_t
 #define u_int16_t      uint16_t
@@ -222,7 +218,7 @@ dhcp_offer *dhcp_offer_list=NULL;
 requested_server *requested_server_list=NULL;
 
 int valid_responses=0;     /* number of valid DHCPOFFERs we received */
-int requested_servers=0;   
+int requested_servers=0;
 int requested_responses=0;
 
 int request_specific_address=FALSE;
@@ -382,7 +378,7 @@ int get_hardware_address(int sock,char *interface_name){
                unit = atoi(p) ;
                *p = '\0' ;
                strncat(dev, interface_name, 6) ;
-               } 
+               }
        else{
                printf(_("Error: can't find unit number in interface_name (%s) - expecting TypeNumber eg lnc0.\n"), interface_name);
                exit(STATE_UNKNOWN);
@@ -535,7 +531,7 @@ int send_dhcp_discover(int sock){
        /* send the DHCPDISCOVER packet out */
        send_dhcp_packet(&discover_packet,sizeof(discover_packet),sock,&sockaddr_broadcast);
 
-       if(verbose) 
+       if(verbose)
                printf("\n\n");
 
        return OK;
@@ -564,7 +560,7 @@ int get_dhcp_offer(int sock){
                if((current_time-start_time)>=dhcpoffer_timeout)
                        break;
 
-               if(verbose) 
+               if(verbose)
                        printf("\n\n");
 
                bzero(&source,sizeof(source));
@@ -581,7 +577,7 @@ int get_dhcp_offer(int sock){
                        continue;
                        }
                else{
-                       if(verbose) 
+                       if(verbose)
                                printf(_("Result=OK\n"));
 
                        responses++;
@@ -626,7 +622,7 @@ int get_dhcp_offer(int sock){
                        printf("\n");
 
                if(result==ERROR){
-                       if(verbose) 
+                       if(verbose)
                                printf(_("DHCPOFFER hardware address did not match our own - ignoring packet\n"));
 
                        continue;
@@ -660,7 +656,7 @@ int send_dhcp_packet(void *buffer, int buffer_size, int sock, struct sockaddr_in
 
        result=sendto(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)dest,sizeof(*dest));
 
-       if(verbose) 
+       if(verbose)
                printf(_("send_dhcp_packet result: %d\n"),result);
 
        if(result<0)
@@ -853,7 +849,7 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
                /* get option length */
                option_length=offer_packet->options[x++];
 
-               if(verbose) 
+               if(verbose)
                        printf("Option: %d (0x%02X)\n",option_type,option_length);
 
                /* get option data */
@@ -989,7 +985,7 @@ int get_results(void){
                                        if(verbose){
                                                printf(_("DHCP Server Match: Offerer=%s"),inet_ntoa(temp_offer->server_address));
                                                printf(_(" Requested=%s"),inet_ntoa(temp_server->server_address));
-                                               if(temp_server->answered) 
+                                               if(temp_server->answered)
                                                        printf(_(" (duplicate)"));
                                                printf(_("\n"));
                                                }
@@ -1090,7 +1086,7 @@ int call_getopt(int argc, char **argv){
 
        int option_index = 0;
        static struct option long_options[] =
-       { 
+       {
                {"serverip",       required_argument,0,'s'},
                {"requestedip",    required_argument,0,'r'},
                {"timeout",        required_argument,0,'t'},
@@ -1168,7 +1164,7 @@ int call_getopt(int argc, char **argv){
                        break;
 
                case 'V': /* version */
-                       print_revision(progname,revision);
+                       print_revision(progname, NP_VERSION);
                        exit(STATE_OK);
 
                case 'h': /* help */
@@ -1306,7 +1302,7 @@ static int dl_bind(int fd, int sap, u_char *addr){
 
 /***********************************************************************
  * interface:
- * function mac_addr_dlpi - get the mac address of the interface with 
+ * function mac_addr_dlpi - get the mac address of the interface with
  *                          type dev (eg lnc, hme) and unit (0, 1 ..)
  *
  * parameter: addr: an array of six bytes, has to be allocated by the caller
@@ -1385,7 +1381,7 @@ void print_hardware_address(const unsigned char *address){
 /* print usage help */
 void print_help(void){
 
-       print_revision(progname,revision);
+       print_revision(progname, NP_VERSION);
 
        printf("Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)\n");
        printf (COPYRIGHT, copyright, email);
@@ -1396,10 +1392,10 @@ void print_help(void){
 
        print_usage();
 
-       printf (_(UT_HELP_VRSN));
-       printf (_(UT_EXTRA_OPTS));
+       printf (UT_HELP_VRSN);
+       printf (UT_EXTRA_OPTS);
 
-       printf (_(UT_VERBOSE));
+       printf (UT_VERBOSE);
 
        printf (" %s\n", "-s, --serverip=IPADDRESS");
   printf ("    %s\n", _("IP address of DHCP server that we must hear from"));
@@ -1414,13 +1410,7 @@ void print_help(void){
   printf (" %s\n", "-u, --unicast");
   printf ("    %s\n", _("Unicast testing: mimic a DHCP relay, requires -s"));
 
-#ifdef NP_EXTRA_OPTS
-  printf ("\n");
-  printf ("%s\n", _("Notes:"));
-  printf (_(UT_EXTRA_OPTS_NOTES));
-#endif
-
-  printf (_(UT_SUPPORT));
+  printf (UT_SUPPORT);
        return;
        }
 
@@ -1428,7 +1418,7 @@ void print_help(void){
 void
 print_usage(void){
 
-  printf (_("Usage:"));
+  printf ("%s\n", _("Usage:"));
   printf (" %s [-v] [-u] [-s serverip] [-r requestedip] [-t timeout]\n",progname);
   printf ("                  [-i interface] [-m mac]\n");