et_network.h

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------*
00002  *  Copyright (c) 1998        Southeastern Universities Research Association, *
00003  *                            Thomas Jefferson National Accelerator Facility  *
00004  *                                                                            *
00005  *    This software was developed under a United States Government license    *
00006  *    described in the NOTICE file included as part of this distribution.     *
00007  *                                                                            *
00008  *    Author:  Carl Timmer                                                    *
00009  *             timmer@jlab.org                   Jefferson Lab, MS-12H        *
00010  *             Phone: (757) 269-5130             12000 Jefferson Ave.         *
00011  *             Fax:   (757) 269-5800             Newport News, VA 23606       *
00012  *                                                                            *
00013  *----------------------------------------------------------------------------*
00014  *
00015  * Description:
00016  *      Header for routines dealing with network communications
00017  *
00018  *----------------------------------------------------------------------------*/
00019  
00020 #ifndef __et_network_h
00021 #define __et_network_h
00022 
00023 #ifdef VXWORKS
00024 #include <ioLib.h>       /* writev */
00025 #include <inetLib.h>    /* htonl stuff */
00026 #else
00027 #include <arpa/inet.h>   /* htonl stuff */
00028 #endif
00029 
00030 #ifdef sun
00031 #include <sys/sockio.h>  /* find broacast addr */
00032 #else
00033 #include <sys/ioctl.h>   /* find broacast addr */
00034 #endif
00035 
00036 #include "et_private.h"
00037 
00038 #ifdef  __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 #if defined sun || defined linux || defined VXWORKS || defined __APPLE__
00043 #  define socklen_t int
00044 #endif
00045 
00046 #ifdef linux
00047   #ifndef _SC_IOV_MAX
00048    #define _SC_IOV_MAX _SC_T_IOV_MAX
00049   #endif
00050 #endif
00051 
00052 #define SA                  struct sockaddr
00053 #define LISTENQ             10
00054 #define ET_SOCKBUFSIZE      49640  /* multiple of 1460 - ethernet MSS */
00055 #define ET_IOV_MAX          16     /* minimum for POSIX systems */
00056 
00057 /* are 2 nodes the same or different? */
00058 #define ET_NODE_SAME 0
00059 #define ET_NODE_DIFF 1
00060 
00061 /*
00062  * Make solaris compatible with Linux. On Solaris,
00063  * _BIG_ENDIAN  or  _LITTLE_ENDIAN is defined
00064  * depending on the architecture.
00065  */
00066 #ifdef sun
00067 
00068   #define __LITTLE_ENDIAN 1234
00069   #define __BIG_ENDIAN    4321
00070 
00071   #if defined(_BIG_ENDIAN)
00072     #define __BYTE_ORDER __BIG_ENDIAN
00073   #else
00074     #define __BYTE_ORDER __LITTLE_ENDIAN
00075   #endif
00076 
00077 /*
00078  * On vxworks, _BIG_ENDIAN = 1234 and _LITTLE_ENDIAN = 4321,
00079  * which is backwards. _BYTE_ORDER is also defined.
00080  * In types/vxArch.h, these definitions are carefully set
00081  * to these reversed values. In other header files such as
00082  * netinet/ip.h & tcp.h, the values are normal (ie
00083  * _BIG_ENDIAN = 4321). What's this all about?
00084  */
00085 #elif VXWORKS
00086 
00087   #define __LITTLE_ENDIAN 1234
00088   #define __BIG_ENDIAN    4321
00089 
00090   #if _BYTE_ORDER == _BIG_ENDIAN
00091     #define __BYTE_ORDER __BIG_ENDIAN
00092   #else
00093     #define __BYTE_ORDER __LITTLE_ENDIAN
00094   #endif
00095 
00096 #endif
00097 
00098 
00099 /* Byte swapping for 64 bits. */
00100 #define hton64(x) ntoh64(x)
00101 #if __BYTE_ORDER == __BIG_ENDIAN
00102 #define ntoh64(x) x
00103 #else
00104 #define ntoh64(x) et_ntoh64(x)
00105 #endif
00106 
00107 /*
00108  * Ints representing ascii for "ET is Grreat",
00109  * used to filter out portscanning software.
00110  */
00111 #define ET_MAGIC_INT1 0x45543269
00112 #define ET_MAGIC_INT2 0x73324772
00113 #define ET_MAGIC_INT3 0x72656174
00114 
00115 
00116 /* our prototypes */
00117 extern uint64_t et_ntoh64(uint64_t n);
00118 
00119 extern int   et_CODAswap(int *src, int *dest, int nints, int same_endian);
00120 
00121 extern int   et_findserver2(const char *etname, char *ethost, int *port,
00122                             uint32_t *inetaddr, et_response **allETinfo,
00123                             et_open_config *config, int trys,
00124                             struct timeval *waittime);
00125                             
00126 extern void  et_freeAnswers(et_response *answer);
00127 
00128 extern codaIpList *et_orderIpAddrs(et_response *response, codaIpAddr *netinfo,
00129                                    char* preferredSubnet);
00130 
00131 #ifdef  __cplusplus
00132 }
00133 #endif
00134 
00135 #endif

Generated on 30 Jul 2015 for ET System by  doxygen 1.6.1