1 /* $Id: testupnpdescgen.c,v 1.29 2012/04/30 21:08:00 nanard Exp $ */
3 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4 * (c) 2006-2012 Thomas Bernard
5 * This software is subject to the conditions detailed
6 * in the LICENCE file provided within the distribution */
13 #include <sys/types.h>
18 #include "upnpdescgen.h"
20 char uuidvalue
[] = "uuid:12345678-0000-0000-0000-00000000abcd";
21 char serialnumber
[] = "12345678";
22 char modelnumber
[] = "1";
23 char presentationurl
[] = "http://192.168.0.1:8080/";
24 /*char presentationurl[] = "";*/
25 char friendly_name
[] = OS_NAME
" router";
27 char * use_ext_ip_addr
= NULL
;
28 const char * ext_if_name
= "eth0";
30 #ifdef ENABLE_6FC_SERVICE
31 int ipv6fc_firewall_enabled
= 1;
32 int ipv6fc_inbound_pinhole_allowed
= 1;
35 int getifaddr(const char * ifname
, char * buf
, int len
)
38 strncpy(buf
, "1.2.3.4", len
);
42 int upnp_get_portmapping_number_of_entries(void)
47 int get_wan_connection_status(const char * ifname
)
55 xml_pretty_print(const char * s
, int len
, FILE * f
)
69 if(len
>0 && *s
== '/')
71 else if(len
>0 && *s
== '?')
80 for(i
=indent
; i
>0; i
--)
90 /*fputc('\n', f); n++; */
95 else if(elt_close
== 0)
99 /* remove existing LF */
109 const char * str1
= "Prefix123String";
110 const char * str2
= "123String";
112 void stupid_test(void)
114 printf("str1:'%s' str2:'%s'\n", str1
, str2
);
115 printf("str1:%p str2:%p str2-str1:%ld\n", str1
, str2
, (long)(str2
-str1
));
121 main(int argc
, char * * argv
)
131 if(mkdir("testdescs", 0777) < 0) {
132 if(errno
!= EEXIST
) {
136 printf("Root Description :\n");
137 rootDesc
= genRootDesc(&rootDescLen
);
138 xml_pretty_print(rootDesc
, rootDescLen
, stdout
);
139 f
= fopen("testdescs/rootdesc.xml", "w");
141 xml_pretty_print(rootDesc
, rootDescLen
, f
);
145 printf("\n-------------\n");
146 printf("WANIPConnection Description :\n");
148 xml_pretty_print(s
, l
, stdout
);
149 f
= fopen("testdescs/wanipc_scpd.xml", "w");
151 xml_pretty_print(s
, l
, f
);
155 printf("\n-------------\n");
156 printf("WANConfig Description :\n");
158 xml_pretty_print(s
, l
, stdout
);
159 f
= fopen("testdescs/wanconfig_scpd.xml", "w");
161 xml_pretty_print(s
, l
, f
);
165 printf("\n-------------\n");
166 #ifdef ENABLE_L3F_SERVICE
167 printf("Layer3Forwarding service :\n");
169 xml_pretty_print(s
, l
, stdout
);
170 f
= fopen("testdescs/l3f_scpd.xml", "w");
172 xml_pretty_print(s
, l
, f
);
176 printf("\n-------------\n");
178 #ifdef ENABLE_6FC_SERVICE
179 printf("WANIPv6FirewallControl service :\n");
181 xml_pretty_print(s
, l
, stdout
);
182 f
= fopen("testdescs/wanipv6fc_scpd.xml", "w");
184 xml_pretty_print(s
, l
, f
);
188 printf("\n-------------\n");
190 #ifdef ENABLE_DP_SERVICE
191 printf("DeviceProtection service :\n");
193 xml_pretty_print(s
, l
, stdout
);
194 f
= fopen("testdescs/dp_scpd.xml", "w");
196 xml_pretty_print(s
, l
, f
);
200 printf("\n-------------\n");
203 s
= getVarsWANIPCn(&l
);
204 xml_pretty_print(s
, l
, stdout
);
206 printf("\n-------------\n");
207 s
= getVarsWANCfg(&l
);
208 xml_pretty_print(s
, l
, stdout
);
210 printf("\n-------------\n");
211 #ifdef ENABLE_L3F_SERVICE
213 xml_pretty_print(s
, l
, stdout
);
215 printf("\n-------------\n");
216 #ifdef ENABLE_6FC_SERVICE
218 xml_pretty_print(s
, l
, stdout
);
220 printf("\n-------------\n");
222 #ifdef ENABLE_DP_SERVICE
224 xml_pretty_print(s
, l
, stdout
);
226 printf("\n-------------\n");