~ubuntu-branches/ubuntu/precise/miniupnpc/precise

« back to all changes in this revision

Viewing changes to upnpcommands.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Goirand
  • Date: 2010-12-29 16:49:20 UTC
  • Revision ID: james.westby@ubuntu.com-20101229164920-vltq442q9tny283z
Tags: upstream-1.4.20101221
ImportĀ upstreamĀ versionĀ 1.4.20101221

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: upnpcommands.h,v 1.18 2010/06/09 10:59:09 nanard Exp $ */
 
2
/* Miniupnp project : http://miniupnp.free.fr/
 
3
 * Author : Thomas Bernard
 
4
 * Copyright (c) 2005-2010 Thomas Bernard
 
5
 * This software is subject to the conditions detailed in the
 
6
 * LICENCE file provided within this distribution */
 
7
#ifndef __UPNPCOMMANDS_H__
 
8
#define __UPNPCOMMANDS_H__
 
9
 
 
10
#include "upnpreplyparse.h"
 
11
#include "declspec.h"
 
12
 
 
13
/* MiniUPnPc return codes : */
 
14
#define UPNPCOMMAND_SUCCESS (0)
 
15
#define UPNPCOMMAND_UNKNOWN_ERROR (-1)
 
16
#define UPNPCOMMAND_INVALID_ARGS (-2)
 
17
#define UPNPCOMMAND_HTTP_ERROR (-3)
 
18
 
 
19
#ifdef __cplusplus
 
20
extern "C" {
 
21
#endif
 
22
 
 
23
#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
 
24
#define UNSIGNED_INTEGER unsigned long long
 
25
#define STRTOUI strtoull
 
26
#else
 
27
#define UNSIGNED_INTEGER unsigned int
 
28
#define STRTOUI strtoul
 
29
#endif
 
30
 
 
31
LIBSPEC UNSIGNED_INTEGER
 
32
UPNP_GetTotalBytesSent(const char * controlURL,
 
33
                                        const char * servicetype);
 
34
 
 
35
LIBSPEC UNSIGNED_INTEGER
 
36
UPNP_GetTotalBytesReceived(const char * controlURL,
 
37
                                                const char * servicetype);
 
38
 
 
39
LIBSPEC UNSIGNED_INTEGER
 
40
UPNP_GetTotalPacketsSent(const char * controlURL,
 
41
                                        const char * servicetype);
 
42
 
 
43
LIBSPEC UNSIGNED_INTEGER
 
44
UPNP_GetTotalPacketsReceived(const char * controlURL,
 
45
                                        const char * servicetype);
 
46
 
 
47
/* UPNP_GetStatusInfo()
 
48
 * status and lastconnerror are 64 byte buffers
 
49
 * Return values :
 
50
 * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
 
51
 * or a UPnP Error code */
 
52
LIBSPEC int
 
53
UPNP_GetStatusInfo(const char * controlURL,
 
54
                               const char * servicetype,
 
55
                                   char * status,
 
56
                                   unsigned int * uptime,
 
57
                   char * lastconnerror);
 
58
 
 
59
/* UPNP_GetConnectionTypeInfo()
 
60
 * argument connectionType is a 64 character buffer
 
61
 * Return Values :
 
62
 * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
 
63
 * or a UPnP Error code */
 
64
LIBSPEC int
 
65
UPNP_GetConnectionTypeInfo(const char * controlURL,
 
66
                           const char * servicetype,
 
67
                                                   char * connectionType);
 
68
 
 
69
/* UPNP_GetExternalIPAddress() call the corresponding UPNP method.
 
70
 * if the third arg is not null the value is copied to it.
 
71
 * at least 16 bytes must be available 
 
72
 *
 
73
 * Return values :
 
74
 * 0 : SUCCESS
 
75
 * NON ZERO : ERROR Either an UPnP error code or an unknown error.
 
76
 * 
 
77
 * possible UPnP Errors :
 
78
 * 402 Invalid Args - See UPnP Device Architecture section on Control.
 
79
 * 501 Action Failed - See UPnP Device Architecture section on Control. */
 
80
LIBSPEC int
 
81
UPNP_GetExternalIPAddress(const char * controlURL,
 
82
                          const char * servicetype,
 
83
                          char * extIpAdd);
 
84
 
 
85
/* UPNP_GetLinkLayerMaxBitRates()
 
86
 * call WANCommonInterfaceConfig:1#GetCommonLinkProperties
 
87
 *
 
88
 * return values :
 
89
 * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
 
90
 * or a UPnP Error Code. */
 
91
LIBSPEC int
 
92
UPNP_GetLinkLayerMaxBitRates(const char* controlURL,
 
93
                                                        const char* servicetype,
 
94
                                                        unsigned int * bitrateDown,
 
95
                                                        unsigned int * bitrateUp);
 
96
 
 
97
/* UPNP_AddPortMapping()
 
98
 * if desc is NULL, it will be defaulted to "libminiupnpc"
 
99
 * remoteHost is usually NULL because IGD don't support it.
 
100
 *
 
101
 * Return values :
 
102
 * 0 : SUCCESS
 
103
 * NON ZERO : ERROR. Either an UPnP error code or an unknown error.
 
104
 * 
 
105
 * List of possible UPnP errors for AddPortMapping :
 
106
 * errorCode errorDescription (short) - Description (long)
 
107
 * 402 Invalid Args - See UPnP Device Architecture section on Control.
 
108
 * 501 Action Failed - See UPnP Device Architecture section on Control.
 
109
 * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be
 
110
 *                                   wild-carded
 
111
 * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded
 
112
 * 718 ConflictInMappingEntry - The port mapping entry specified conflicts
 
113
 *                     with a mapping assigned previously to another client
 
114
 * 724 SamePortValuesRequired - Internal and External port values
 
115
 *                              must be the same 
 
116
 * 725 OnlyPermanentLeasesSupported - The NAT implementation only supports
 
117
 *                  permanent lease times on port mappings
 
118
 * 726 RemoteHostOnlySupportsWildcard - RemoteHost must be a wildcard
 
119
 *                             and cannot be a specific IP address or DNS name
 
120
 * 727 ExternalPortOnlySupportsWildcard - ExternalPort must be a wildcard and
 
121
 *                                        cannot be a specific port value */
 
122
LIBSPEC int
 
123
UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
 
124
                    const char * extPort,
 
125
                                    const char * inPort,
 
126
                                        const char * inClient,
 
127
                                        const char * desc,
 
128
                    const char * proto,
 
129
                    const char * remoteHost);
 
130
 
 
131
/* UPNP_DeletePortMapping()
 
132
 * Use same argument values as what was used for AddPortMapping().
 
133
 * remoteHost is usually NULL because IGD don't support it.
 
134
 * Return Values :
 
135
 * 0 : SUCCESS
 
136
 * NON ZERO : error. Either an UPnP error code or an undefined error.
 
137
 *
 
138
 * List of possible UPnP errors for DeletePortMapping :
 
139
 * 402 Invalid Args - See UPnP Device Architecture section on Control.
 
140
 * 714 NoSuchEntryInArray - The specified value does not exist in the array */
 
141
LIBSPEC int
 
142
UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
 
143
                       const char * extPort, const char * proto,
 
144
                       const char * remoteHost);
 
145
 
 
146
/* UPNP_GetPortMappingNumberOfEntries()
 
147
 * not supported by all routers */
 
148
LIBSPEC int
 
149
UPNP_GetPortMappingNumberOfEntries(const char* controlURL, const char* servicetype, unsigned int * num);
 
150
 
 
151
/* UPNP_GetSpecificPortMappingEntry retrieves an existing port mapping
 
152
 * the result is returned in the intClient and intPort strings
 
153
 * please provide 16 and 6 bytes of data
 
154
 *
 
155
 * return value :
 
156
 * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
 
157
 * or a UPnP Error Code. */
 
158
LIBSPEC int
 
159
UPNP_GetSpecificPortMappingEntry(const char * controlURL,
 
160
                                 const char * servicetype,
 
161
                                 const char * extPort,
 
162
                                 const char * proto,
 
163
                                 char * intClient,
 
164
                                 char * intPort);
 
165
 
 
166
/* UPNP_GetGenericPortMappingEntry()
 
167
 *
 
168
 * return value :
 
169
 * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
 
170
 * or a UPnP Error Code.
 
171
 *
 
172
 * Possible UPNP Error codes :
 
173
 * 402 Invalid Args - See UPnP Device Architecture section on Control.
 
174
 * 713 SpecifiedArrayIndexInvalid - The specified array index is out of bounds
 
175
 */
 
176
LIBSPEC int
 
177
UPNP_GetGenericPortMappingEntry(const char * controlURL,
 
178
                                const char * servicetype,
 
179
                                                                const char * index,
 
180
                                                                char * extPort,
 
181
                                                                char * intClient,
 
182
                                                                char * intPort,
 
183
                                                                char * protocol,
 
184
                                                                char * desc,
 
185
                                                                char * enabled,
 
186
                                                                char * rHost,
 
187
                                                                char * duration);
 
188
 
 
189
#ifdef __cplusplus
 
190
}
 
191
#endif
 
192
 
 
193
#endif
 
194