]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
make consistent layout for 'struct pkt'
authorJuergen Perlinger <perlinger@ntp.org>
Sat, 2 Aug 2014 11:15:10 +0000 (13:15 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Sat, 2 Aug 2014 11:15:10 +0000 (13:15 +0200)
bk: 53dcc83eDvaWAxmqmyZIG0Ucn-ifew

include/ntp.h
libntp/work_thread.c
sntp/main.c

index d485de03b1f81eab4c910c17f57a34b5aff6b15f..60adc4f34ae6af425f178c8ca0a33935a92c9cb1 100644 (file)
@@ -557,13 +557,19 @@ struct pkt {
         * response, so the maximum total extension field length is 864
         * octets. But, to handle humungus certificates, the bank must
         * be broke.
+        *
+        * The different definitions of the 'exten' field are here for
+        * the benefit of applications that want to send a packet from
+        * an auto variable in the stack - not using the AUTOKEY version
+        * saves 2KB of stack space. The receive buffer should ALWAYS be
+        * big enough to hold a full extended packet if the extension
+        * fields have to be parsed or skipped.
         */
 #ifdef AUTOKEY
-       u_int32 exten[NTP_MAXEXTEN / 4]; /* max extension field */
+       u_int32 exten[(NTP_MAXEXTEN + MAX_MAC_LEN) / sizeof(u_int32)];
 #else  /* !AUTOKEY follows */
-       u_int32 exten[1];       /* misused */
+       u_int32 exten[(MAX_MAC_LEN) / sizeof(u_int32)];
 #endif /* !AUTOKEY */
-       u_char  mac[MAX_MAC_LEN]; /* mac */
 };
 
 /*
index cf41de9c4e80af1507547186204ff40b8a5ef441..38d87470f01a7b7ad877311791de0fe6ae8689dd 100644 (file)
@@ -40,7 +40,7 @@
 # define thread_exit(c)        _endthreadex(c)
 # define tickle_sem    SetEvent
 #else
-# define thread_exit(c)        pthread_exit((void *)(c))
+# define thread_exit(c)        pthread_exit((void*)(size_t)(c))
 # define tickle_sem    sem_post
 #endif
 
index ee59714b41572b18afc0f03749a9db0f39497298..d60710868f2ddc0d72317d47468a8fac119b5c37 100644 (file)
@@ -85,7 +85,7 @@ sent_pkt *    fam_listheads[2];
 
 static union {
        struct pkt pkt;
-       char   buf[1500];
+       char   buf[LEN_PKT_NOMAC + NTP_MAXEXTEN + MAX_MAC_LEN];
 } rbuf;
 
 #define r_pkt  rbuf.pkt
@@ -295,9 +295,7 @@ open_sockets(
        )
 {
        sockaddr_u      name;
-       int             one_fam_works;
 
-       one_fam_works = FALSE;
        if (-1 == sock4) {
                sock4 = socket(PF_INET, SOCK_DGRAM, 0);
                if (-1 == sock4) {
@@ -328,7 +326,6 @@ open_sockets(
                        msyslog(LOG_ERR,
                                "open_sockets: event_new(base, sock4) failed!");
                } else {
-                       one_fam_works = TRUE;
                        event_add(ev_sock4, &wakeup_tv);
                }
        }
@@ -363,7 +360,6 @@ open_sockets(
                        msyslog(LOG_ERR,
                                "open_sockets: event_new(base, sock6) failed!");
                } else {
-                       one_fam_works = TRUE;
                        event_add(ev_sock6, &wakeup_tv);
                }
        }