4.3BSD/usr/src/etc/timed/byteorder.c
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char sccsid[] = "@(#)byteorder.c 2.4 (Berkeley) 5/20/86";
#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 */
}
}