1 /*- 2 * Copyright (c) 1985, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)byteorder.c 8.1 (Berkeley) 06/06/93"; 10 #endif /* not lint */ 11 12 #ifdef sgi 13 #ident "$Revision: 1.3 $" 14 #endif 15 16 #include "globals.h" 17 18 /* 19 * Two routines to do the necessary byte swapping for timed protocol 20 * messages. Protocol is defined in /usr/include/protocols/timed.h 21 */ 22 void bytenetorder(ptr)23bytenetorder(ptr) 24 struct tsp *ptr; 25 { 26 ptr->tsp_seq = htons((u_short)ptr->tsp_seq); 27 switch (ptr->tsp_type) { 28 29 case TSP_SETTIME: 30 case TSP_ADJTIME: 31 case TSP_SETDATE: 32 case TSP_SETDATEREQ: 33 ptr->tsp_time.tv_sec = htonl((u_long)ptr->tsp_time.tv_sec); 34 ptr->tsp_time.tv_usec = htonl((u_long)ptr->tsp_time.tv_usec); 35 break; 36 37 default: 38 break; /* nothing more needed */ 39 } 40 } 41 42 void bytehostorder(ptr)43bytehostorder(ptr) 44 struct tsp *ptr; 45 { 46 ptr->tsp_seq = ntohs((u_short)ptr->tsp_seq); 47 switch (ptr->tsp_type) { 48 49 case TSP_SETTIME: 50 case TSP_ADJTIME: 51 case TSP_SETDATE: 52 case TSP_SETDATEREQ: 53 ptr->tsp_time.tv_sec = ntohl((u_long)ptr->tsp_time.tv_sec); 54 ptr->tsp_time.tv_usec = ntohl((u_long)ptr->tsp_time.tv_usec); 55 break; 56 57 default: 58 break; /* nothing more needed */ 59 } 60 } 61