"Fossies" - the Fresh Open Source Software Archive

Member "minidlna-1.3.0/upnphttp.h" (24 Nov 2020, 5435 Bytes) of package /linux/privat/minidlna-1.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "upnphttp.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.2.1_vs_1.3.0.

    1 /* MiniDLNA project
    2  *
    3  * http://sourceforge.net/projects/minidlna/
    4  *
    5  * MiniDLNA media server
    6  * Copyright (C) 2008-2012  Justin Maggard
    7  *
    8  * This file is part of MiniDLNA.
    9  *
   10  * MiniDLNA is free software; you can redistribute it and/or modify
   11  * it under the terms of the GNU General Public License version 2 as
   12  * published by the Free Software Foundation.
   13  *
   14  * MiniDLNA is distributed in the hope that it will be useful,
   15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17  * GNU General Public License for more details.
   18  *
   19  * You should have received a copy of the GNU General Public License
   20  * along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
   21  *
   22  * Portions of the code from the MiniUPnP project:
   23  *
   24  * Copyright (c) 2006-2007, Thomas Bernard
   25  * All rights reserved.
   26  *
   27  * Redistribution and use in source and binary forms, with or without
   28  * modification, are permitted provided that the following conditions are met:
   29  *     * Redistributions of source code must retain the above copyright
   30  *       notice, this list of conditions and the following disclaimer.
   31  *     * Redistributions in binary form must reproduce the above copyright
   32  *       notice, this list of conditions and the following disclaimer in the
   33  *       documentation and/or other materials provided with the distribution.
   34  *     * The name of the author may not be used to endorse or promote products
   35  *       derived from this software without specific prior written permission.
   36  *
   37  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   38  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   39  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   40  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
   41  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   42  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   43  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   44  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   45  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   46  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   47  * POSSIBILITY OF SUCH DAMAGE.
   48  */
   49 #ifndef __UPNPHTTP_H__
   50 #define __UPNPHTTP_H__
   51 
   52 #include <netinet/in.h>
   53 #include <sys/queue.h>
   54 
   55 #include "minidlnatypes.h"
   56 #include "config.h"
   57 
   58 /* server: HTTP header returned in all HTTP responses : */
   59 #define MINIDLNA_SERVER_STRING  OS_VERSION " DLNADOC/1.50 UPnP/1.0 " SERVER_NAME "/" MINIDLNA_VERSION
   60 
   61 /*
   62  states :
   63   0 - waiting for data to read
   64   1 - waiting for HTTP Post Content.
   65   ...
   66   >= 100 - to be deleted
   67 */
   68 enum httpCommands {
   69     EUnknown = 0,
   70     EGet,
   71     EPost,
   72     EHead,
   73     ESubscribe,
   74     EUnSubscribe
   75 };
   76 
   77 struct upnphttp {
   78     struct event ev;
   79     struct in_addr clientaddr;  /* client address */
   80     int iface;
   81     int state;
   82     char HttpVer[16];
   83     /* request */
   84     char * req_buf;
   85     int req_buflen;
   86     int req_contentlen;
   87     int req_contentoff;     /* header length */
   88     enum httpCommands req_command;
   89     struct client_cache_s * req_client;
   90     const char * req_soapAction;
   91     int req_soapActionLen;
   92     const char * req_Callback;  /* For SUBSCRIBE */
   93     int req_CallbackLen;
   94     const char * req_NT;
   95     int req_NTLen;
   96     int req_Timeout;
   97     const char * req_SID;       /* For UNSUBSCRIBE */
   98     int req_SIDLen;
   99     off_t req_RangeStart;
  100     off_t req_RangeEnd;
  101     long int req_chunklen;
  102     uint32_t reqflags;
  103     /* response */
  104     char * res_buf;
  105     int res_buflen;
  106     int res_buf_alloclen;
  107     uint32_t respflags;
  108     /*int res_contentlen;*/
  109     /*int res_contentoff;*/     /* header length */
  110     LIST_ENTRY(upnphttp) entries;
  111 };
  112 
  113 #define FLAG_TIMEOUT            0x00000001
  114 #define FLAG_SID                0x00000002
  115 #define FLAG_RANGE              0x00000004
  116 #define FLAG_HOST               0x00000008
  117 #define FLAG_LANGUAGE           0x00000010
  118 
  119 #define FLAG_INVALID_REQ        0x00000040
  120 #define FLAG_HTML               0x00000080
  121 
  122 #define FLAG_CHUNKED            0x00000100
  123 #define FLAG_TIMESEEK           0x00000200
  124 #define FLAG_REALTIMEINFO       0x00000400
  125 #define FLAG_PLAYSPEED          0x00000800
  126 #define FLAG_XFERSTREAMING      0x00001000
  127 #define FLAG_XFERINTERACTIVE    0x00002000
  128 #define FLAG_XFERBACKGROUND     0x00004000
  129 #define FLAG_CAPTION            0x00008000
  130 
  131 #ifndef MSG_MORE
  132 #define MSG_MORE 0
  133 #endif
  134 
  135 /* New_upnphttp() */
  136 struct upnphttp *
  137 New_upnphttp(int);
  138 
  139 /* CloseSocket_upnphttp() */
  140 void
  141 CloseSocket_upnphttp(struct upnphttp *);
  142 
  143 /* Delete_upnphttp() */
  144 void
  145 Delete_upnphttp(struct upnphttp *);
  146 
  147 /* BuildHeader_upnphttp()
  148  * build the header for the HTTP Response
  149  * also allocate the buffer for body data */
  150 void
  151 BuildHeader_upnphttp(struct upnphttp * h, int respcode,
  152                      const char * respmsg,
  153                      int bodylen);
  154 
  155 /* BuildResp_upnphttp() 
  156  * fill the res_buf buffer with the complete
  157  * HTTP 200 OK response from the body passed as argument */
  158 void
  159 BuildResp_upnphttp(struct upnphttp *, const char *, int);
  160 
  161 /* BuildResp2_upnphttp()
  162  * same but with given response code/message */
  163 void
  164 BuildResp2_upnphttp(struct upnphttp * h, int respcode,
  165                     const char * respmsg,
  166                     const char * body, int bodylen);
  167 
  168 /* Error messages */
  169 void
  170 Send500(struct upnphttp *);
  171 void
  172 Send501(struct upnphttp *);
  173 
  174 /* SendResp_upnphttp() */
  175 void
  176 SendResp_upnphttp(struct upnphttp *);
  177 
  178 #endif
  179