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__
10
#include "upnpreplyparse.h"
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)
23
#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
24
#define UNSIGNED_INTEGER unsigned long long
25
#define STRTOUI strtoull
27
#define UNSIGNED_INTEGER unsigned int
28
#define STRTOUI strtoul
31
LIBSPEC UNSIGNED_INTEGER
32
UPNP_GetTotalBytesSent(const char * controlURL,
33
const char * servicetype);
35
LIBSPEC UNSIGNED_INTEGER
36
UPNP_GetTotalBytesReceived(const char * controlURL,
37
const char * servicetype);
39
LIBSPEC UNSIGNED_INTEGER
40
UPNP_GetTotalPacketsSent(const char * controlURL,
41
const char * servicetype);
43
LIBSPEC UNSIGNED_INTEGER
44
UPNP_GetTotalPacketsReceived(const char * controlURL,
45
const char * servicetype);
47
/* UPNP_GetStatusInfo()
48
* status and lastconnerror are 64 byte buffers
50
* UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
51
* or a UPnP Error code */
53
UPNP_GetStatusInfo(const char * controlURL,
54
const char * servicetype,
56
unsigned int * uptime,
57
char * lastconnerror);
59
/* UPNP_GetConnectionTypeInfo()
60
* argument connectionType is a 64 character buffer
62
* UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
63
* or a UPnP Error code */
65
UPNP_GetConnectionTypeInfo(const char * controlURL,
66
const char * servicetype,
67
char * connectionType);
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
75
* NON ZERO : ERROR Either an UPnP error code or an unknown error.
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. */
81
UPNP_GetExternalIPAddress(const char * controlURL,
82
const char * servicetype,
85
/* UPNP_GetLinkLayerMaxBitRates()
86
* call WANCommonInterfaceConfig:1#GetCommonLinkProperties
89
* UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
90
* or a UPnP Error Code. */
92
UPNP_GetLinkLayerMaxBitRates(const char* controlURL,
93
const char* servicetype,
94
unsigned int * bitrateDown,
95
unsigned int * bitrateUp);
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.
103
* NON ZERO : ERROR. Either an UPnP error code or an unknown error.
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
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
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 */
123
UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
124
const char * extPort,
126
const char * inClient,
129
const char * remoteHost);
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.
136
* NON ZERO : error. Either an UPnP error code or an undefined error.
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 */
142
UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
143
const char * extPort, const char * proto,
144
const char * remoteHost);
146
/* UPNP_GetPortMappingNumberOfEntries()
147
* not supported by all routers */
149
UPNP_GetPortMappingNumberOfEntries(const char* controlURL, const char* servicetype, unsigned int * num);
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
156
* UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
157
* or a UPnP Error Code. */
159
UPNP_GetSpecificPortMappingEntry(const char * controlURL,
160
const char * servicetype,
161
const char * extPort,
166
/* UPNP_GetGenericPortMappingEntry()
169
* UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
170
* or a UPnP Error Code.
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
177
UPNP_GetGenericPortMappingEntry(const char * controlURL,
178
const char * servicetype,