c83f6543aa42ecd0f3c6a579b94385ccde55c642
[unix-history] / usr / src / usr.sbin / timed / timed / byteorder.c
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#ifndef lint
static char sccsid[] = "@(#)byteorder.c 2.5 (Berkeley) %G%";
#endif /* not lint */
#include "globals.h"
#include <protocols/timed.h>
/*
* Two routines to do the necessary byte swapping for timed protocol
* messages. Protocol is defined in /usr/include/protocols/timed.h
*/
bytenetorder(ptr)
struct tsp *ptr;
{
ptr->tsp_seq = htons((u_short)ptr->tsp_seq);
switch (ptr->tsp_type) {
case TSP_SETTIME:
case TSP_ADJTIME:
case TSP_SETDATE:
case TSP_SETDATEREQ:
ptr->tsp_time.tv_sec = htonl((u_long)ptr->tsp_time.tv_sec);
ptr->tsp_time.tv_usec = htonl((u_long)ptr->tsp_time.tv_usec);
break;
default:
break; /* nothing more needed */
}
}
bytehostorder(ptr)
struct tsp *ptr;
{
ptr->tsp_seq = ntohs((u_short)ptr->tsp_seq);
switch (ptr->tsp_type) {
case TSP_SETTIME:
case TSP_ADJTIME:
case TSP_SETDATE:
case TSP_SETDATEREQ:
ptr->tsp_time.tv_sec = ntohl((u_long)ptr->tsp_time.tv_sec);
ptr->tsp_time.tv_usec = ntohl((u_long)ptr->tsp_time.tv_usec);
break;
default:
break; /* nothing more needed */
}
}