FreeBSD/contrib/ntp/ntpdate/ntpdate.c
/*
 * transmit - transmit a packet to the given server, or mark it completed.
 *		This is called by the timeout routine and by the receive
 *		procedure.
 */
transmit a packet to the given server, or mark it completed.
This is called by the timeout routine and by the receive
procedure.
transmit a packet to the given server or mark it completed . This is called by the timeout routine and by the receive procedure .
static void
transmit(
	register struct server *server
	)
{
	struct pkt xpkt;
	if (debug)
		printf("transmit(%s)\n", stoa(&server->srcadr));
	if (server->filter_nextpt < server->xmtcnt) {
		l_fp ts;
		L_CLR(&ts);
		server_data(server, 0, &ts, 0);
	}
	if ((int)server->filter_nextpt >= sys_samples) {
		server->event_time = 0;
		complete_servers++;
		return;
	}
	xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
					 sys_version, MODE_CLIENT);
	xpkt.stratum = STRATUM_TO_PKT(STRATUM_UNSPEC);
	xpkt.ppoll = NTP_MINPOLL;
	xpkt.precision = NTPDATE_PRECISION;
	xpkt.rootdelay = htonl(NTPDATE_DISTANCE);
	xpkt.rootdisp = htonl(NTPDATE_DISP);
	xpkt.refid = htonl(NTPDATE_REFID);
	L_CLR(&xpkt.reftime);
	L_CLR(&xpkt.org);
	L_CLR(&xpkt.rec);
	if (sys_authenticate) {
		size_t len;
		xpkt.exten[0] = htonl(sys_authkey);
		get_systime(&server->xmt);
		L_ADDUF(&server->xmt, sys_authdelay);
		HTONL_FP(&server->xmt, &xpkt.xmt);
		len = authencrypt(sys_authkey, (u_int32 *)&xpkt, LEN_PKT_NOMAC);
		sendpkt(&server->srcadr, &xpkt, (int)(LEN_PKT_NOMAC + len));
		if (debug > 1)
			printf("transmit auth to %s\n",
			   stoa(&server->srcadr));
	} else {
		get_systime(&(server->xmt));
		HTONL_FP(&server->xmt, &xpkt.xmt);
		sendpkt(&server->srcadr, &xpkt, LEN_PKT_NOMAC);
		if (debug > 1)
			printf("transmit to %s\n", stoa(&server->srcadr));
	}
	server->event_time = current_time + sys_timeout;
	server->xmtcnt++;
}
static void transmit ( register struct server * server ) { struct pkt xpkt ; if ( debug ) printf ( " \n " , stoa ( & server -> srcadr ) ) ; if ( server -> filter_nextpt < server -> xmtcnt ) { l_fp ts ; L_CLR ( & ts ) ; server_data ( server , 0 , & ts , 0 ) ; } if ( ( int ) server -> filter_nextpt >= sys_samples ) { server -> event_time = 0 ; complete_servers ++ ; return ; } xpkt . li_vn_mode = PKT_LI_VN_MODE ( LEAP_NOTINSYNC , sys_version , MODE_CLIENT ) ; xpkt . stratum = STRATUM_TO_PKT ( STRATUM_UNSPEC ) ; xpkt . ppoll = NTP_MINPOLL ; xpkt . precision = NTPDATE_PRECISION ; xpkt . rootdelay = htonl ( NTPDATE_DISTANCE ) ; xpkt . rootdisp = htonl ( NTPDATE_DISP ) ; xpkt . refid = htonl ( NTPDATE_REFID ) ; L_CLR ( & xpkt . reftime ) ; L_CLR ( & xpkt . org ) ; L_CLR ( & xpkt . rec ) ; if ( sys_authenticate ) { size_t len ; xpkt . exten [ 0 ] = htonl ( sys_authkey ) ; get_systime ( & server -> xmt ) ; L_ADDUF ( & server -> xmt , sys_authdelay ) ; HTONL_FP ( & server -> xmt , & xpkt . xmt ) ; len = authencrypt ( sys_authkey , ( u_int32 * ) & xpkt , LEN_PKT_NOMAC ) ; sendpkt ( & server -> srcadr , & xpkt , ( int ) ( LEN_PKT_NOMAC + len ) ) ; if ( debug > 1 ) printf ( " \n " , stoa ( & server -> srcadr ) ) ; } else { get_systime ( & ( server -> xmt ) ) ; HTONL_FP ( & server -> xmt , & xpkt . xmt ) ; sendpkt ( & server -> srcadr , & xpkt , LEN_PKT_NOMAC ) ; if ( debug > 1 ) printf ( " \n " , stoa ( & server -> srcadr ) ) ; } server -> event_time = current_time + sys_timeout ; server -> xmtcnt ++ ; }
transmit - transmit a packet to the given server, or mark it completed.
transmit - transmit a packet to the given server or mark it completed .
/*
		 * Last message to this server timed out.  Shift
		 * zeros into the filter.
		 */ /*
		 * Got all the data we need.  Mark this guy
		 * completed and return.
		 */ /*
	 * If we're here, send another message to the server.  Fill in
	 * the packet and let 'er rip.
	 */ /*
	 * Determine whether to authenticate or not.	If so,
	 * fill in the extended part of the packet and do it.
	 * If not, just timestamp it and send it away.
	 */ /*
	 * Update the server timeout and transmit count
	 */