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