00001 /* 00002 Converse Client/Server: Server-side interface 00003 Orion Sky Lawlor, 9/13/2000, olawlor@acm.org 00004 00005 CcsServer routines handle the CCS Server socket, 00006 translate CCS requests and replies into the final 00007 network format, and send/recv the actual requests 00008 and replies. 00009 00010 Depending on the situation, this code is called from 00011 conv-host.c, or conv-core.c/conv-ccs.C (for 00012 NODE_0_IS_CONVHOST). All the routines in this file 00013 should be called from within only one machine&program-- 00014 the CCS server. That is, you can't receive a request 00015 on one machine, send the request to another machine, 00016 and send the response from the new machine (because 00017 the reply socket is for the original machine). 00018 */ 00019 00020 #ifndef CCS_SERVER_H 00021 #define CCS_SERVER_H 00022 00023 #include "sockRoutines.h" 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00029 #if CMK_CCS_AVAILABLE 00030 00031 /*Security attributes for a CCS request*/ 00032 typedef struct { 00033 skt_ip_t ip;/*Source machine (or firewall)*/ 00034 ChMessageInt_t port; 00035 ChMessageInt_t replySalt;/*Salt value for reply hash*/ 00036 unsigned char auth;/*1-- message authenticated; 0-- no authentication*/ 00037 unsigned char level;/*Security level-- 0 to 255*/ 00038 } CcsSecAttr; 00039 00040 /*Used within CCS implementation to identify requestor*/ 00041 #define CCS_MAXHANDLER 32 /*Longest possible handler name*/ 00042 typedef struct { 00043 CcsSecAttr attr; /*Source information*/ 00044 char handler[CCS_MAXHANDLER];/*Handler name for message to follow*/ 00045 ChMessageInt_t pe;/*Dest. processor # (global numbering)*/ 00046 ChMessageInt_t replyFd;/*Send reply back here*/ 00047 ChMessageInt_t len;/*Bytes of message data to follow*/ 00048 } CcsImplHeader; 00049 00050 /********* CCS Implementation (not in ccs-server.C) ********/ 00051 /*Deliver this request data to the appropriate PE. */ 00052 void CcsImpl_netRequest(CcsImplHeader *hdr,const void *reqData); 00053 00054 /*Deliver this reply data to this reply socket. 00055 The data will eventually be sent to the CCS server. 00056 */ 00057 void CcsImpl_reply(CcsImplHeader *hdr,int repLen,const void *repData); 00058 00059 /*Send any registered clients kill messages before we exit*/ 00060 void CcsImpl_kill(void); 00061 00062 /*Convert CCS header & message data into a converse message to handler*/ 00063 char *CcsImpl_ccs2converse(const CcsImplHeader *hdr,const void *data,int *ret_len); 00064 00065 /******************* ccs-server.C routines ***************/ 00066 /*Make a new Ccs Server socket, on the given port. 00067 Returns the actual port and IP address. 00068 */ 00069 void CcsServer_new(skt_ip_t *ret_ip,int *use_port,const char *securityFile); 00070 00071 /*Get the Ccs Server socket. This socket can 00072 be added to the rdfs list for calling select(). 00073 */ 00074 SOCKET CcsServer_fd(void); 00075 00076 /*Connect to the Ccs Server socket, and 00077 receive a ccs request from the network. 00078 Returns 1 if a request was successfully received; 00079 0 otherwise. 00080 reqData is allocated with malloc(hdr->len). 00081 */ 00082 int CcsServer_recvRequest(CcsImplHeader *hdr,void **reqData); 00083 00084 /*Send a Ccs reply down the given socket. 00085 Closes the socket afterwards. 00086 */ 00087 void CcsServer_sendReply(CcsImplHeader *hdr,int repBytes,const void *repData); 00088 00089 /*No request will be sent through this socket. 00090 Closes it. 00091 */ 00092 void CcsServer_noReply(CcsImplHeader *hdr); 00093 00094 #else /*CCS not available*/ 00095 00096 #define CcsServer_new(i,p) /*empty*/ 00097 #define CcsServer_fd() SOCKET_ERROR 00098 #define CcsServer_recvReq(h,b) 0 00099 #define CcsServer_sendReply(f,l,d) /*empty*/ 00100 #define CcsServer_noReply(f) /*empty*/ 00101 #define CcsImpl_kill() /*empty*/ 00102 #endif /*CCS available*/ 00103 00104 #ifdef __cplusplus 00105 } 00106 #endif 00107 #endif