Monero
Loading...
Searching...
No Matches
miniupnpc-libevent.h
Go to the documentation of this file.
1/* $Id: miniupnpc-libevent.h,v 1.13 2015/07/22 13:48:37 nanard Exp $ */
2/* miniupnpc-libevent
3 * Copyright (c) 2008-2015, 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_LIBEVENT_H_INCLUDED
18#define MINIUPNPC_LIBEVENT_H_INCLUDED
19
20#include <event2/event.h>
21
22#include "declspec.h"
23#include "upnpreplyparse.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#define MINIUPNPC_LIBEVENT_API_VERSION 1
30
31#define UPNPC_OK 0
32#define UPNPC_ERR_INVALID_ARGS (-1)
33#define UPNPC_ERR_SOCKET_FAILED (-2)
34#define UPNPC_ERR_BIND_FAILED (-3)
35#define UPNPC_ERR_REQ_IN_PROGRESS (-4)
36
37#define UPNPC_ERR_NO_DEVICE_FOUND (-100)
38#define UPNPC_ERR_ROOT_DESC_ERROR (-101)
39#define UPNPC_ERR_NOT_IGD (-102)
40#define UPNPC_ERR_NOT_CONNECTED (-103)
41
42/* device->state masks */
43#define UPNPC_DEVICE_SOAP_REQ (0x0001)
44#define UPNPC_DEVICE_GETSTATUS (0x0002)
45#define UPNPC_DEVICE_CONNECTED (0x4000)
46#define UPNPC_DEVICE_READY (0x8000)
47
48typedef struct upnpc_device upnpc_device_t;
49typedef struct upnpc upnpc_t;
50
51typedef void(* upnpc_callback_fn)(int, upnpc_t *, upnpc_device_t *, void *);
52#ifdef ENABLE_UPNP_EVENTS
53typedef void(* upnpc_event_callback_fn)(upnpc_t *, upnpc_device_t *, void *, const char *, const char *, const char *);
54#endif /* ENABLE_UPNP_EVENTS */
55
56struct upnpc_device {
59 char * root_desc_location;
60 struct evhttp_connection * desc_conn;
61 char * control_cif_url;
64 char * control_conn_url;
67 struct evhttp_connection * soap_conn;
69 unsigned int state;
70#ifdef ENABLE_UPNP_EVENTS
71 char * event_conn_sid;
72#endif /* ENABLE_UPNP_EVENTS */
73};
74
75struct upnpc {
76 struct event_base * base;
77 evutil_socket_t ssdp_socket;
84 void * cb_data;
85#ifdef ENABLE_UPNP_EVENTS
86 struct evhttp * http_server;
87 upnpc_event_callback_fn value_changed_cb;
88#endif /* ENABLE_UPNP_EVENTS */
91 unsigned char ttl;
92};
93
94int upnpc_init(upnpc_t * p, struct event_base * base, const char * multicastif,
95 upnpc_callback_fn ready_cb, upnpc_callback_fn soap_cb, void * cb_data);
96
97int upnpc_set_local_address(upnpc_t * p, const char * address, uint16_t port);
98
99#ifdef ENABLE_UPNP_EVENTS
100int upnpc_set_event_callback(upnpc_t * p, upnpc_event_callback_fn cb);
101#endif /* ENABLE_UPNP_EVENTS */
102
103int upnpc_start(upnpc_t * p);
104
105int upnpc_finalize(upnpc_t * p);
106
107#ifdef ENABLE_UPNP_EVENTS
108int upnpc_event_subscribe(upnpc_device_t * p);
109#endif /* ENABLE_UPNP_EVENTS */
110
112
114
116 const char * remote_host, unsigned short ext_port,
117 unsigned short int_port, const char * int_client,
118 const char * proto, const char * description,
119 unsigned int lease_duration);
120
122 const char * remote_host, unsigned short ext_port,
123 const char * proto);
124
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif /* MINIUPNPC_LIBEVENT_H_INCLUDED */
132
uint32_t address
Definition getifaddr.c:269
struct upnpc_device upnpc_device_t
int upnpc_get_status_info(upnpc_device_t *p)
Definition miniupnpc-libevent.c:1048
int upnpc_finalize(upnpc_t *p)
Definition miniupnpc-async.c:814
int upnpc_init(upnpc_t *p, struct event_base *base, const char *multicastif, upnpc_callback_fn ready_cb, upnpc_callback_fn soap_cb, void *cb_data)
Definition miniupnpc-libevent.c:751
int upnpc_get_link_layer_max_rate(upnpc_device_t *p)
Definition miniupnpc-async.c:855
int upnpc_start(upnpc_t *p)
Definition miniupnpc-libevent.c:813
int upnpc_add_port_mapping(upnpc_device_t *p, const char *remote_host, unsigned short ext_port, unsigned short int_port, const char *int_client, const char *proto, const char *description, unsigned int lease_duration)
Definition miniupnpc-async.c:865
void(* upnpc_callback_fn)(int, upnpc_t *, upnpc_device_t *, void *)
Definition miniupnpc-libevent.h:51
int upnpc_set_local_address(upnpc_t *p, const char *address, uint16_t port)
Definition miniupnpc-libevent.c:836
int upnpc_delete_port_mapping(upnpc_device_t *p, const char *remote_host, unsigned short ext_port, const char *proto)
Definition miniupnpc-libevent.c:988
int upnpc_get_external_ip_address(upnpc_device_t *p)
Definition miniupnpc-async.c:845
struct upnpc upnpc_t
Definition miniupnpc-libevent.h:49
Definition base.py:1
unsigned short uint16_t
Definition stdint.h:125
Definition upnpreplyparse.h:21
Definition minixmlvalid.c:15
Definition miniupnpc-async.h:43
char * cif_service_type
Definition miniupnpc-libevent.h:63
struct NameValueParserData soap_response_data
Definition miniupnpc-async.h:71
struct evhttp_connection * desc_conn
Definition miniupnpc-libevent.h:60
upnpc_t * parent
Definition miniupnpc-libevent.h:57
char * conn_service_type
Definition miniupnpc-libevent.h:66
char * event_cif_url
Definition miniupnpc-libevent.h:62
struct upnpc_device * next
Definition miniupnpc-async.h:44
char * control_cif_url
Definition miniupnpc-async.h:58
char * event_conn_url
Definition miniupnpc-libevent.h:65
char * root_desc_location
Definition miniupnpc-async.h:57
enum upnpc_device::@141230116256174032210074057037153206176156165173 state
char * control_conn_url
Definition miniupnpc-async.h:59
struct evhttp_connection * soap_conn
Definition miniupnpc-libevent.h:67
Definition miniupnpc-async.h:76
Definition miniupnpc-libevent.h:75
int discover_device_index
Definition miniupnpc-libevent.h:80
char * local_address
Definition miniupnpc-libevent.h:89
upnpc_callback_fn soap_cb
Definition miniupnpc-libevent.h:83
struct event * ev_ssdp_recv
Definition miniupnpc-libevent.h:78
struct event * ev_ssdp_writable
Definition miniupnpc-libevent.h:79
evutil_socket_t ssdp_socket
Definition miniupnpc-libevent.h:77
upnpc_device_t * devices
Definition miniupnpc-libevent.h:81
upnpc_callback_fn ready_cb
Definition miniupnpc-libevent.h:82
void * cb_data
Definition miniupnpc-libevent.h:84
unsigned char ttl
Definition miniupnpc-libevent.h:91
uint16_t local_port
Definition miniupnpc-libevent.h:90