Annotation of embedaddon/miniupnpd/miniupnpc-async/miniupnpc-async.h, revision 1.1.1.1
1.1 misho 1: /* $Id: miniupnpc-async.h,v 1.13 2014/11/07 11:25:52 nanard Exp $ */
2: /* miniupnpc-async
3: * Copyright (c) 2008-2017, Thomas BERNARD <miniupnp@free.fr>
4: * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
5: *
6: * Permission to use, copy, modify, and/or distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
17: #ifndef MINIUPNPC_ASYNC_H_INCLUDED
18: #define MINIUPNPC_ASYNC_H_INCLUDED
19:
20: /* for struct sockaddr_storage */
21: #include <netinet/in.h>
22: /* for fd_set */
23: #include <sys/select.h>
24:
25: #include "declspec.h"
26: #include "upnpreplyparse.h"
27:
28: #ifdef __cplusplus
29: extern "C" {
30: #endif
31:
32: #define UPNPC_OK 0
33: #define UPNPC_ERR_INVALID_ARGS (-1)
34: #define UPNPC_ERR_SOCKET_FAILED (-2)
35: #define UPNPC_ERR_BIND_FAILED (-3)
36: #define UPNPC_ERR_UNKNOWN_STATE (-4)
37:
38: #define UPNPC_SSDP_READABLE 0x0001
39: #define UPNPC_SSDP_WRITEABLE 0x0100
40: #define UPNPC_HTTP_READABLE 0x0002
41: #define UPNPC_HTTP_WRITEABLE 0x0200
42:
43: typedef struct upnpc_device {
44: struct upnpc_device * next;
45: enum {
46: EDevInit = 1,
47: EDevGetDescConnect,
48: EDevGetDescRequest,
49: EDevGetDescResponse,
50: EDevReady,
51: EDevSoapConnect,
52: EDevSoapRequest,
53: EDevSoapResponse,
54: EDevFinalized = 99,
55: EDevError = 1000
56: } state;
57: char * root_desc_location;
58: char * control_cif_url;
59: char * control_conn_url;
60: int http_socket;
61: int socket_flags; /* see UPNPC_*_READABLE, etc. */
62: char * http_request;
63: int http_request_len;
64: int http_request_sent;
65: char * http_response;
66: int http_response_received;
67: int http_response_end_of_headers;
68: int http_response_content_length;
69: int http_response_chunked;
70: int http_response_code;
71: struct NameValueParserData soap_response_data;
72: struct sockaddr_storage selfaddr;
73: socklen_t selfaddrlen;
74: } upnpc_device_t;
75:
76: typedef struct {
77: enum {
78: EUPnPInit = 1,
79: EUPnPSendSSDP,
80: EUPnPReceiveSSDP,
81: EUPnPGetDesc,
82: EUPnPReady,
83: EUPnPProcessing,
84: EUPnPFinalized = 99,
85: EUPnPError = 1000
86: } state;
87: int socket_flags; /* see UPNPC_*_READABLE, etc. */
88: int ssdp_socket;
89: upnpc_device_t * device_list;
90: } upnpc_t;
91:
92: int upnpc_init(upnpc_t * p, const char * multicastif);
93:
94: int upnpc_finalize(upnpc_t * p);
95:
96: int upnpc_get_external_ip_address(upnpc_device_t * p);
97:
98: int upnpc_get_link_layer_max_rate(upnpc_device_t * p);
99:
100: int upnpc_add_port_mapping(upnpc_device_t * p,
101: const char * remote_host, unsigned short ext_port,
102: unsigned short int_port, const char * int_client,
103: const char * proto, const char * description,
104: unsigned int lease_duration);
105:
106: #ifdef UPNPC_USE_SELECT
107: int upnpc_select_fds(upnpc_t * p, int * nfds, fd_set * readfds, fd_set * writefds);
108: void upnpc_check_select_fds(upnpc_t * p, const fd_set * readfds, const fd_set * writefds);
109: #endif /* UPNPC_USE_SELECT */
110:
111: int upnpc_process(upnpc_t * p);
112:
113: #ifdef __cplusplus
114: }
115: #endif
116:
117: #endif /* MINIUPNPC_ASYNC_H_INCLUDED */
118:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>