]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Add address family override on the commandline. Use -4/-6 like most other
authorJohn Hay <hay@ntp.org>
Thu, 1 Aug 2002 04:11:17 +0000 (06:11 +0200)
committerJohn Hay <hay@ntp.org>
Thu, 1 Aug 2002 04:11:17 +0000 (06:11 +0200)
programs that do it. Note that it overrides it for all the servers on the
commandline.

bk: 3d48b4e5IekaOCVHs0pIM_rE_3GKrA

ntpdate/ntpdate.c

index 0112e8ed9169e78df77fb4a4715b3a0ce0f0759a..52c8765249450ee131801d85dccdd2379821f048 100644 (file)
@@ -108,6 +108,7 @@ volatile int debug = 0;
 /*
  * File descriptor masks etc. for call to select
  */
+int ai_fam_templ;
 int nbsock;
 int fd[MAX_AF];  /* support up to 2 sockets */
 int fd_family[MAX_AF];  /* to remember the socket family */
@@ -352,9 +353,15 @@ ntpdatemain (
        /*
         * Decode argument list
         */
-       while ((c = ntp_getopt(argc, argv, "a:bBde:k:o:p:qr:st:uv")) != EOF)
+       while ((c = ntp_getopt(argc, argv, "46a:bBde:k:o:p:qr:st:uv")) != EOF)
                switch (c)
                {
+               case '4':
+                       ai_fam_templ = AF_INET;
+                       break;
+               case '6':
+                       ai_fam_templ = AF_INET6;
+                       break;
                case 'a':
                        c = atoi(ntp_optarg);
                        sys_authenticate = 1;
@@ -444,8 +451,8 @@ ntpdatemain (
        
        if (errflg) {
                (void) fprintf(stderr,
-                                  "usage: %s [-bBdqsuv] [-a key#] [-e delay] [-k file] [-p samples] [-o version#] [-r rate] [-t timeo] server ...\n",
-                                  progname);
+                   "usage: %s [-46bBdqsuv] [-a key#] [-e delay] [-k file] [-p samples] [-o version#] [-r rate] [-t timeo] server ...\n",
+                   progname);
                exit(2);
        }
 
@@ -1323,9 +1330,9 @@ addserver(
         char service[5];
        sprintf(service, "%d", NTP_PORT);
 
-        /* Get host address. Looking for UDP datagram connection and IPv6 address format*/
+        /* Get host address. Looking for UDP datagram connection*/
         memset(&hints, 0, sizeof(hints));
-        hints.ai_family = AF_UNSPEC;
+        hints.ai_family = ai_fam_templ;
         hints.ai_socktype = SOCK_DGRAM;
 
         printf("Looking for host %s and service %s\n", serv, service);