Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

ntp.c File Reference


Detailed Description

Detection of a local NTP server.

Author:
Raphael Manfredi
Date:
2004

#include "common.h"
#include "ntp.h"
#include "sockets.h"
#include "if/core/hosts.h"
#include "if/gnet_property.h"
#include "if/gnet_property_priv.h"
#include "lib/cq.h"
#include "lib/endian.h"
#include "lib/misc.h"
#include "lib/tm.h"
#include "lib/override.h"

Data Structures

struct  ntp_msg
 An NTP message, as described in RFC2030 (trailing auth-data ignored). More...


Defines

#define OFFSET_1900   2208988800U /**< secs between 1900 and the Epoch */
 secs between 1900 and the Epoch

#define NTP_FP_SCALE   4294967296.0 /**< NTP fixed-point scaling base */
 NTP fixed-point scaling base.

#define NTP_WAIT_MS   (5*1000) /**< Wait at most 5 secs for reply */
 Wait at most 5 secs for reply.

#define NTP_VERSION   3 /**< Say we're version 3 */
 Say we're version 3.

#define NTP_CLIENT   3 /**< Mode for unicast request */
 Mode for unicast request.

#define NTP_SERVER   4 /**< Mode for server reply */
 Mode for server reply.

#define NTP_AUTHSIZE   20 /**< Size of NTP auth, when present */
 Size of NTP auth, when present.

#define NTP_MINSIZE   sizeof(struct ntp_msg)
#define NTP_MAXSIZE   (NTP_MINSIZE + NTP_AUTHSIZE)

Functions

 RCSID ("$Id:ntp.c, v 1.16 2005/11/04 20:52:43 cbiere Exp $")
void ntp_tm_serialize (guchar dest[8], tm_t *t)
 Fill 8-byte buffer with NTP's representation of a tm_t time.

void ntp_tm_deserialize (guchar src[8], tm_t *dest)
 Construct a tm_t time from an NTP timestamp.

void ntp_no_reply (cqueue_t *unused_cq, gpointer unused_udata)
 Callout queue timeout when no reply is received within a reasonable timeframe.

gboolean ntp_send_probe (const host_addr_t addr)
gboolean ntp_send_probes (void)
void ntp_probe (void)
 Send an NTP probe to the local host using the loopback addresses 127.0.0.1 and ::1, waiting for a reply within the next NTP_WAIT_MS ms.

void ntp_got_reply (struct gnutella_socket *s)
 Got a reply from an NTP daemon.

void ntp_init (void)
 Initialize the NTP monitoring.

void ntp_close (void)
 Shutdown the NTP monitoring.


Variables

gpointer wait_ev = NULL
 Callout queue waiting event.

ntp_msg __packed__
 An NTP message, as described in RFC2030 (trailing auth-data ignored).


Define Documentation

#define NTP_AUTHSIZE   20 /**< Size of NTP auth, when present */
 

Size of NTP auth, when present.

#define NTP_CLIENT   3 /**< Mode for unicast request */
 

Mode for unicast request.

#define NTP_FP_SCALE   4294967296.0 /**< NTP fixed-point scaling base */
 

NTP fixed-point scaling base.

#define NTP_MAXSIZE   (NTP_MINSIZE + NTP_AUTHSIZE)
 

#define NTP_MINSIZE   sizeof(struct ntp_msg)
 

#define NTP_SERVER   4 /**< Mode for server reply */
 

Mode for server reply.

#define NTP_VERSION   3 /**< Say we're version 3 */
 

Say we're version 3.

#define NTP_WAIT_MS   (5*1000) /**< Wait at most 5 secs for reply */
 

Wait at most 5 secs for reply.

#define OFFSET_1900   2208988800U /**< secs between 1900 and the Epoch */
 

secs between 1900 and the Epoch


Function Documentation

void ntp_close void   ) 
 

Shutdown the NTP monitoring.

void ntp_got_reply struct gnutella_socket s  ) 
 

Got a reply from an NTP daemon.

void ntp_init void   ) 
 

Initialize the NTP monitoring.

void ntp_no_reply cqueue_t unused_cq,
gpointer  unused_udata
[static]
 

Callout queue timeout when no reply is received within a reasonable timeframe.

void ntp_probe void   ) 
 

Send an NTP probe to the local host using the loopback addresses 127.0.0.1 and ::1, waiting for a reply within the next NTP_WAIT_MS ms.

gboolean ntp_send_probe const host_addr_t  addr  )  [static]
 

gboolean ntp_send_probes void   )  [static]
 

void ntp_tm_deserialize guchar  src[8],
tm_t dest
[static]
 

Construct a tm_t time from an NTP timestamp.

void ntp_tm_serialize guchar  dest[8],
tm_t t
[static]
 

Fill 8-byte buffer with NTP's representation of a tm_t time.

RCSID "$Id:ntp.  c,
v 1.16 2005/11/04 20:52:43 cbiere Exp $" 
 


Variable Documentation

struct ntp_msg __packed__
 

An NTP message, as described in RFC2030 (trailing auth-data ignored).

gpointer wait_ev = NULL [static]
 

Callout queue waiting event.


Generated on Sun Feb 12 10:50:05 2006 for Gtk-Gnutella by doxygen 1.3.6