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