aboutsummaryrefslogtreecommitdiff
path: root/src/nat/miniupnp/igd_desc_parse.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-09-01 13:36:01 +0000
committerChristian Grothoff <christian@grothoff.org>2010-09-01 13:36:01 +0000
commit75bf71e92c81b966df11ad3c00228658f46a6e8f (patch)
tree610fecea7e6ce4b4bfda0f3a205f355dd0ef30be /src/nat/miniupnp/igd_desc_parse.c
parentc09f6eb6d32f57778cf8f8baf0456cbe7158eb79 (diff)
downloadgnunet-75bf71e92c81b966df11ad3c00228658f46a6e8f.tar.gz
gnunet-75bf71e92c81b966df11ad3c00228658f46a6e8f.zip
starting NAT code cleanup
Diffstat (limited to 'src/nat/miniupnp/igd_desc_parse.c')
-rw-r--r--src/nat/miniupnp/igd_desc_parse.c126
1 files changed, 0 insertions, 126 deletions
diff --git a/src/nat/miniupnp/igd_desc_parse.c b/src/nat/miniupnp/igd_desc_parse.c
deleted file mode 100644
index deb53152c..000000000
--- a/src/nat/miniupnp/igd_desc_parse.c
+++ /dev/null
@@ -1,126 +0,0 @@
1/* $Id: igd_desc_parse.c,v 1.8 2008/04/23 11:51:06 nanard Exp $ */
2/* Project : miniupnp
3 * http://miniupnp.free.fr/
4 * Author : Thomas Bernard
5 * Copyright (c) 2005-2008 Thomas Bernard
6 * This software is subject to the conditions detailed in the
7 * LICENCE file provided in this distribution.
8 * */
9#include "igd_desc_parse.h"
10#include <stdio.h>
11#include <string.h>
12
13/* TODO : rewrite this code so it correctly handle descriptions with
14 * both WANIPConnection and/or WANPPPConnection */
15
16/* Start element handler :
17 * update nesting level counter and copy element name */
18void
19IGDstartelt (void *d, const char *name, int l)
20{
21 struct IGDdatas *datas = (struct IGDdatas *) d;
22 memcpy (datas->cureltname, name, l);
23 datas->cureltname[l] = '\0';
24 datas->level++;
25 if ((l == 7) && !memcmp (name, "service", l))
26 {
27 datas->controlurl_tmp[0] = '\0';
28 datas->eventsuburl_tmp[0] = '\0';
29 datas->scpdurl_tmp[0] = '\0';
30 datas->servicetype_tmp[0] = '\0';
31 }
32}
33
34/* End element handler :
35 * update nesting level counter and update parser state if
36 * service element is parsed */
37void
38IGDendelt (void *d, const char *name, int l)
39{
40 struct IGDdatas *datas = (struct IGDdatas *) d;
41 datas->level--;
42 /*printf("endelt %2d %.*s\n", datas->level, l, name); */
43 if ((l == 7) && !memcmp (name, "service", l))
44 {
45 /*
46 if( datas->state < 1
47 && !strcmp(datas->servicetype,
48 // "urn:schemas-upnp-org:service:WANIPConnection:1") )
49 "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"))
50 datas->state ++;
51 */
52 if (0 == strcmp (datas->servicetype_tmp,
53 "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"))
54 {
55 memcpy (datas->controlurl_CIF, datas->controlurl_tmp,
56 MINIUPNPC_URL_MAXSIZE);
57 memcpy (datas->eventsuburl_CIF, datas->eventsuburl_tmp,
58 MINIUPNPC_URL_MAXSIZE);
59 memcpy (datas->scpdurl_CIF, datas->scpdurl_tmp,
60 MINIUPNPC_URL_MAXSIZE);
61 memcpy (datas->servicetype_CIF, datas->servicetype_tmp,
62 MINIUPNPC_URL_MAXSIZE);
63 }
64 else if (0 == strcmp (datas->servicetype_tmp,
65 "urn:schemas-upnp-org:service:WANIPConnection:1")
66 || 0 == strcmp (datas->servicetype_tmp,
67 "urn:schemas-upnp-org:service:WANPPPConnection:1"))
68 {
69 memcpy (datas->controlurl, datas->controlurl_tmp,
70 MINIUPNPC_URL_MAXSIZE);
71 memcpy (datas->eventsuburl, datas->eventsuburl_tmp,
72 MINIUPNPC_URL_MAXSIZE);
73 memcpy (datas->scpdurl, datas->scpdurl_tmp, MINIUPNPC_URL_MAXSIZE);
74 memcpy (datas->servicetype, datas->servicetype_tmp,
75 MINIUPNPC_URL_MAXSIZE);
76 }
77 }
78}
79
80/* Data handler :
81 * copy data depending on the current element name and state */
82void
83IGDdata (void *d, const char *data, int l)
84{
85 struct IGDdatas *datas = (struct IGDdatas *) d;
86 char *dstmember = 0;
87 /*printf("%2d %s : %.*s\n",
88 datas->level, datas->cureltname, l, data); */
89 if (!strcmp (datas->cureltname, "URLBase"))
90 dstmember = datas->urlbase;
91 else if (!strcmp (datas->cureltname, "serviceType"))
92 dstmember = datas->servicetype_tmp;
93 else if (!strcmp (datas->cureltname, "controlURL"))
94 dstmember = datas->controlurl_tmp;
95 else if (!strcmp (datas->cureltname, "eventSubURL"))
96 dstmember = datas->eventsuburl_tmp;
97 else if (!strcmp (datas->cureltname, "SCPDURL"))
98 dstmember = datas->scpdurl_tmp;
99/* else if( !strcmp(datas->cureltname, "deviceType") )
100 dstmember = datas->devicetype_tmp;*/
101 if (dstmember)
102 {
103 if (l >= MINIUPNPC_URL_MAXSIZE)
104 l = MINIUPNPC_URL_MAXSIZE - 1;
105 memcpy (dstmember, data, l);
106 dstmember[l] = '\0';
107 }
108}
109
110void
111printIGD (struct IGDdatas *d)
112{
113 printf ("urlbase = %s\n", d->urlbase);
114 printf ("WAN Device (Common interface config) :\n");
115 /*printf(" deviceType = %s\n", d->devicetype_CIF); */
116 printf (" serviceType = %s\n", d->servicetype_CIF);
117 printf (" controlURL = %s\n", d->controlurl_CIF);
118 printf (" eventSubURL = %s\n", d->eventsuburl_CIF);
119 printf (" SCPDURL = %s\n", d->scpdurl_CIF);
120 printf ("WAN Connection Device (IP or PPP Connection):\n");
121 /*printf(" deviceType = %s\n", d->devicetype); */
122 printf (" servicetype = %s\n", d->servicetype);
123 printf (" controlURL = %s\n", d->controlurl);
124 printf (" eventSubURL = %s\n", d->eventsuburl);
125 printf (" SCPDURL = %s\n", d->scpdurl);
126}