~ubuntu-branches/ubuntu/oneiric/collectd/oneiric

« back to all changes in this revision

Viewing changes to src/ntpd.c

  • Committer: Bazaar Package Importer
  • Author(s): Morten Kjeldgaard
  • Date: 2008-11-18 15:54:20 UTC
  • mfrom: (1.1.5 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20081118155420-sc2mxv2pebafkmon
Tags: 4.4.2-2ubuntu1
* Merge from Debian unstable (LP: #298828). Remaining Ubuntu changes:
* Add ubuntu_in6-glibc28.dpatch patch, fix FTBFS.
* Add ubuntu_hardening.dpatch patch, fix FTBFS.
* Add ubuntu_perl.c.dpatch, fix FTBFS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
#define MAXFILENAME 128
69
69
#define MAXSEQ  127
70
70
#define MODE_PRIVATE 7
71
 
#define NTP_OLDVERSION ((u_char) 1) /* oldest credible version */
 
71
#define NTP_OLDVERSION ((uint8_t) 1) /* oldest credible version */
72
72
#define IMPL_XNTPD 3
73
73
#define FP_FRAC 65536.0
74
74
 
117
117
 
118
118
#define ISRESPONSE(rm_vn_mode)  (((rm_vn_mode)&RESP_BIT)!=0)
119
119
#define ISMORE(rm_vn_mode)      (((rm_vn_mode)&MORE_BIT)!=0)
120
 
#define INFO_VERSION(rm_vn_mode) ((u_char)(((rm_vn_mode)>>3)&0x7))
 
120
#define INFO_VERSION(rm_vn_mode) ((uint8_t)(((rm_vn_mode)>>3)&0x7))
121
121
#define INFO_MODE(rm_vn_mode)   ((rm_vn_mode)&0x7)
122
122
 
123
123
#define RM_VN_MODE(resp, more, version)         \
124
 
                                ((u_char)(((resp)?RESP_BIT:0)\
 
124
                                ((uint8_t)(((resp)?RESP_BIT:0)\
125
125
                                |((more)?MORE_BIT:0)\
126
126
                                |((version?version:(NTP_OLDVERSION+1))<<3)\
127
127
                                |(MODE_PRIVATE)))
128
128
 
129
129
#define INFO_IS_AUTH(auth_seq)  (((auth_seq) & 0x80) != 0)
130
130
#define INFO_SEQ(auth_seq)      ((auth_seq)&0x7f)
131
 
#define AUTH_SEQ(auth, seq)     ((u_char)((((auth)!=0)?0x80:0)|((seq)&0x7f)))
 
131
#define AUTH_SEQ(auth, seq)     ((uint8_t)((((auth)!=0)?0x80:0)|((seq)&0x7f)))
132
132
 
133
 
#define INFO_ERR(err_nitems)    ((u_short)((ntohs(err_nitems)>>12)&0xf))
134
 
#define INFO_NITEMS(err_nitems) ((u_short)(ntohs(err_nitems)&0xfff))
135
 
#define ERR_NITEMS(err, nitems) (htons((u_short)((((u_short)(err)<<12)&0xf000)\
136
 
                                |((u_short)(nitems)&0xfff))))
 
133
#define INFO_ERR(err_nitems)    ((uint16_t)((ntohs(err_nitems)>>12)&0xf))
 
134
#define INFO_NITEMS(err_nitems) ((uint16_t)(ntohs(err_nitems)&0xfff))
 
135
#define ERR_NITEMS(err, nitems) (htons((uint16_t)((((uint16_t)(err)<<12)&0xf000)\
 
136
                                |((uint16_t)(nitems)&0xfff))))
137
137
 
138
138
#define INFO_MBZ(mbz_itemsize)  ((ntohs(mbz_itemsize)>>12)&0xf)
139
 
#define INFO_ITEMSIZE(mbz_itemsize)     ((u_short)(ntohs(mbz_itemsize)&0xfff))
140
 
#define MBZ_ITEMSIZE(itemsize)  (htons((u_short)(itemsize)))
 
139
#define INFO_ITEMSIZE(mbz_itemsize)     ((uint16_t)(ntohs(mbz_itemsize)&0xfff))
 
140
#define MBZ_ITEMSIZE(itemsize)  (htons((uint16_t)(itemsize)))
141
141
 
142
142
/* negate a long float type */
143
143
#define M_NEG(v_i, v_f) \
302
302
        vl.values = values;
303
303
        vl.values_len = 1;
304
304
        vl.time = time (NULL);
305
 
        strcpy (vl.host, hostname_g);
306
 
        strcpy (vl.plugin, "ntpd");
307
 
        strcpy (vl.plugin_instance, "");
 
305
        sstrncpy (vl.host, hostname_g, sizeof (vl.host));
 
306
        sstrncpy (vl.plugin, "ntpd", sizeof (vl.plugin));
 
307
        sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
308
308
        strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
309
309
 
310
310
        plugin_dispatch_values (type, &vl);
612
612
                pkt_padding = 0;
613
613
                if (pkt_item_len < res_item_size)
614
614
                        pkt_padding = res_item_size - pkt_item_len;
615
 
                DEBUG ("res_item_size = %i; pkt_padding = %i;",
616
 
                                res_item_size, (int) pkt_padding);
 
615
                DEBUG ("res_item_size = %i; pkt_padding = %zi;",
 
616
                                res_item_size, pkt_padding);
617
617
 
618
618
                /* Extract the sequence number */
619
619
                pkt_sequence = INFO_SEQ (res.auth_seq);
651
651
                 * Enough with the checks. Copy the data now.
652
652
                 * We start by allocating some more memory.
653
653
                 */
654
 
                DEBUG ("realloc (%p, %i)", (void *) *res_data,
655
 
                                (int) (items_num + pkt_item_num) * res_item_size);
 
654
                DEBUG ("realloc (%p, %zu)", (void *) *res_data,
 
655
                                (items_num + pkt_item_num) * res_item_size);
656
656
                items = realloc ((void *) *res_data,
657
657
                                (items_num + pkt_item_num) * res_item_size);
658
658
                if (items == NULL)