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