00001 00002 // 00003 // Copyright (c) 2000-2003 Intel Corporation 00004 // All rights reserved. 00005 // 00006 // Redistribution and use in source and binary forms, with or without 00007 // modification, are permitted provided that the following conditions are met: 00008 // 00009 // * Redistributions of source code must retain the above copyright notice, 00010 // this list of conditions and the following disclaimer. 00011 // * Redistributions in binary form must reproduce the above copyright notice, 00012 // this list of conditions and the following disclaimer in the documentation 00013 // and/or other materials provided with the distribution. 00014 // * Neither name of Intel Corporation nor the names of its contributors 00015 // may be used to endorse or promote products derived from this software 00016 // without specific prior written permission. 00017 // 00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR 00022 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00025 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00026 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00027 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 // 00031 00032 #ifndef MINISERVER_H 00033 #define MINISERVER_H 00034 00035 #include "sock.h" 00036 #include "httpparser.h" 00037 00038 extern SOCKET gMiniServerStopSock; 00039 00040 typedef struct MServerSockArray { 00041 int miniServerSock; //socket for listening for miniserver 00042 //requests 00043 int miniServerStopSock; //socket for stopping miniserver 00044 int ssdpSock; //socket for incoming advertisments and search requests 00045 00046 int stopPort; 00047 int miniServerPort; 00048 00049 CLIENTONLY(int ssdpReqSock;) //socket for sending search 00050 //requests and receiving 00051 // search replies 00052 00053 } MiniServerSockArray; 00054 00055 //typedef void (*MiniServerCallback) ( const char* document, int sockfd ); 00056 00057 typedef void (*MiniServerCallback) ( IN http_parser_t *parser, 00058 IN http_message_t* request, 00059 IN SOCKINFO *info ); 00060 00061 #ifdef __cplusplus 00062 extern "C" { 00063 #endif 00064 00065 /************************************************************************ 00066 * Function : SetHTTPGetCallback 00067 * 00068 * Parameters : 00069 * MiniServerCallback callback ; - HTTP Callback to be invoked 00070 * 00071 * Description : Set HTTP Get Callback 00072 * 00073 * Return : void 00074 * 00075 * Note : 00076 ************************************************************************/ 00077 void SetHTTPGetCallback( MiniServerCallback callback ); 00078 00079 /************************************************************************ 00080 * Function : SetSoapCallback 00081 * 00082 * Parameters : 00083 * MiniServerCallback callback ; - SOAP Callback to be invoked 00084 * 00085 * Description : Set SOAP Callback 00086 * 00087 * Return : void 00088 * 00089 * Note : 00090 ************************************************************************/ 00091 void SetSoapCallback( MiniServerCallback callback ); 00092 00093 /************************************************************************ 00094 * Function : SetGenaCallback 00095 * 00096 * Parameters : 00097 * MiniServerCallback callback ; - GENA Callback to be invoked 00098 * 00099 * Description : Set GENA Callback 00100 * 00101 * Return : void 00102 * 00103 * Note : 00104 ************************************************************************/ 00105 void SetGenaCallback( MiniServerCallback callback ); 00106 00107 /************************************************************************ 00108 * Function : StartMiniServer 00109 * 00110 * Parameters : 00111 * unsigned short listen_port ; Port on which the server listens for 00112 * incoming connections 00113 * 00114 * Description : Initialize the sockets functionality for the 00115 * Miniserver. Initialize a thread pool job to run the MiniServer 00116 * and the job to the thread pool. If listen port is 0, port is 00117 * dynamically picked 00118 * 00119 * Use timer mechanism to start the MiniServer, failure to meet the 00120 * allowed delay aborts the attempt to launch the MiniServer. 00121 * 00122 * Return : int ; 00123 * Actual port socket is bound to - On Success: 00124 * A negative number UPNP_E_XXX - On Error 00125 * Note : 00126 ************************************************************************/ 00127 int StartMiniServer( unsigned short listen_port ); 00128 00129 /************************************************************************ 00130 * Function : StopMiniServer 00131 * 00132 * Parameters : 00133 * void ; 00134 * 00135 * Description : Stop and Shutdown the MiniServer and free socket 00136 * resources. 00137 * 00138 * Return : int ; 00139 * Always returns 0 00140 * 00141 * Note : 00142 ************************************************************************/ 00143 int StopMiniServer( void ); 00144 00145 00146 #ifdef __cplusplus 00147 } /* extern C */ 00148 #endif 00149 00150 #endif /* MINISERVER_H */
1.6.1