File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / miniupnpd / upnphttp.h
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 00:32:35 2013 UTC (10 years, 10 months ago) by misho
Branches: miniupnpd, elwix, MAIN
CVS tags: v1_8p0, v1_8, HEAD
1.8

    1: /* $Id: upnphttp.h,v 1.1.1.3 2013/07/22 00:32:35 misho Exp $ */
    2: /* MiniUPnP project
    3:  * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
    4:  * (c) 2006-2012 Thomas Bernard
    5:  * This software is subject to the conditions detailed
    6:  * in the LICENCE file provided within the distribution */
    7: 
    8: #ifndef UPNPHTTP_H_INCLUDED
    9: #define UPNPHTTP_H_INCLUDED
   10: 
   11: #include <netinet/in.h>
   12: #include <sys/queue.h>
   13: 
   14: #include "config.h"
   15: 
   16: #if 0
   17: /* according to "UPnP Device Architecture 1.0" */
   18: #define UPNP_VERSION_STRING "UPnP/1.0"
   19: #else
   20: /* according to "UPnP Device Architecture 1.1" */
   21: #define UPNP_VERSION_STRING "UPnP/1.1"
   22: #endif
   23: 
   24: /* server: HTTP header returned in all HTTP responses : */
   25: #define MINIUPNPD_SERVER_STRING	OS_VERSION " " UPNP_VERSION_STRING " MiniUPnPd/" MINIUPNPD_VERSION
   26: 
   27: /*
   28:  states :
   29:   0 - waiting for data to read
   30:   1 - waiting for HTTP Post Content.
   31:   ...
   32:   >= 100 - to be deleted
   33: */
   34: enum httpStates {
   35: 	EWaitingForHttpRequest = 0,
   36: 	EWaitingForHttpContent,
   37: 	ESendingContinue,
   38: 	ESendingAndClosing,
   39: 	EToDelete = 100
   40: };
   41: 
   42: enum httpCommands {
   43: 	EUnknown = 0,
   44: 	EGet,
   45: 	EPost,
   46: 	ESubscribe,
   47: 	EUnSubscribe
   48: };
   49: 
   50: struct upnphttp {
   51: 	int socket;
   52: 	struct in_addr clientaddr;	/* client address */
   53: #ifdef ENABLE_IPV6
   54: 	int ipv6;
   55: 	struct in6_addr clientaddr_v6;
   56: #endif
   57: 	enum httpStates state;
   58: 	char HttpVer[16];
   59: 	/* request */
   60: 	char * req_buf;
   61: 	char accept_language[8];
   62: 	int req_buflen;
   63: 	int req_contentlen;
   64: 	int req_contentoff;     /* header length */
   65: 	enum httpCommands req_command;
   66: 	int req_soapActionOff;
   67: 	int req_soapActionLen;
   68: #ifdef ENABLE_EVENTS
   69: 	int req_CallbackOff;	/* For SUBSCRIBE */
   70: 	int req_CallbackLen;
   71: 	int req_Timeout;
   72: 	int req_SIDOff;		/* For UNSUBSCRIBE */
   73: 	int req_SIDLen;
   74: 	const char * res_SID;
   75: #ifdef UPNP_STRICT
   76: 	int req_NTOff;
   77: 	int req_NTLen;
   78: #endif
   79: #endif
   80: 	int respflags;				/* see FLAG_* constants below */
   81: 	/* response */
   82: 	char * res_buf;
   83: 	int res_buflen;
   84: 	int res_sent;
   85: 	int res_buf_alloclen;
   86: 	LIST_ENTRY(upnphttp) entries;
   87: };
   88: 
   89: /* Include the "Timeout:" header in response */
   90: #define FLAG_TIMEOUT	0x01
   91: /* Include the "SID:" header in response */
   92: #define FLAG_SID		0x02
   93: 
   94: /* If set, the POST request included a "Expect: 100-continue" header */
   95: #define FLAG_CONTINUE	0x40
   96: 
   97: /* If set, the Content-Type is set to text/xml, otherwise it is text/xml */
   98: #define FLAG_HTML		0x80
   99: 
  100: /* If set, the corresponding Allow: header is set */
  101: #define FLAG_ALLOW_POST			0x100
  102: #define FLAG_ALLOW_SUB_UNSUB	0x200
  103: 
  104: 
  105: /* New_upnphttp() */
  106: struct upnphttp *
  107: New_upnphttp(int);
  108: 
  109: /* CloseSocket_upnphttp() */
  110: void
  111: CloseSocket_upnphttp(struct upnphttp *);
  112: 
  113: /* Delete_upnphttp() */
  114: void
  115: Delete_upnphttp(struct upnphttp *);
  116: 
  117: /* Process_upnphttp() */
  118: void
  119: Process_upnphttp(struct upnphttp *);
  120: 
  121: /* BuildHeader_upnphttp()
  122:  * build the header for the HTTP Response
  123:  * also allocate the buffer for body data */
  124: void
  125: BuildHeader_upnphttp(struct upnphttp * h, int respcode,
  126:                      const char * respmsg,
  127:                      int bodylen);
  128: 
  129: /* BuildResp_upnphttp()
  130:  * fill the res_buf buffer with the complete
  131:  * HTTP 200 OK response from the body passed as argument */
  132: void
  133: BuildResp_upnphttp(struct upnphttp *, const char *, int);
  134: 
  135: /* BuildResp2_upnphttp()
  136:  * same but with given response code/message */
  137: void
  138: BuildResp2_upnphttp(struct upnphttp * h, int respcode,
  139:                     const char * respmsg,
  140:                     const char * body, int bodylen);
  141: 
  142: int
  143: SendResp_upnphttp(struct upnphttp *);
  144: 
  145: /* SendRespAndClose_upnphttp() */
  146: void
  147: SendRespAndClose_upnphttp(struct upnphttp *);
  148: 
  149: #endif
  150: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>