Annotation of embedaddon/miniupnpd/upnphttp.h, revision 1.1.1.3

1.1.1.3 ! misho       1: /* $Id: upnphttp.h,v 1.35 2012/10/03 21:03:50 nanard Exp $ */
1.1       misho       2: /* MiniUPnP project
                      3:  * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
1.1.1.3 ! misho       4:  * (c) 2006-2012 Thomas Bernard
1.1       misho       5:  * This software is subject to the conditions detailed
                      6:  * in the LICENCE file provided within the distribution */
                      7: 
1.1.1.3 ! misho       8: #ifndef UPNPHTTP_H_INCLUDED
        !             9: #define UPNPHTTP_H_INCLUDED
1.1       misho      10: 
                     11: #include <netinet/in.h>
                     12: #include <sys/queue.h>
                     13: 
                     14: #include "config.h"
                     15: 
1.1.1.3 ! misho      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: 
1.1       misho      24: /* server: HTTP header returned in all HTTP responses : */
1.1.1.3 ! misho      25: #define MINIUPNPD_SERVER_STRING        OS_VERSION " " UPNP_VERSION_STRING " MiniUPnPd/" MINIUPNPD_VERSION
1.1       misho      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: */
1.1.1.3 ! misho      34: enum httpStates {
        !            35:        EWaitingForHttpRequest = 0,
        !            36:        EWaitingForHttpContent,
        !            37:        ESendingContinue,
        !            38:        ESendingAndClosing,
        !            39:        EToDelete = 100
        !            40: };
        !            41: 
1.1       misho      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 */
1.1.1.2   misho      53: #ifdef ENABLE_IPV6
                     54:        int ipv6;
                     55:        struct in6_addr clientaddr_v6;
                     56: #endif
1.1.1.3 ! misho      57:        enum httpStates state;
1.1       misho      58:        char HttpVer[16];
                     59:        /* request */
                     60:        char * req_buf;
1.1.1.3 ! misho      61:        char accept_language[8];
1.1       misho      62:        int req_buflen;
                     63:        int req_contentlen;
                     64:        int req_contentoff;     /* header length */
                     65:        enum httpCommands req_command;
1.1.1.3 ! misho      66:        int req_soapActionOff;
1.1       misho      67:        int req_soapActionLen;
                     68: #ifdef ENABLE_EVENTS
1.1.1.3 ! misho      69:        int req_CallbackOff;    /* For SUBSCRIBE */
1.1       misho      70:        int req_CallbackLen;
                     71:        int req_Timeout;
1.1.1.3 ! misho      72:        int req_SIDOff;         /* For UNSUBSCRIBE */
1.1       misho      73:        int req_SIDLen;
1.1.1.3 ! misho      74:        const char * res_SID;
        !            75: #ifdef UPNP_STRICT
        !            76:        int req_NTOff;
        !            77:        int req_NTLen;
        !            78: #endif
1.1       misho      79: #endif
1.1.1.2   misho      80:        int respflags;                          /* see FLAG_* constants below */
1.1       misho      81:        /* response */
                     82:        char * res_buf;
                     83:        int res_buflen;
1.1.1.3 ! misho      84:        int res_sent;
1.1       misho      85:        int res_buf_alloclen;
                     86:        LIST_ENTRY(upnphttp) entries;
                     87: };
                     88: 
1.1.1.2   misho      89: /* Include the "Timeout:" header in response */
1.1       misho      90: #define FLAG_TIMEOUT   0x01
1.1.1.2   misho      91: /* Include the "SID:" header in response */
1.1       misho      92: #define FLAG_SID               0x02
                     93: 
1.1.1.3 ! misho      94: /* If set, the POST request included a "Expect: 100-continue" header */
        !            95: #define FLAG_CONTINUE  0x40
        !            96: 
1.1.1.2   misho      97: /* If set, the Content-Type is set to text/xml, otherwise it is text/xml */
1.1       misho      98: #define FLAG_HTML              0x80
                     99: 
1.1.1.3 ! misho     100: /* If set, the corresponding Allow: header is set */
        !           101: #define FLAG_ALLOW_POST                        0x100
        !           102: #define FLAG_ALLOW_SUB_UNSUB   0x200
        !           103: 
        !           104: 
1.1       misho     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: 
1.1.1.3 ! misho     129: /* BuildResp_upnphttp()
1.1       misho     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: 
1.1.1.3 ! misho     142: int
1.1       misho     143: SendResp_upnphttp(struct upnphttp *);
                    144: 
1.1.1.3 ! misho     145: /* SendRespAndClose_upnphttp() */
        !           146: void
        !           147: SendRespAndClose_upnphttp(struct upnphttp *);
        !           148: 
1.1       misho     149: #endif
                    150: 

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