1 | /*
|
---|
2 | * TINET (TCP/IP Protocol Stack)
|
---|
3 | *
|
---|
4 | * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
|
---|
5 | * Tomakomai National College of Technology, JAPAN
|
---|
6 | *
|
---|
7 | * ä¸è¨èä½æ¨©è
|
---|
8 | ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
9 | * ã«ãã£ã¦å
|
---|
10 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
11 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
12 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
13 | å¸ï¼ä»¥ä¸ï¼
|
---|
14 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
15 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
16 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
17 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
18 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
19 | * ç¨ã§ããå½¢ã§åé
|
---|
20 | å¸ããå ´åã«ã¯ï¼åé
|
---|
21 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
22 | * è
|
---|
23 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
24 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
25 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
26 | * ç¨ã§ããªãå½¢ã§åé
|
---|
27 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
|
---|
28 | * (a) åé
|
---|
29 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
30 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
31 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
32 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
33 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
34 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
35 | 責ãããã¨ï¼
|
---|
36 | *
|
---|
37 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
38 | ã
|
---|
39 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
40 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
41 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
42 | *
|
---|
43 | * @(#) $Id: wwws.c 388 2019-05-22 11:25:18Z coas-nagasima $
|
---|
44 | */
|
---|
45 |
|
---|
46 | /*
|
---|
47 | * WWW ãµã¼ã
|
---|
48 | *
|
---|
49 | * ã»éåä¿¡ã¿ã¹ã¯åä¸å
|
---|
50 | * ã»ãã³ããããã³ã°ã³ã¼ã«
|
---|
51 | * ã»çã³ãã¼ API
|
---|
52 | * ã»IPv4/IPv6
|
---|
53 | */
|
---|
54 |
|
---|
55 | #include <stdlib.h>
|
---|
56 | #include <string.h>
|
---|
57 |
|
---|
58 | #ifdef TARGET_KERNEL_ASP
|
---|
59 |
|
---|
60 | #include <kernel.h>
|
---|
61 | #include <sil.h>
|
---|
62 | #include <t_syslog.h>
|
---|
63 | #include "kernel/kernel_impl.h"
|
---|
64 | #include "target_config.h"
|
---|
65 | #include "target_syssvc.h"
|
---|
66 | #include "target_stddef.h"
|
---|
67 | #include "kernel_cfg.h"
|
---|
68 | #include "tinet_cfg.h"
|
---|
69 |
|
---|
70 | #endif /* of #ifdef TARGET_KERNEL_ASP */
|
---|
71 |
|
---|
72 | #ifdef TARGET_KERNEL_JSP
|
---|
73 |
|
---|
74 | #include <s_services.h>
|
---|
75 | #include <t_services.h>
|
---|
76 | #include "kernel_id.h"
|
---|
77 | #include "tinet_id.h"
|
---|
78 |
|
---|
79 | #endif /* of #ifdef TARGET_KERNEL_JSP */
|
---|
80 |
|
---|
81 | #include <tinet_defs.h>
|
---|
82 | #include <tinet_config.h>
|
---|
83 |
|
---|
84 | #include <net/if.h>
|
---|
85 | #include <net/if_ppp.h>
|
---|
86 | #include <net/if_loop.h>
|
---|
87 | #include <net/ethernet.h>
|
---|
88 | #include <net/net.h>
|
---|
89 | #include <net/net_endian.h>
|
---|
90 | #include <net/net_buf.h>
|
---|
91 | #include <net/net_count.h>
|
---|
92 |
|
---|
93 | #include <netinet/in.h>
|
---|
94 | #include <netinet/in_itron.h>
|
---|
95 |
|
---|
96 | #include <netapp/netapp.h>
|
---|
97 | #include <netapp/netapp_var.h>
|
---|
98 | #include <netapp/wwws.h>
|
---|
99 |
|
---|
100 | #ifdef USE_WWW_SRV
|
---|
101 |
|
---|
102 | /*
|
---|
103 | * éåä¿¡ API ã®é¸æ
|
---|
104 | */
|
---|
105 |
|
---|
106 | #define EOF (-1)
|
---|
107 |
|
---|
108 | typedef struct file {
|
---|
109 | ER (*func)(ID cepid, T_WWW_RWBUF *srbuf);
|
---|
110 | char *uri;
|
---|
111 | } T_FILE;
|
---|
112 |
|
---|
113 | typedef struct status {
|
---|
114 | uint16_t code;
|
---|
115 | uint8_t *reason;
|
---|
116 | } T_STATUS;
|
---|
117 |
|
---|
118 | /*
|
---|
119 | * é¢æ°
|
---|
120 | */
|
---|
121 |
|
---|
122 | static ER index_html(ID cepid, T_WWW_RWBUF *srbuf);
|
---|
123 |
|
---|
124 | #if NET_COUNT_ENABLE
|
---|
125 |
|
---|
126 | static ER stat_html(ID cepid, T_WWW_RWBUF *srbuf);
|
---|
127 |
|
---|
128 | #endif /* of #if NET_COUNT_ENABLE */
|
---|
129 |
|
---|
130 | #ifdef USE_TCP_EXTENTIONS
|
---|
131 |
|
---|
132 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
|
---|
133 |
|
---|
134 | #if NUM_WWW_SRV_TASKS >= 2 /* 2 ãè¶
|
---|
135 | ããåæ°ã¯æ³å®ãã¦ããªãã */
|
---|
136 |
|
---|
137 | #define WWW4_SRV_TASK WWW_SRV_TASK1
|
---|
138 | #define WWW6_SRV_TASK WWW_SRV_TASK2
|
---|
139 |
|
---|
140 | #else /* of #if NUM_WWW_SRV_TASKS >= 2 */
|
---|
141 |
|
---|
142 | #define WWW4_SRV_TASK WWW_SRV_TASK1
|
---|
143 | #define WWW6_SRV_TASK WWW_SRV_TASK1
|
---|
144 |
|
---|
145 | #endif /* of #if NUM_WWW_SRV_TASKS >= 2 */
|
---|
146 |
|
---|
147 | #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
|
---|
148 |
|
---|
149 | #define WWW4_SRV_TASK WWW_SRV_TASK1
|
---|
150 | #define WWW6_SRV_TASK WWW_SRV_TASK1
|
---|
151 |
|
---|
152 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
|
---|
153 |
|
---|
154 | #endif /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
155 |
|
---|
156 |
|
---|
157 | /*
|
---|
158 | * å
|
---|
159 | ¨åå¤æ°
|
---|
160 | */
|
---|
161 |
|
---|
162 | /* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
|
---|
163 |
|
---|
164 | #ifndef TCP_CFG_SWBUF_CSAVE
|
---|
165 | uint8_t www_srv_swbuf[NUM_WWW_SRV_TASKS][WWW_SRV_SWBUF_SIZE];
|
---|
166 | #endif
|
---|
167 |
|
---|
168 | #ifndef TCP_CFG_RWBUF_CSAVE
|
---|
169 | uint8_t www_srv_rwbuf[NUM_WWW_SRV_TASKS][WWW_SRV_RWBUF_SIZE];
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | /*
|
---|
173 | * å¤æ°
|
---|
174 | */
|
---|
175 |
|
---|
176 | SYSTIM srv_start;
|
---|
177 |
|
---|
178 | static const T_FILE file[] = {
|
---|
179 | { index_html, "/" },
|
---|
180 | { index_html, "/index.html" },
|
---|
181 |
|
---|
182 | #if NET_COUNT_ENABLE
|
---|
183 |
|
---|
184 | { stat_html, "/stat.html" },
|
---|
185 |
|
---|
186 | #endif /* of #if NET_COUNT_ENABLE */
|
---|
187 | };
|
---|
188 |
|
---|
189 | #define NUM_FILES (sizeof(file) / sizeof(T_FILE))
|
---|
190 |
|
---|
191 | static const char *status[] = {
|
---|
192 | "200 OK",
|
---|
193 | "404 Not Found",
|
---|
194 | };
|
---|
195 |
|
---|
196 | #define NUM_STATUS (sizeof(status) / sizeof(T_STATUS))
|
---|
197 |
|
---|
198 | #define ST_OK 0
|
---|
199 | #define ST_NOT_FOUND 1
|
---|
200 |
|
---|
201 | /*
|
---|
202 | * æ¥ç¶ç¸æã®æ
|
---|
203 | å ±æ§é ä½
|
---|
204 | */
|
---|
205 |
|
---|
206 | #ifdef NUM_WWW4_SRV_TASKS
|
---|
207 | #undef NUM_WWW4_SRV_TASKS
|
---|
208 | #endif
|
---|
209 | #define NUM_WWW4_SRV_TASKS 1
|
---|
210 |
|
---|
211 | typedef struct t_www_srv_info {
|
---|
212 | ID cepid; /* éä¿¡ç«¯ç¹ ID */
|
---|
213 | ID repid; /* åä»å£ ID */
|
---|
214 | T_IPEP dst; /* æ¥ç¶ç¸æã¢ãã¬ã¹æ
|
---|
215 | å ± */
|
---|
216 | } T_WWW_SRV_INFO;
|
---|
217 |
|
---|
218 | #define INDEX_SRV_INFO(id) ((id)-1)
|
---|
219 |
|
---|
220 | #ifdef USE_TCP_EXTENTIONS
|
---|
221 |
|
---|
222 | static T_WWW_SRV_INFO www_srv_info[NUM_WWW_SRV_TASKS];
|
---|
223 | /* 2 ãè¶
|
---|
224 | ããåæ°ã¯æ³å®ãã¦ããªãã */
|
---|
225 |
|
---|
226 | #else /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
227 |
|
---|
228 | static T_WWW_SRV_INFO www_srv_info[] = {
|
---|
229 |
|
---|
230 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
|
---|
231 |
|
---|
232 | { WWW4_SRV_CEPID1, WWW4_SRV_REPID },
|
---|
233 |
|
---|
234 | #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
|
---|
235 |
|
---|
236 | { WWW_SRV_CEPID1, WWW_SRV_REPID },
|
---|
237 |
|
---|
238 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
|
---|
239 |
|
---|
240 | #if NUM_WWW_SRV_TASKS >= 2 /* 2 ãè¶
|
---|
241 | ããåæ°ã¯æ³å®ãã¦ããªãã */
|
---|
242 | { WWW_SRV_CEPID2, WWW_SRV_REPID },
|
---|
243 | #endif
|
---|
244 |
|
---|
245 | };
|
---|
246 |
|
---|
247 | #endif /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
248 |
|
---|
249 | #ifdef USE_COPYSAVE_API
|
---|
250 |
|
---|
251 | /*
|
---|
252 | * get_char -- ä¸æåå
|
---|
253 | ¥åããã
|
---|
254 | */
|
---|
255 |
|
---|
256 | static int_t
|
---|
257 | get_char (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
258 | {
|
---|
259 | int_t len, ch;
|
---|
260 | ER error;
|
---|
261 |
|
---|
262 | if (srbuf->unget) {
|
---|
263 | ch = srbuf->unget;
|
---|
264 | srbuf->unget = 0;
|
---|
265 | }
|
---|
266 | else {
|
---|
267 | if (srbuf->rbuf.index >= srbuf->rbuf.len) {
|
---|
268 | if ((error = tcp_rel_buf(cepid, srbuf->rbuf.len)) != E_OK)
|
---|
269 | syslog(LOG_WARNING, "[WWWn:%02u REL] tcp_rel_buf error: %s",
|
---|
270 | cepid, itron_strerror(error));
|
---|
271 | srbuf->rbuf.index = 0;
|
---|
272 | if ((len = tcp_rcv_buf(cepid, (void**)&srbuf->rbuf.buf, TMO_FEVR)) <= 0) {
|
---|
273 | if (len < 0)
|
---|
274 | syslog(LOG_WARNING, "[WWWn:%02u RCV] tcp_rcv_buf error: %s",
|
---|
275 | cepid, itron_strerror(len));
|
---|
276 | srbuf->rbuf.len = 0;
|
---|
277 | return EOF;
|
---|
278 | }
|
---|
279 | else
|
---|
280 | srbuf->rbuf.len = len;
|
---|
281 | }
|
---|
282 | ch = srbuf->rbuf.buf[srbuf->rbuf.index ++];
|
---|
283 | }
|
---|
284 | return ch;
|
---|
285 | }
|
---|
286 |
|
---|
287 | /*
|
---|
288 | * flush_sbuf -- éä¿¡ãããã¡ããã©ãã·ã¥ããã
|
---|
289 | */
|
---|
290 |
|
---|
291 | static ER
|
---|
292 | flush_sbuf (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
293 | {
|
---|
294 | ER_UINT error;
|
---|
295 |
|
---|
296 | error = tcp_snd_buf(cepid, srbuf->sbuf.index);
|
---|
297 | srbuf->sbuf.index = srbuf->sbuf.len = 0;
|
---|
298 |
|
---|
299 | return error;
|
---|
300 | }
|
---|
301 |
|
---|
302 | /*
|
---|
303 | * put_str -- æååãåºåããã
|
---|
304 | */
|
---|
305 |
|
---|
306 | static uint_t
|
---|
307 | put_str (ID cepid, T_WWW_RWBUF *srbuf, const char *str)
|
---|
308 | {
|
---|
309 | ER error;
|
---|
310 | ER_UINT blen;
|
---|
311 | uint16_t len, off = 0;
|
---|
312 |
|
---|
313 | len = strlen(str);
|
---|
314 | while (len > 0) {
|
---|
315 | if (srbuf->sbuf.index >= srbuf->sbuf.len)
|
---|
316 | if ((error = flush_sbuf(cepid, srbuf)) != E_OK) {
|
---|
317 | syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error));
|
---|
318 | return 0;
|
---|
319 | }
|
---|
320 |
|
---|
321 | if (srbuf->sbuf.len == 0) {
|
---|
322 | if ((blen = tcp_get_buf(cepid, (void**)&srbuf->sbuf.buf, TMO_FEVR)) < 0) {
|
---|
323 | syslog(LOG_WARNING, "[WWWn:%02u GET] error: %s", cepid, itron_strerror(srbuf->sbuf.len));
|
---|
324 | return 0;
|
---|
325 | }
|
---|
326 | srbuf->sbuf.len = (uint16_t)blen;
|
---|
327 | }
|
---|
328 |
|
---|
329 | if (len > srbuf->sbuf.len - srbuf->sbuf.index)
|
---|
330 | blen = srbuf->sbuf.len - srbuf->sbuf.index;
|
---|
331 | else
|
---|
332 | blen = len;
|
---|
333 | memcpy(&srbuf->sbuf.buf[srbuf->sbuf.index], str + off, blen);
|
---|
334 | srbuf->sbuf.index += (uint16_t)blen;
|
---|
335 | off += (uint16_t)blen;
|
---|
336 | len -= (uint16_t)blen;
|
---|
337 | }
|
---|
338 |
|
---|
339 | return off;
|
---|
340 | }
|
---|
341 |
|
---|
342 | #else /* of #ifdef USE_COPYSAVE_API */
|
---|
343 |
|
---|
344 | /*
|
---|
345 | * get_char -- ä¸æåå
|
---|
346 | ¥åããã
|
---|
347 | */
|
---|
348 |
|
---|
349 | static int_t
|
---|
350 | get_char (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
351 | {
|
---|
352 | int_t len, ch;
|
---|
353 |
|
---|
354 | if (srbuf->unget) {
|
---|
355 | ch = srbuf->unget;
|
---|
356 | srbuf->unget = 0;
|
---|
357 | }
|
---|
358 | else {
|
---|
359 | if (srbuf->rbuf.index >= srbuf->rbuf.len) {
|
---|
360 | if ((len = tcp_rcv_dat(cepid, srbuf->rbuf.buf, sizeof(srbuf->rbuf.buf), TMO_FEVR)) <= 0) {
|
---|
361 | if (len < 0) {
|
---|
362 | syslog(LOG_WARNING, "[WWWn:%02u RCV] error: %s",
|
---|
363 | cepid, itron_strerror(len));
|
---|
364 | }
|
---|
365 | return EOF;
|
---|
366 | }
|
---|
367 | else {
|
---|
368 | srbuf->rbuf.len = len;
|
---|
369 | srbuf->rbuf.index = 0;
|
---|
370 | }
|
---|
371 | }
|
---|
372 | ch = srbuf->rbuf.buf[srbuf->rbuf.index ++];
|
---|
373 | }
|
---|
374 | return ch;
|
---|
375 | }
|
---|
376 |
|
---|
377 | /*
|
---|
378 | * flush_sbuf -- éä¿¡ãããã¡ããã©ãã·ã¥ããã
|
---|
379 | */
|
---|
380 |
|
---|
381 | static ER
|
---|
382 | flush_sbuf (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
383 | {
|
---|
384 | ER_UINT len = E_OK;
|
---|
385 | uint16_t off = 0;
|
---|
386 |
|
---|
387 | while (off < srbuf->sbuf.index) {
|
---|
388 | if ((len = tcp_snd_dat(cepid, srbuf->sbuf.buf + off, srbuf->sbuf.index - off, TMO_FEVR)) < 0)
|
---|
389 | break;
|
---|
390 | off += len;
|
---|
391 | }
|
---|
392 | srbuf->sbuf.index = 0;
|
---|
393 |
|
---|
394 | return len < 0 ? len : E_OK;
|
---|
395 | }
|
---|
396 |
|
---|
397 | /*
|
---|
398 | * put_str -- æååãåºåããã
|
---|
399 | */
|
---|
400 |
|
---|
401 | static uint16_t
|
---|
402 | put_str (ID cepid, T_WWW_RWBUF *srbuf, const char *str)
|
---|
403 | {
|
---|
404 | ER error;
|
---|
405 | uint16_t blen, len, off = 0;
|
---|
406 |
|
---|
407 | len = strlen(str);
|
---|
408 | while (len > 0) {
|
---|
409 | if (srbuf->sbuf.index >= srbuf->sbuf.len)
|
---|
410 | if ((error = flush_sbuf(cepid, srbuf)) != E_OK) {
|
---|
411 | syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error));
|
---|
412 | return 0;
|
---|
413 | }
|
---|
414 | if (len > srbuf->sbuf.len - srbuf->sbuf.index)
|
---|
415 | blen = srbuf->sbuf.len - srbuf->sbuf.index;
|
---|
416 | else
|
---|
417 | blen = len;
|
---|
418 | memcpy(&srbuf->sbuf.buf[srbuf->sbuf.index], str + off, blen);
|
---|
419 | srbuf->sbuf.index += blen;
|
---|
420 | off += blen;
|
---|
421 | len -= blen;
|
---|
422 | }
|
---|
423 |
|
---|
424 | return off;
|
---|
425 | }
|
---|
426 |
|
---|
427 | #endif /* of #ifdef USE_COPYSAVE_API */
|
---|
428 |
|
---|
429 | /*
|
---|
430 | * get_line -- ä¸è¡å
|
---|
431 | ¥åããã
|
---|
432 | */
|
---|
433 |
|
---|
434 | static uint16_t
|
---|
435 | get_line (ID cepid, T_WWW_LINE *line, T_WWW_RWBUF *srbuf)
|
---|
436 | {
|
---|
437 | int_t ch = 0;
|
---|
438 | uint16_t len;
|
---|
439 | char *p, *t;
|
---|
440 |
|
---|
441 | p = line->buf;
|
---|
442 | t = line->buf + WWW_LINE_SIZE;
|
---|
443 | while (p < t && (ch = get_char(cepid, srbuf)) != EOF && ch != '\n' && ch != '\r')
|
---|
444 | *p ++ = ch;
|
---|
445 | *p = '\0';
|
---|
446 | len = p - line->buf;
|
---|
447 | if (p >= t) {
|
---|
448 | while ((ch = get_char(cepid, srbuf)) != EOF && ch != '\n' && ch != '\r')
|
---|
449 | len ++;
|
---|
450 | }
|
---|
451 | if (ch == '\r') {
|
---|
452 | len ++;
|
---|
453 | if ((ch = get_char(cepid, srbuf)) != EOF && ch != '\n')
|
---|
454 | srbuf->unget = ch;
|
---|
455 | }
|
---|
456 | if (ch == '\n')
|
---|
457 | len ++;
|
---|
458 | line->len = len;
|
---|
459 | return p - line->buf;
|
---|
460 | }
|
---|
461 |
|
---|
462 | #if NET_COUNT_ENABLE
|
---|
463 |
|
---|
464 | #ifdef _int64_
|
---|
465 | #define VAL_TYPE uint64_t
|
---|
466 | #else
|
---|
467 | #define VAL_TYPE uint32_t
|
---|
468 | #endif
|
---|
469 |
|
---|
470 | /*
|
---|
471 | * convert -- æ°å¤å¤æ
|
---|
472 | */
|
---|
473 |
|
---|
474 | static int_t
|
---|
475 | convert (char *buf, VAL_TYPE val, int_t radix, int_t width, bool_t minus, char padchar)
|
---|
476 | {
|
---|
477 | static const char radhex[] = "0123456789abcdef";
|
---|
478 |
|
---|
479 | char digits[23], *start;
|
---|
480 | int_t ix, pad;
|
---|
481 |
|
---|
482 | ix = 0;
|
---|
483 | start = buf;
|
---|
484 | do {
|
---|
485 | digits[ix ++] = radhex[val % radix];
|
---|
486 | val /= radix;
|
---|
487 | } while (val != 0);
|
---|
488 | if (minus)
|
---|
489 | digits[ix ++] = '-';
|
---|
490 | for (pad = ix; pad < width; pad ++)
|
---|
491 | *buf ++ = padchar;
|
---|
492 | while (ix -- > 0)
|
---|
493 | *buf ++ = digits[ix];
|
---|
494 | *buf = '\0';
|
---|
495 | return buf - start;
|
---|
496 | }
|
---|
497 |
|
---|
498 | #endif /* of #if NET_COUNT_ENABLE */
|
---|
499 |
|
---|
500 | /*
|
---|
501 | * split_fields -- ãã£ã¼ã«ãã«åå²ããã
|
---|
502 | */
|
---|
503 |
|
---|
504 | static void
|
---|
505 | split_fields (T_WWW_LINE *line, char *delim)
|
---|
506 | {
|
---|
507 | char *p, quote;
|
---|
508 | int_t ix = 0;
|
---|
509 |
|
---|
510 | line->off[ix ++] = 0;
|
---|
511 | for (p = line->buf; ix < WWW_NUM_FIELDS && *p; p ++) {
|
---|
512 | if (strchr("\"'`", *p) != NULL) {
|
---|
513 | for (quote = *p ++; *p && *p != quote; p ++)
|
---|
514 | ;
|
---|
515 | }
|
---|
516 | else if (strchr(delim, *p) != NULL) {
|
---|
517 | *p = '\0';
|
---|
518 | line->off[ix ++] = (uint8_t)(p - line->buf + 1);
|
---|
519 | }
|
---|
520 | }
|
---|
521 | line->num = ix;
|
---|
522 | }
|
---|
523 |
|
---|
524 | /*
|
---|
525 | * put_status -- status line ãåºåããã
|
---|
526 | */
|
---|
527 |
|
---|
528 | static uint16_t
|
---|
529 | put_status (ID cepid, T_WWW_RWBUF *srbuf, int_t index)
|
---|
530 | {
|
---|
531 | uint16_t len = 0;
|
---|
532 |
|
---|
533 | len += put_str(cepid, srbuf, "HTTP/1.0 ");
|
---|
534 | len += put_str(cepid, srbuf, status[index]);
|
---|
535 | len += put_str(cepid, srbuf, "\r\n");
|
---|
536 | return len;
|
---|
537 | }
|
---|
538 |
|
---|
539 | /*
|
---|
540 | * put_content_length -- Content-length ãåºåããã
|
---|
541 | */
|
---|
542 |
|
---|
543 | static uint16_t
|
---|
544 | put_content_length (ID cepid, T_WWW_RWBUF *srbuf, int_t content_len)
|
---|
545 | {
|
---|
546 | uint16_t len = 0;
|
---|
547 | #if 0
|
---|
548 | char length[TD_DIGITS + 1];
|
---|
549 |
|
---|
550 | convert(length, content_len, 10, 0, false, ' ');
|
---|
551 | len += put_str(cepid, srbuf, "Content-length: ");
|
---|
552 | len += put_str(cepid, srbuf, length);
|
---|
553 | len += put_str(cepid, srbuf, "\r\n");
|
---|
554 | #endif /* of #if 0 */
|
---|
555 | return len;
|
---|
556 | }
|
---|
557 |
|
---|
558 | /*
|
---|
559 | * get_method -- GET ã¡ã½ããã®å¦ç
|
---|
560 | */
|
---|
561 |
|
---|
562 | static ER
|
---|
563 | get_method (ID cepid, T_WWW_RWBUF *srbuf, T_WWW_LINE *line)
|
---|
564 | {
|
---|
565 | int_t ix;
|
---|
566 |
|
---|
567 | for (ix = NUM_FILES; ix -- > 0; ) {
|
---|
568 | if (!strcmp(file[ix].uri, &line->buf[line->off[1]])) {
|
---|
569 | //syslog(LOG_NOTICE, "[WWWn:%02u PTH] '%s'", cepid, &line->buf[line->off[1]]);
|
---|
570 | return (*file[ix].func)(cepid, srbuf);
|
---|
571 | }
|
---|
572 | }
|
---|
573 | put_status(cepid, srbuf, ST_NOT_FOUND);
|
---|
574 | return E_NOEXS;
|
---|
575 | }
|
---|
576 |
|
---|
577 | /*
|
---|
578 | * parse_request -- ãªã¯ã¨ã¹ãã解æããã
|
---|
579 | */
|
---|
580 |
|
---|
581 | static ER
|
---|
582 | parse_request (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
583 | {
|
---|
584 | T_WWW_LINE *method, *line;
|
---|
585 | ER error = E_OK;
|
---|
586 | int_t blen = 0;
|
---|
587 |
|
---|
588 | if ((error = tget_mpf(MPF_WWW_LINE, (void*)&method, TMO_FEVR)) != E_OK) {
|
---|
589 | syslog(LOG_CRIT, "[WWWn:%02u MPF] get line error: %s.",
|
---|
590 | cepid, itron_strerror(error));
|
---|
591 | return error;
|
---|
592 | }
|
---|
593 |
|
---|
594 | if (get_line(cepid, method, srbuf) == 0) {
|
---|
595 | if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
|
---|
596 | syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
|
---|
597 | cepid, itron_strerror(error));
|
---|
598 | return error;
|
---|
599 | }
|
---|
600 |
|
---|
601 | if ((error = tget_mpf(MPF_WWW_LINE, (void*)&line, TMO_FEVR)) != E_OK) {
|
---|
602 | syslog(LOG_CRIT, "[WWWn:%02u MPF] get line buffer error: %s.",
|
---|
603 | cepid, itron_strerror(error));
|
---|
604 | if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
|
---|
605 | syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
|
---|
606 | cepid, itron_strerror(error));
|
---|
607 | return error;
|
---|
608 | }
|
---|
609 |
|
---|
610 | while (get_line(cepid, line, srbuf) > 0) { /* ããããã¹ãããããã*/
|
---|
611 | split_fields(line, ": ");
|
---|
612 | if (strcmp("Content-Length", &line->buf[line->off[0]]) == 0)
|
---|
613 | blen = atoi(&line->buf[line->off[1]]);
|
---|
614 | }
|
---|
615 | while (blen > 0 && get_line(cepid, line, srbuf) > 0) {
|
---|
616 | /* ã¨ã³ãã£ãã£ã»ããã£ãã¹ãããããã*/
|
---|
617 | blen -= line->len;
|
---|
618 | }
|
---|
619 |
|
---|
620 | if ((error = rel_mpf(MPF_WWW_LINE, line)) != E_OK)
|
---|
621 | syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
|
---|
622 | cepid, itron_strerror(error));
|
---|
623 |
|
---|
624 | split_fields(method, ": ");
|
---|
625 | if (!strcmp(&method->buf[method->off[0]], "GET"))
|
---|
626 | error = get_method(cepid, srbuf, method);
|
---|
627 |
|
---|
628 | flush_sbuf(cepid, srbuf);
|
---|
629 |
|
---|
630 | if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
|
---|
631 | syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
|
---|
632 | cepid, itron_strerror(error));
|
---|
633 |
|
---|
634 | return error;
|
---|
635 | }
|
---|
636 |
|
---|
637 | /*
|
---|
638 | * index_html -- /index.html ãã¡ã¤ã«
|
---|
639 | */
|
---|
640 |
|
---|
641 | static ER
|
---|
642 | index_html (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
643 | {
|
---|
644 | static const char response[] =
|
---|
645 | "\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD html 3.2//EN\">\r\n"
|
---|
646 | "<html><head>\r\n"
|
---|
647 |
|
---|
648 | #ifdef TOPPERS_S810_CLG3_85
|
---|
649 | "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=Shift_JIS\">\r\n"
|
---|
650 | #else
|
---|
651 | "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=EUC-JP\">\r\n"
|
---|
652 | #endif
|
---|
653 |
|
---|
654 | "<title>TINET TCP/IP Protocol Stack</title>\r\n"
|
---|
655 | "</head><body bgcolor=\"#ffffbb\">\r\n"
|
---|
656 | "<hr>ãã® WWW ãµã¼ãã¯<br>"
|
---|
657 |
|
---|
658 | #ifdef TARGET_KERNEL_ASP
|
---|
659 | "ASP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") ã¨<br>\r\n"
|
---|
660 | #endif
|
---|
661 |
|
---|
662 | #ifdef TARGET_KERNEL_JSP
|
---|
663 | "JSP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") ã¨<br>\r\n"
|
---|
664 | #endif
|
---|
665 |
|
---|
666 | "TINET TCP/IP ãããã³ã«ã¹ã¿ãã¯ã«ãããµã¼ãã¹ãã¦ãã¾ãã<br><hr>\r\n"
|
---|
667 |
|
---|
668 | #if NET_COUNT_ENABLE
|
---|
669 |
|
---|
670 | "<ul><li type=\"square\"><a href=\"stat.html\">ãããã¯ã¼ã¯çµ±è¨æ
|
---|
671 | å ±</a></ul><hr>\r\n"
|
---|
672 |
|
---|
673 | #else /* of #if NET_COUNT_ENABLE */
|
---|
674 |
|
---|
675 | "<ul><li type=\"square\">ãããã¯ã¼ã¯çµ±è¨æ
|
---|
676 | å ±</ul><hr>\r\n"
|
---|
677 |
|
---|
678 | #endif /* of #if NET_COUNT_ENABLE */
|
---|
679 |
|
---|
680 | "FreeBSD: Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995<br>\r\n"
|
---|
681 | "The Regents of the University of California. All rights reserved.<br><br>\r\n"
|
---|
682 |
|
---|
683 | #ifdef SUPPORT_PPP
|
---|
684 |
|
---|
685 | "pppd: Copyright (c) 1989 Carnegie Mellon University.<br>\r\n"
|
---|
686 | "All rights reserved.<br><br>\r\n"
|
---|
687 | "ppp: Written by Toshiharu OHNO (tony-o@iij.ad.jp)<br>\r\n"
|
---|
688 | "Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.<br><br>\r\n"
|
---|
689 |
|
---|
690 | #endif /* of #ifdef SUPPORT_PPP */
|
---|
691 |
|
---|
692 | #ifdef SUPPORT_ETHER
|
---|
693 |
|
---|
694 | "if_ed: Copyright (c) 1995, David Greenman<br>\r\n"
|
---|
695 | "All rights reserved.<br><br>\r\n"
|
---|
696 |
|
---|
697 | #endif /* of #ifdef SUPPORT_ETHER */
|
---|
698 |
|
---|
699 | #ifdef TARGET_KERNEL_ASP
|
---|
700 | "TOPPERS/ASP Kernel<br>\r\n"
|
---|
701 | "Toyohashi Open Platform for Embedded Real-Time Systems/<br>\r\n"
|
---|
702 | "Advanced Standard Profile Kernel<br>\r\n"
|
---|
703 | "Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory<br>\r\n"
|
---|
704 | "Toyohashi Univ. of Technology, JAPAN<br>\r\n"
|
---|
705 | "Copyright (C) 2004-2008 by Embedded and Real-Time Systems Laboratory<br>\r\n"
|
---|
706 | "Graduate School of Information Science, Nagoya Univ., JAPAN<br><br>\r\n"
|
---|
707 | #endif /* of #ifdef TARGET_KERNEL_ASP */
|
---|
708 |
|
---|
709 | #ifdef TARGET_KERNEL_JSP
|
---|
710 | "TOPPERS/JSP Kernel<br>\r\n"
|
---|
711 | "Toyohashi Open Platform for Embedded Real-Time Systems/<br>\r\n"
|
---|
712 | "Just Standard Profile Kernel<br>\r\n"
|
---|
713 | "Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory<br>\r\n"
|
---|
714 | "Toyohashi Univ. of Technology, JAPAN<br>\r\n"
|
---|
715 | "Copyright (C) 2005 by Embedded and Real-Time Systems Laboratory<br>\r\n"
|
---|
716 | "Graduate School of Information Science, Nagoya Univ., JAPAN<br><br>\r\n"
|
---|
717 | #endif /* of #ifdef TARGET_KERNEL_JSP */
|
---|
718 |
|
---|
719 | "TINET (TCP/IP Protocol Stack)<br>\r\n"
|
---|
720 | "Copyright (C) 2001-2008 by Dep. of Computer Science and Engineering<br>\r\n"
|
---|
721 | "Tomakomai National College of Technology, JAPAN\r\n"
|
---|
722 | "</body></html>\r\n"
|
---|
723 | ;
|
---|
724 |
|
---|
725 | SYSTIM start, finish;
|
---|
726 | uint16_t len = 0;
|
---|
727 |
|
---|
728 | get_tim(&start);
|
---|
729 | len += put_status(cepid, srbuf, ST_OK);
|
---|
730 | len += put_content_length(cepid, srbuf, strlen(response) - 2); /* 2 ã¯æåã® \r\n */
|
---|
731 | len += put_str(cepid, srbuf, response);
|
---|
732 | get_tim(&finish);
|
---|
733 | syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [us]",
|
---|
734 | cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
|
---|
735 | return E_OK;
|
---|
736 | }
|
---|
737 |
|
---|
738 | #if NET_COUNT_ENABLE
|
---|
739 |
|
---|
740 | #define TD_TEMPLATE1 "<tr><td></td><td align=\"right\"></td>\r\n<td align=\"right\"></td>\r\n<td align=\"right\"></td>\r\n<td align=\"right\"></td>\r\n<td align=\"right\"></td>\r\n<td align=\"right\"></td></tr>\r\n"
|
---|
741 | #define TD_TEMPLATE2 "<tr><td></td><td align=\"right\"></td><td align=\"right\"></td></tr>\r\n"
|
---|
742 | #define TD_TEMPLATE3 "<tr><td></td><td align=\"right\"></td></tr>\r\n"
|
---|
743 | #define TD_TEMPLATE4 "<tr><td></td><td align=\"right\"></td><td align=\"right\"></td><td align=\"right\"></td></tr>\r\n"
|
---|
744 |
|
---|
745 | #define TD_LEN1(i) (sizeof(i) + sizeof(TD_TEMPLATE1) + TD_DIGITS * 6 - 2)
|
---|
746 | #define TD_LEN2(i) (sizeof(i) + sizeof(TD_TEMPLATE2) + TD_DIGITS * 2 - 2)
|
---|
747 | #define TD_LEN4(i) (sizeof(i) + sizeof(TD_TEMPLATE4) + TD_DIGITS * 3 - 2)
|
---|
748 | #define TD_DIGITS 20
|
---|
749 |
|
---|
750 | static const char time_prefix[] =
|
---|
751 | "çµéæé: "
|
---|
752 | ;
|
---|
753 |
|
---|
754 | static const char time_suffix[] =
|
---|
755 | "<hr>\r\n"
|
---|
756 | ;
|
---|
757 |
|
---|
758 | static const char table_suffix[] = "</table><br><hr>";
|
---|
759 |
|
---|
760 | #if defined(SUPPORT_INET4)
|
---|
761 |
|
---|
762 | static const char table_prefix_ip4[] =
|
---|
763 | "<h2>IPv4</h2><table border>\r\n"
|
---|
764 | "<tr><th>é
|
---|
765 | ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
|
---|
766 | ;
|
---|
767 |
|
---|
768 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
769 |
|
---|
770 | #if defined(SUPPORT_INET6)
|
---|
771 |
|
---|
772 | static const char table_prefix_ip6[] =
|
---|
773 | "<h2>IPv6</h2><table border>\r\n"
|
---|
774 | "<tr><th>é
|
---|
775 | ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
|
---|
776 | ;
|
---|
777 |
|
---|
778 | static const char table_prefix_icmp6[] =
|
---|
779 | "<h2>ICMPv6</h2><table border>\r\n"
|
---|
780 | "<tr><th>é
|
---|
781 | ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
|
---|
782 | ;
|
---|
783 |
|
---|
784 | static const char table_prefix_nd6[] =
|
---|
785 | "<h2>è¿é£æ¢ç´¢</h2><table border>\r\n"
|
---|
786 | "<tr><th>é
|
---|
787 | ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
|
---|
788 | ;
|
---|
789 |
|
---|
790 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
791 |
|
---|
792 | static const char table_prefix_tcp[] =
|
---|
793 | "<h2>TCP</h2><table border>\r\n"
|
---|
794 | "<tr><th>é
|
---|
795 | ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
|
---|
796 | ;
|
---|
797 |
|
---|
798 | static const char table_prefix_net_buf[] =
|
---|
799 | "<h2>ãããã¯ã¼ã¯ãããã¡</h2><table border>\r\n"
|
---|
800 | "<tr><th>ãµã¤ãº</th>"
|
---|
801 | "<th>ç¨ææ°</th>"
|
---|
802 | "<th>å²å½è¦æ±æ°</th>"
|
---|
803 | "<th>å²å½æ°</th>"
|
---|
804 | "<th>å²å½ã¦<br>ã¨ã©ã¼æ°</th></tr>\r\n"
|
---|
805 | ;
|
---|
806 |
|
---|
807 | #ifdef SUPPORT_PPP
|
---|
808 |
|
---|
809 | static const char table_prefix_ppp[] =
|
---|
810 | "<h2>PPP ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹</h2><table border>\r\n"
|
---|
811 | "<tr><th>é
|
---|
812 | ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
|
---|
813 | ;
|
---|
814 |
|
---|
815 | static const char *ppp_item[NC_PPP_SIZE] = {
|
---|
816 | "åä¿¡ãªã¯ãããæ°",
|
---|
817 | "éä¿¡ãªã¯ãããæ°",
|
---|
818 | "åä¿¡ãã¬ã¼ã æ°",
|
---|
819 | "éä¿¡ãã¬ã¼ã æ°",
|
---|
820 | "åä¿¡ã¨ã©ã¼ãã¬ã¼ã æ°",
|
---|
821 | "éä¿¡ã¨ã©ã¼ãã¬ã¼ã æ°",
|
---|
822 | "ãããã¡å²ãå½ã¦å¤±ææ°",
|
---|
823 | };
|
---|
824 |
|
---|
825 | #endif /* of #ifdef SUPPORT_PPP */
|
---|
826 |
|
---|
827 | #ifdef SUPPORT_ETHER
|
---|
828 |
|
---|
829 | static const char table_prefix_ether_nic[] =
|
---|
830 | "<h2>ã¤ã¼ãµãããã»ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹</h2><table border>\r\n"
|
---|
831 | "<tr><th>é
|
---|
832 | ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
|
---|
833 | ;
|
---|
834 |
|
---|
835 | static const char *ether_nic_item[NC_ETHER_NIC_SIZE] = {
|
---|
836 | "ãªã»ããæ°",
|
---|
837 | "éä¿¡ã»ããã©è³æºè¿å´ãªã¼ãã¼æ°",
|
---|
838 | "éä¿¡ã¿ã¤ã ã¢ã¦ãæ°",
|
---|
839 | "è¡çªæ°",
|
---|
840 | "éä¿¡ã¨ã©ã¼ãã¬ã¼ã æ°",
|
---|
841 | "éä¿¡ãã¬ã¼ã æ°",
|
---|
842 | "éä¿¡ãªã¯ãããæ°",
|
---|
843 | "åä¿¡ã»ããã©è³æºè¿å´ãªã¼ãã¼æ°",
|
---|
844 | "åä¿¡ãããã¡å²ãå½ã¦å¤±ææ°",
|
---|
845 | "åä¿¡ã¨ã©ã¼ãã¬ã¼ã æ°",
|
---|
846 | "åä¿¡ãã¬ã¼ã æ°",
|
---|
847 | "åä¿¡ãªã¯ãããæ°",
|
---|
848 | };
|
---|
849 |
|
---|
850 | #endif /* of #ifdef SUPPORT_ETHER */
|
---|
851 |
|
---|
852 | #if defined(SUPPORT_INET4)
|
---|
853 |
|
---|
854 | static const char *ip4_item[NC_IP4_SIZE] = {
|
---|
855 | "åå²éä¿¡ããã©ã°ã¡ã³ãæ°",
|
---|
856 | "åå²éä¿¡æ°",
|
---|
857 | "éä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°",
|
---|
858 | "éä¿¡ãã¼ã¿ã°ã©ã æ°",
|
---|
859 | "éä¿¡ãªã¯ãããæ°",
|
---|
860 | "åå²åä¿¡ã¿ã¤ã ã¢ã¦ãæ°",
|
---|
861 | "åå²åä¿¡ãããã¡å²ãå½ã¦å¤±ææ°",
|
---|
862 | "åå²åä¿¡ç ´æ£æ°",
|
---|
863 | "åå²åä¿¡åæ§ææåæ°",
|
---|
864 | "åå²åä¿¡ãã©ã°ã¡ã³ãæ°",
|
---|
865 | "åå²åä¿¡æ°",
|
---|
866 | "ãªãã·ã§ã³å
|
---|
867 | ¥åæ°",
|
---|
868 | "ãããã³ã«ã¨ã©ã¼æ°",
|
---|
869 | "ã¢ãã¬ã¹ã¨ã©ã¼æ°",
|
---|
870 | "ãã¼ã¸ã§ã³ã¨ã©ã¼æ°",
|
---|
871 | "é·ãã¨ã©ã¼æ°",
|
---|
872 | "ãã§ãã¯ãµã ã¨ã©ã¼æ°",
|
---|
873 | "åä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°",
|
---|
874 | "åä¿¡ãã¼ã¿ã°ã©ã æ°",
|
---|
875 | "åä¿¡ãªã¯ãããæ°",
|
---|
876 | };
|
---|
877 |
|
---|
878 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
879 |
|
---|
880 | #if defined(SUPPORT_INET6)
|
---|
881 |
|
---|
882 | static const char *ip6_item[NC_IP6_SIZE] = {
|
---|
883 | "åå²éä¿¡ããã©ã°ã¡ã³ãæ°",
|
---|
884 | "åå²éä¿¡æ°",
|
---|
885 | "éä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°",
|
---|
886 | "éä¿¡ãã¼ã¿ã°ã©ã æ°",
|
---|
887 | "éä¿¡ãªã¯ãããæ° ",
|
---|
888 | "åå²åä¿¡ã¿ã¤ã ã¢ã¦ãæ°",
|
---|
889 | "åå²åä¿¡ãããã¡å²ãå½ã¦å¤±ææ°",
|
---|
890 | "åå²åä¿¡ç ´æ£æ°",
|
---|
891 | "åå²åä¿¡åæ§ææåæ°",
|
---|
892 | "åå²åä¿¡ãã©ã°ã¡ã³ãæ°",
|
---|
893 | "åå²åä¿¡æ°",
|
---|
894 | "ãããã³ã«ã¨ã©ã¼æ° ",
|
---|
895 | "ã¢ãã¬ã¹ã¨ã©ã¼æ° ",
|
---|
896 | "ãã¼ã¸ã§ã³ã¨ã©ã¼æ° ",
|
---|
897 | "é·ãã¨ã©ã¼æ°",
|
---|
898 | "åä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°",
|
---|
899 | "åä¿¡ãã¼ã¿ã°ã©ã æ°",
|
---|
900 | "åä¿¡ãªã¯ãããæ° ",
|
---|
901 | };
|
---|
902 |
|
---|
903 | static const char *icmp6_item[NC_ICMP6_SIZE] = {
|
---|
904 | "éä¿¡ã¨ã©ã¼ ICMP ãã¼ã¿æ° ",
|
---|
905 | "éä¿¡ ICMP ãã¼ã¿æ°",
|
---|
906 | "éä¿¡ ICMP ãªã¯ãããæ°",
|
---|
907 | "é·ãã¨ã©ã¼æ°",
|
---|
908 | "åä¿¡ã¨ã©ã¼ ICMP ãã¼ã¿æ° ",
|
---|
909 | "åä¿¡ ICMP ãã¼ã¿æ°",
|
---|
910 | "åä¿¡ ICMP ãªã¯ãããæ°",
|
---|
911 | };
|
---|
912 |
|
---|
913 | static const char *nd6_item[NC_ND6_SIZE] = {
|
---|
914 | "éè¤ã¢ãã¬ã¹æ¤åºéä¿¡æ°",
|
---|
915 | "è¿é£è¦è«éä¿¡æ°",
|
---|
916 | "è¿é£è¦è«åä¿¡æ°",
|
---|
917 | "è¿é£éç¥éä¿¡æ°",
|
---|
918 | "è¿é£éç¥åä¿¡æ°",
|
---|
919 | "ã«ã¼ã¿è¦è«åºåæ°",
|
---|
920 | "ã«ã¼ã¿éç¥åä¿¡æ°",
|
---|
921 | };
|
---|
922 |
|
---|
923 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
924 |
|
---|
925 | static const char *tcp_item[NC_TCP_SIZE] = {
|
---|
926 | "è½åãªã¼ãã³æ°",
|
---|
927 | "ååãªã¼ãã³æ°",
|
---|
928 | "RTT æ´æ°æ°",
|
---|
929 | "éä¿¡ RST æ°",
|
---|
930 | "éä¿¡ ACK æ°",
|
---|
931 | "éä¿¡ç·æ¥ã»ã°ã¡ã³ãæ°",
|
---|
932 | "éä¿¡ãã¼ã¿ã»ã°ã¡ã³ãæ°",
|
---|
933 | "åéã»ã°ã¡ã³ãæ°",
|
---|
934 | "éä¿¡ã»ã°ã¡ã³ãæ°",
|
---|
935 | "éä¿¡å¶å¾¡ã»ã°ã¡ã³ãæ°",
|
---|
936 | "éä¿¡ãã¼ã¿ãªã¯ãããæ°",
|
---|
937 | "åä¿¡ãã¥ã¼è§£æ¾æ°",
|
---|
938 | "åä¿¡å¤éæ°",
|
---|
939 | "åä¿¡ç ´æ£æ°",
|
---|
940 | "åä¿¡ RST æ°",
|
---|
941 | "åä¿¡å¤é ACK æ°",
|
---|
942 | "åä¿¡ ACK æ°",
|
---|
943 | "åä¿¡ãã§ãã¯ãµã ä¸æ£æ°",
|
---|
944 | "åä¿¡ãããä¸æ£æ°",
|
---|
945 | "åä¿¡ç·æ¥ã»ã°ã¡ã³ãæ°",
|
---|
946 | "åä¿¡ãã¼ã¿ã»ã°ã¡ã³ãæ°",
|
---|
947 | "åä¿¡ã»ã°ã¡ã³ãæ°",
|
---|
948 | "åä¿¡ãã¼ã¿ãªã¯ãããæ°",
|
---|
949 | "åä¿¡ãªã¯ãããæ°",
|
---|
950 | };
|
---|
951 |
|
---|
952 | /*
|
---|
953 | * put_count_item1 -- ã«ã¦ã³ã¿ã®å
|
---|
954 | 容ãåºåãããã°ã«ã¼ã 1
|
---|
955 | */
|
---|
956 |
|
---|
957 | static uint16_t
|
---|
958 | put_count_item1 (ID cepid, T_WWW_RWBUF *srbuf, const char *item, T_NET_COUNT *counter)
|
---|
959 | {
|
---|
960 | char buf[TD_DIGITS + 1];
|
---|
961 | uint16_t len = 0;
|
---|
962 |
|
---|
963 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
964 | len += put_str(cepid, srbuf, item);
|
---|
965 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
966 |
|
---|
967 | convert(buf, counter->in_octets, 10, TD_DIGITS, false, ' ');
|
---|
968 | len += put_str(cepid, srbuf, buf);
|
---|
969 | len += put_str(cepid, srbuf, "</td>\r\n<td align=\"right\">");
|
---|
970 |
|
---|
971 | convert(buf, counter->out_octets, 10, TD_DIGITS, false, ' ');
|
---|
972 | len += put_str(cepid, srbuf, buf);
|
---|
973 | len += put_str(cepid, srbuf, "</td>\r\n<td align=\"right\">");
|
---|
974 |
|
---|
975 | convert(buf, counter->in_packets, 10, TD_DIGITS, false, ' ');
|
---|
976 | len += put_str(cepid, srbuf, buf);
|
---|
977 | len += put_str(cepid, srbuf, "</td>\r\n<td align=\"right\">");
|
---|
978 |
|
---|
979 | convert(buf, counter->out_packets, 10, TD_DIGITS, false, ' ');
|
---|
980 | len += put_str(cepid, srbuf, buf);
|
---|
981 | len += put_str(cepid, srbuf, "</td>\r\n<td align=\"right\">");
|
---|
982 |
|
---|
983 | convert(buf, counter->in_err_packets, 10, TD_DIGITS, false, ' ');
|
---|
984 | len += put_str(cepid, srbuf, buf);
|
---|
985 | len += put_str(cepid, srbuf, "</td>\r\n<td align=\"right\">");
|
---|
986 |
|
---|
987 | convert(buf, counter->out_err_packets, 10, TD_DIGITS, false, ' ');
|
---|
988 | len += put_str(cepid, srbuf, buf);
|
---|
989 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
990 |
|
---|
991 | return len;
|
---|
992 | }
|
---|
993 |
|
---|
994 | #ifdef SUPPORT_PPP
|
---|
995 |
|
---|
996 | /*
|
---|
997 | * put_count_item2 -- ã«ã¦ã³ã¿ã®å
|
---|
998 | 容ãåºåãããã°ã«ã¼ã 2
|
---|
999 | */
|
---|
1000 |
|
---|
1001 | static uint16_t
|
---|
1002 | put_count_item2 (ID cepid, T_WWW_RWBUF *srbuf, const char *item, uint32_t octets, uint32_t packets)
|
---|
1003 | {
|
---|
1004 | char buf[TD_DIGITS + 1];
|
---|
1005 | uint16_t len = 0;
|
---|
1006 |
|
---|
1007 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1008 | len += put_str(cepid, srbuf, item);
|
---|
1009 | len += put_str(cepid, srbuf, "</td><td>");
|
---|
1010 |
|
---|
1011 | convert(buf, octets, 10, TD_DIGITS, false, ' ');
|
---|
1012 | len += put_str(cepid, srbuf, buf);
|
---|
1013 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1014 |
|
---|
1015 | convert(buf, packets, 10, TD_DIGITS, false, ' ');
|
---|
1016 | len += put_str(cepid, srbuf, buf);
|
---|
1017 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1018 |
|
---|
1019 | return len;
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 | /*
|
---|
1023 | * td_len_ppp -- put_count_ppp ã§åºåããæåæ°ã
|
---|
1024 | */
|
---|
1025 |
|
---|
1026 | static uint16_t
|
---|
1027 | td_len_ppp (void)
|
---|
1028 | {
|
---|
1029 | int_t ix;
|
---|
1030 | uint16_t len = 0;
|
---|
1031 |
|
---|
1032 | for (ix = NC_PPP_SIZE; ix -- > 0; )
|
---|
1033 | len += strlen(ppp_item[ix]);
|
---|
1034 | return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_PPP_SIZE;
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | /*
|
---|
1038 | * put_count_ppp -- ã«ã¦ã³ã¿ (PPP) ã®å
|
---|
1039 | 容ãåºåããã
|
---|
1040 | */
|
---|
1041 |
|
---|
1042 | static uint16_t
|
---|
1043 | put_count_ppp (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
1044 | {
|
---|
1045 |
|
---|
1046 | char buf[TD_DIGITS + 1];
|
---|
1047 | uint16_t len = 0;
|
---|
1048 |
|
---|
1049 | len += put_str(cepid, srbuf, table_prefix_ppp);
|
---|
1050 |
|
---|
1051 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1052 | len += put_str(cepid, srbuf, ppp_item[0]);
|
---|
1053 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1054 | convert(buf, net_count_ppp.in_octets, 10, TD_DIGITS, false, ' ');
|
---|
1055 | len += put_str(cepid, srbuf, buf);
|
---|
1056 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1057 |
|
---|
1058 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1059 | len += put_str(cepid, srbuf, ppp_item[1]);
|
---|
1060 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1061 | convert(buf, net_count_ppp.out_octets, 10, TD_DIGITS, false, ' ');
|
---|
1062 | len += put_str(cepid, srbuf, buf);
|
---|
1063 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1064 |
|
---|
1065 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1066 | len += put_str(cepid, srbuf, ppp_item[2]);
|
---|
1067 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1068 | convert(buf, net_count_ppp.in_packets, 10, TD_DIGITS, false, ' ');
|
---|
1069 | len += put_str(cepid, srbuf, buf);
|
---|
1070 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1071 |
|
---|
1072 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1073 | len += put_str(cepid, srbuf, ppp_item[3]);
|
---|
1074 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1075 | convert(buf, net_count_ppp.out_packets, 10, TD_DIGITS, false, ' ');
|
---|
1076 | len += put_str(cepid, srbuf, buf);
|
---|
1077 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1078 |
|
---|
1079 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1080 | len += put_str(cepid, srbuf, ppp_item[4]);
|
---|
1081 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1082 | convert(buf, net_count_ppp.in_err_packets, 10, TD_DIGITS, false, ' ');
|
---|
1083 | len += put_str(cepid, srbuf, buf);
|
---|
1084 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1085 |
|
---|
1086 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1087 | len += put_str(cepid, srbuf, ppp_item[5]);
|
---|
1088 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1089 | convert(buf, net_count_ppp.out_err_packets, 10, TD_DIGITS, false, ' ');
|
---|
1090 | len += put_str(cepid, srbuf, buf);
|
---|
1091 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1092 |
|
---|
1093 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1094 | len += put_str(cepid, srbuf, ppp_item[6]);
|
---|
1095 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1096 | convert(buf, net_count_ppp_no_bufs, 10, TD_DIGITS, false, ' ');
|
---|
1097 | len += put_str(cepid, srbuf, buf);
|
---|
1098 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1099 |
|
---|
1100 | len += put_str(cepid, srbuf, table_suffix);
|
---|
1101 |
|
---|
1102 | return len;
|
---|
1103 | }
|
---|
1104 |
|
---|
1105 | #endif /* of #ifdef SUPPORT_PPP */
|
---|
1106 |
|
---|
1107 | #if defined(SUPPORT_INET4)
|
---|
1108 |
|
---|
1109 | /*
|
---|
1110 | * td_len_ip4 -- put_count_ip4 ã§åºåããæåæ°ã
|
---|
1111 | */
|
---|
1112 |
|
---|
1113 | static uint16_t
|
---|
1114 | td_len_ip4 (void)
|
---|
1115 | {
|
---|
1116 | int_t ix;
|
---|
1117 | uint16_t len = 0;
|
---|
1118 |
|
---|
1119 | for (ix = NC_IP4_SIZE; ix -- > 0; )
|
---|
1120 | len += strlen(ip4_item[ix]);
|
---|
1121 | return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_IP4_SIZE;
|
---|
1122 | }
|
---|
1123 |
|
---|
1124 | /*
|
---|
1125 | * put_count_ip4 -- ã«ã¦ã³ã¿ (IP4) ã®å
|
---|
1126 | 容ãåºåããã
|
---|
1127 | */
|
---|
1128 |
|
---|
1129 | static uint16_t
|
---|
1130 | put_count_ip4 (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
1131 | {
|
---|
1132 | char buf[TD_DIGITS + 1];
|
---|
1133 | uint16_t len = 0;
|
---|
1134 | int_t ix;
|
---|
1135 |
|
---|
1136 | len += put_str(cepid, srbuf, table_prefix_ip4);
|
---|
1137 | for (ix = NC_IP4_SIZE; ix -- > 0; ) {
|
---|
1138 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1139 | len += put_str(cepid, srbuf, ip4_item[ix]);
|
---|
1140 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1141 | convert(buf, net_count_ip4[ix], 10, TD_DIGITS, false, ' ');
|
---|
1142 | len += put_str(cepid, srbuf, buf);
|
---|
1143 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1144 | }
|
---|
1145 | len += put_str(cepid, srbuf, table_suffix);
|
---|
1146 |
|
---|
1147 | return len;
|
---|
1148 | }
|
---|
1149 |
|
---|
1150 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
1151 |
|
---|
1152 | #if defined(SUPPORT_INET6)
|
---|
1153 |
|
---|
1154 | /*
|
---|
1155 | * td_len_nd6 -- put_count_nd6 ã§åºåããæåæ°ã
|
---|
1156 | */
|
---|
1157 |
|
---|
1158 | static uint16_t
|
---|
1159 | td_len_nd6 (void)
|
---|
1160 | {
|
---|
1161 | int_t ix;
|
---|
1162 | uint16_t len = 0;
|
---|
1163 |
|
---|
1164 | for (ix = NC_ND6_SIZE; ix -- > 0; )
|
---|
1165 | len += strlen(nd6_item[ix]);
|
---|
1166 | return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_ND6_SIZE;
|
---|
1167 | }
|
---|
1168 |
|
---|
1169 | /*
|
---|
1170 | * put_count_nd6 -- ã«ã¦ã³ã¿ (ND6) ã®å
|
---|
1171 | 容ãåºåããã
|
---|
1172 | */
|
---|
1173 |
|
---|
1174 | static uint16_t
|
---|
1175 | put_count_nd6 (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
1176 | {
|
---|
1177 | char buf[TD_DIGITS + 1];
|
---|
1178 | uint16_t len = 0;
|
---|
1179 | int_t ix;
|
---|
1180 |
|
---|
1181 | len += put_str(cepid, srbuf, table_prefix_nd6);
|
---|
1182 | for (ix = NC_ND6_SIZE; ix -- > 0; ) {
|
---|
1183 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1184 | len += put_str(cepid, srbuf, nd6_item[ix]);
|
---|
1185 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1186 | convert(buf, net_count_nd6[ix], 10, TD_DIGITS, false, ' ');
|
---|
1187 | len += put_str(cepid, srbuf, buf);
|
---|
1188 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1189 | }
|
---|
1190 | len += put_str(cepid, srbuf, table_suffix);
|
---|
1191 |
|
---|
1192 | return len;
|
---|
1193 | }
|
---|
1194 |
|
---|
1195 | /*
|
---|
1196 | * td_len_icmp6 -- put_count_icmp6 ã§åºåããæåæ°ã
|
---|
1197 | */
|
---|
1198 |
|
---|
1199 | static uint16_t
|
---|
1200 | td_len_icmp6 (void)
|
---|
1201 | {
|
---|
1202 | int_t ix;
|
---|
1203 | uint16_t len = 0;
|
---|
1204 |
|
---|
1205 | for (ix = NC_ICMP6_SIZE; ix -- > 0; )
|
---|
1206 | len += strlen(icmp6_item[ix]);
|
---|
1207 | return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_ICMP6_SIZE;
|
---|
1208 | }
|
---|
1209 |
|
---|
1210 | /*
|
---|
1211 | * put_count_icmp6 -- ã«ã¦ã³ã¿ (ICMP6) ã®å
|
---|
1212 | 容ãåºåããã
|
---|
1213 | */
|
---|
1214 |
|
---|
1215 | static uint16_t
|
---|
1216 | put_count_icmp6 (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
1217 | {
|
---|
1218 | char buf[TD_DIGITS + 1];
|
---|
1219 | uint16_t len = 0;
|
---|
1220 | int_t ix;
|
---|
1221 |
|
---|
1222 | len += put_str(cepid, srbuf, table_prefix_icmp6);
|
---|
1223 | for (ix = NC_ICMP6_SIZE; ix -- > 0; ) {
|
---|
1224 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1225 | len += put_str(cepid, srbuf, icmp6_item[ix]);
|
---|
1226 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1227 | convert(buf, net_count_icmp6[ix], 10, TD_DIGITS, false, ' ');
|
---|
1228 | len += put_str(cepid, srbuf, buf);
|
---|
1229 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1230 | }
|
---|
1231 | len += put_str(cepid, srbuf, table_suffix);
|
---|
1232 |
|
---|
1233 | return len;
|
---|
1234 | }
|
---|
1235 |
|
---|
1236 | /*
|
---|
1237 | * td_len_ip6 -- put_count_ip6 ã§åºåããæåæ°ã
|
---|
1238 | */
|
---|
1239 |
|
---|
1240 | static uint16_t
|
---|
1241 | td_len_ip6 (void)
|
---|
1242 | {
|
---|
1243 | int_t ix;
|
---|
1244 | uint16_t len = 0;
|
---|
1245 |
|
---|
1246 | for (ix = NC_IP6_SIZE; ix -- > 0; )
|
---|
1247 | len += strlen(ip6_item[ix]);
|
---|
1248 | return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_IP6_SIZE;
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 | /*
|
---|
1252 | * put_count_ip6 -- ã«ã¦ã³ã¿ (IP6) ã®å
|
---|
1253 | 容ãåºåããã
|
---|
1254 | */
|
---|
1255 |
|
---|
1256 | static uint16_t
|
---|
1257 | put_count_ip6 (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
1258 | {
|
---|
1259 | char buf[TD_DIGITS + 1];
|
---|
1260 | uint16_t len = 0;
|
---|
1261 | int_t ix;
|
---|
1262 |
|
---|
1263 | len += put_str(cepid, srbuf, table_prefix_ip6);
|
---|
1264 | for (ix = NC_IP6_SIZE; ix -- > 0; ) {
|
---|
1265 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1266 | len += put_str(cepid, srbuf, ip6_item[ix]);
|
---|
1267 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1268 | convert(buf, net_count_ip6[ix], 10, TD_DIGITS, false, ' ');
|
---|
1269 | len += put_str(cepid, srbuf, buf);
|
---|
1270 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1271 | }
|
---|
1272 | len += put_str(cepid, srbuf, table_suffix);
|
---|
1273 |
|
---|
1274 | return len;
|
---|
1275 | }
|
---|
1276 |
|
---|
1277 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
1278 |
|
---|
1279 | /*
|
---|
1280 | * td_len_tcp -- put_count_tcp ã§åºåããæåæ°ã
|
---|
1281 | */
|
---|
1282 |
|
---|
1283 | static uint16_t
|
---|
1284 | td_len_tcp (void)
|
---|
1285 | {
|
---|
1286 | int_t ix;
|
---|
1287 | uint16_t len = 0;
|
---|
1288 |
|
---|
1289 | for (ix = NC_TCP_SIZE; ix -- > 0; )
|
---|
1290 | len += strlen(tcp_item[ix]);
|
---|
1291 | return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_TCP_SIZE;
|
---|
1292 | }
|
---|
1293 |
|
---|
1294 | /*
|
---|
1295 | * put_count_tcp -- ã«ã¦ã³ã¿ (TCP) ã®å
|
---|
1296 | 容ãåºåããã
|
---|
1297 | */
|
---|
1298 |
|
---|
1299 | static uint16_t
|
---|
1300 | put_count_tcp (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
1301 | {
|
---|
1302 | char buf[TD_DIGITS + 1];
|
---|
1303 | uint16_t len = 0;
|
---|
1304 | int_t ix;
|
---|
1305 |
|
---|
1306 | len += put_str(cepid, srbuf, table_prefix_tcp);
|
---|
1307 | for (ix = NC_TCP_SIZE; ix -- > 0; ) {
|
---|
1308 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1309 | len += put_str(cepid, srbuf, tcp_item[ix]);
|
---|
1310 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1311 | convert(buf, net_count_tcp[ix], 10, TD_DIGITS, false, ' ');
|
---|
1312 | len += put_str(cepid, srbuf, buf);
|
---|
1313 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1314 | }
|
---|
1315 | len += put_str(cepid, srbuf, table_suffix);
|
---|
1316 |
|
---|
1317 | return len;
|
---|
1318 | }
|
---|
1319 |
|
---|
1320 | /*
|
---|
1321 | * put_elapse_time -- çµéæéãåºåããã
|
---|
1322 | */
|
---|
1323 |
|
---|
1324 | static uint16_t
|
---|
1325 | put_elapse_time (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
1326 | {
|
---|
1327 | SYSTIM now, elapse;
|
---|
1328 | char buf[TD_DIGITS + 1];
|
---|
1329 | uint16_t len = 0;
|
---|
1330 |
|
---|
1331 | get_tim(&now);
|
---|
1332 | elapse = now - srv_start;
|
---|
1333 |
|
---|
1334 | len += put_str(cepid, srbuf, time_prefix);
|
---|
1335 |
|
---|
1336 | convert(buf, elapse / (60 * 60 * SYSTIM_HZ), 10, 4, false, ' ');
|
---|
1337 | len += put_str(cepid, srbuf, buf);
|
---|
1338 | len += put_str(cepid, srbuf, ":");
|
---|
1339 |
|
---|
1340 | convert(buf, (elapse / (60 * SYSTIM_HZ)) % 60, 10, 2, false, ' ');
|
---|
1341 | len += put_str(cepid, srbuf, buf);
|
---|
1342 | len += put_str(cepid, srbuf, ":");
|
---|
1343 |
|
---|
1344 | convert(buf, (elapse / SYSTIM_HZ) % 60, 10, 2, false, ' ');
|
---|
1345 | len += put_str(cepid, srbuf, buf);
|
---|
1346 |
|
---|
1347 | len += put_str(cepid, srbuf, time_suffix);
|
---|
1348 |
|
---|
1349 | return len;
|
---|
1350 | }
|
---|
1351 |
|
---|
1352 | /*
|
---|
1353 | * put_count_net_buf -- ã«ã¦ã³ã¿ (TCP) ã®å
|
---|
1354 | 容ãåºåããã
|
---|
1355 | */
|
---|
1356 |
|
---|
1357 | static uint16_t
|
---|
1358 | put_count_net_buf (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
1359 | {
|
---|
1360 |
|
---|
1361 | const T_NET_BUF_ENTRY *tbl;
|
---|
1362 | char buf[TD_DIGITS + 1];
|
---|
1363 | uint16_t len = 0;
|
---|
1364 | int_t ix;
|
---|
1365 |
|
---|
1366 | len += put_str(cepid, srbuf, table_prefix_net_buf);
|
---|
1367 | tbl = nbuf_get_tbl();
|
---|
1368 | for (ix = nbuf_get_tbl_size(); ix -- > 0; ) {
|
---|
1369 | len += put_str(cepid, srbuf, "<tr><td align=\"right\">");
|
---|
1370 | convert(buf, tbl[ix].size, 10, 4, false, ' ');
|
---|
1371 | len += put_str(cepid, srbuf, buf);
|
---|
1372 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1373 | convert(buf, tbl[ix].prepares, 10, TD_DIGITS, false, ' ');
|
---|
1374 | len += put_str(cepid, srbuf, buf);
|
---|
1375 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1376 | convert(buf, tbl[ix].requests, 10, TD_DIGITS, false, ' ');
|
---|
1377 | len += put_str(cepid, srbuf, buf);
|
---|
1378 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1379 | convert(buf, tbl[ix].allocs, 10, TD_DIGITS, false, ' ');
|
---|
1380 | len += put_str(cepid, srbuf, buf);
|
---|
1381 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1382 | convert(buf, tbl[ix].errors, 10, TD_DIGITS, false, ' ');
|
---|
1383 | len += put_str(cepid, srbuf, buf);
|
---|
1384 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1385 | }
|
---|
1386 | len += put_str(cepid, srbuf, table_suffix);
|
---|
1387 |
|
---|
1388 | return len;
|
---|
1389 | }
|
---|
1390 |
|
---|
1391 | #ifdef SUPPORT_ETHER
|
---|
1392 |
|
---|
1393 | /*
|
---|
1394 | * td_len_ether_nic -- put_count_ether_nic ã§åºåããæåæ°ã
|
---|
1395 | */
|
---|
1396 |
|
---|
1397 | static uint16_t
|
---|
1398 | td_len_ether_nic (void)
|
---|
1399 | {
|
---|
1400 | int_t ix;
|
---|
1401 | uint16_t len = 0;
|
---|
1402 |
|
---|
1403 | for (ix = NC_ETHER_NIC_SIZE; ix -- > 0; )
|
---|
1404 | len += strlen(ether_nic_item[ix]);
|
---|
1405 | return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_ETHER_NIC_SIZE;
|
---|
1406 | }
|
---|
1407 |
|
---|
1408 | /*
|
---|
1409 | * put_count_ether_nic -- ã«ã¦ã³ã¿ (ETHER_NIC) ã®å
|
---|
1410 | 容ãåºåããã
|
---|
1411 | */
|
---|
1412 |
|
---|
1413 | static uint16_t
|
---|
1414 | put_count_ether_nic (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
1415 | {
|
---|
1416 | char buf[TD_DIGITS + 1];
|
---|
1417 | uint16_t len = 0;
|
---|
1418 | int_t ix;
|
---|
1419 |
|
---|
1420 | len += put_str(cepid, srbuf, table_prefix_ether_nic);
|
---|
1421 | for (ix = NC_ETHER_NIC_SIZE; ix -- > 0; ) {
|
---|
1422 | len += put_str(cepid, srbuf, "<tr><td>");
|
---|
1423 | len += put_str(cepid, srbuf, ether_nic_item[ix]);
|
---|
1424 | len += put_str(cepid, srbuf, "</td><td align=\"right\">");
|
---|
1425 | convert(buf, net_count_ether_nic[ix], 10, TD_DIGITS, false, ' ');
|
---|
1426 | len += put_str(cepid, srbuf, buf);
|
---|
1427 | len += put_str(cepid, srbuf, "</td></tr>\r\n");
|
---|
1428 | }
|
---|
1429 | len += put_str(cepid, srbuf, table_suffix);
|
---|
1430 |
|
---|
1431 | return len;
|
---|
1432 | }
|
---|
1433 |
|
---|
1434 | #endif /* of #ifdef SUPPORT_ETHER */
|
---|
1435 |
|
---|
1436 | /*
|
---|
1437 | * stat_html -- /stat.html ãã¡ã¤ã«
|
---|
1438 | */
|
---|
1439 |
|
---|
1440 | static ER
|
---|
1441 | stat_html (ID cepid, T_WWW_RWBUF *srbuf)
|
---|
1442 | {
|
---|
1443 | static const char res_prefix[] =
|
---|
1444 | "\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD html 3.2//EN\">\r\n"
|
---|
1445 | "<html><head>\r\n"
|
---|
1446 |
|
---|
1447 | #ifdef TOPPERS_S810_CLG3_85
|
---|
1448 | "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=Shift_JIS\">\r\n"
|
---|
1449 | #else
|
---|
1450 | "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=EUC-JP\">\r\n"
|
---|
1451 | #endif
|
---|
1452 |
|
---|
1453 | "<title>ãããã¯ã¼ã¯çµ±è¨æ
|
---|
1454 | å ±</title>\r\n"
|
---|
1455 | "</head><body bgcolor=\"#ffffbb\">\r\n"
|
---|
1456 | "<hr><h1 align=\"center\">ãããã¯ã¼ã¯çµ±è¨æ
|
---|
1457 | å ±</h1><hr>\r\n"
|
---|
1458 | ;
|
---|
1459 |
|
---|
1460 | static const char res_suffix[] =
|
---|
1461 | "</body></html>\r\n"
|
---|
1462 | ;
|
---|
1463 |
|
---|
1464 | static const char table_prefix1[] =
|
---|
1465 | "<h2>ã°ã«ã¼ã 1</h2><table border>\r\n"
|
---|
1466 | "<tr><th>é
|
---|
1467 | ç®</th>\r\n"
|
---|
1468 | "<th>åä¿¡ãªã¯ãããæ°</th>"
|
---|
1469 | "<th>éä¿¡ãªã¯ãããæ°</th>\r\n"
|
---|
1470 | "<th>åä¿¡ãã±ããæ°</th>"
|
---|
1471 | "<th>éä¿¡ãã±ããæ°</th>\r\n"
|
---|
1472 | "<th>åä¿¡ã¨ã©ã¼<br>ãã±ããæ°</th>"
|
---|
1473 | "<th>éä¿¡ã¨ã©ã¼<br>ãã±ããæ°</th></tr>\r\n"
|
---|
1474 | ;
|
---|
1475 |
|
---|
1476 | #ifdef SUPPORT_PPP
|
---|
1477 |
|
---|
1478 | static const char table_prefix2[] =
|
---|
1479 | "<h2>ã°ã«ã¼ã 2</h2><table border>\r\n"
|
---|
1480 | "<tr><th>é
|
---|
1481 | ç®</th>"
|
---|
1482 | "<th>åä¿¡ãªã¯ãããæ°</th>"
|
---|
1483 | "<th>åä¿¡ãã¬ã¼ã æ°</th></tr>\r\n"
|
---|
1484 | ;
|
---|
1485 |
|
---|
1486 | #endif /* of #ifdef SUPPORT_PPP */
|
---|
1487 |
|
---|
1488 | uint16_t content_len, len = 0;
|
---|
1489 | SYSTIM start, finish;
|
---|
1490 |
|
---|
1491 | get_tim(&start);
|
---|
1492 | content_len = 0
|
---|
1493 |
|
---|
1494 | #ifdef SUPPORT_PPP
|
---|
1495 |
|
---|
1496 | + TD_LEN1("HDLC")
|
---|
1497 |
|
---|
1498 | #endif /* of #ifdef SUPPORT_PPP */
|
---|
1499 |
|
---|
1500 | #ifdef SUPPORT_PPP
|
---|
1501 |
|
---|
1502 | + td_len_ppp()
|
---|
1503 | + TD_LEN2("LCP")
|
---|
1504 | + TD_LEN2("IPCP")
|
---|
1505 |
|
---|
1506 | #endif /* of #ifdef SUPPORT_PPP */
|
---|
1507 |
|
---|
1508 | #ifdef SUPPORT_ETHER
|
---|
1509 |
|
---|
1510 | + TD_LEN1("ARP")
|
---|
1511 | + td_len_ether_nic()
|
---|
1512 |
|
---|
1513 | #endif /* of #ifdef SUPPORT_ETHER */
|
---|
1514 |
|
---|
1515 | + TD_LEN1("ICMP")
|
---|
1516 | + TD_LEN1("UDP")
|
---|
1517 |
|
---|
1518 | #if defined(SUPPORT_INET4)
|
---|
1519 |
|
---|
1520 | + td_len_ip4()
|
---|
1521 |
|
---|
1522 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
1523 |
|
---|
1524 | #if defined(SUPPORT_INET6)
|
---|
1525 |
|
---|
1526 | + td_len_ip6()
|
---|
1527 | + td_len_nd6()
|
---|
1528 | + td_len_icmp6()
|
---|
1529 |
|
---|
1530 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
1531 |
|
---|
1532 | + td_len_tcp()
|
---|
1533 | + TD_LEN4("0123") * nbuf_get_tbl_size();
|
---|
1534 | ;
|
---|
1535 |
|
---|
1536 | len += put_status(cepid, srbuf, ST_OK);
|
---|
1537 | len += put_content_length(cepid, srbuf, strlen(res_prefix)
|
---|
1538 | + strlen(res_suffix)
|
---|
1539 | + strlen(time_prefix)
|
---|
1540 | + strlen("1234:12:12")
|
---|
1541 | + strlen(time_suffix)
|
---|
1542 | + strlen(table_prefix1)
|
---|
1543 | + strlen(table_prefix_net_buf)
|
---|
1544 |
|
---|
1545 | #if defined(SUPPORT_INET4)
|
---|
1546 |
|
---|
1547 | + strlen(table_prefix_ip4)
|
---|
1548 |
|
---|
1549 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
1550 |
|
---|
1551 | #if defined(SUPPORT_INET6)
|
---|
1552 |
|
---|
1553 | + strlen(table_prefix_ip6)
|
---|
1554 | + strlen(table_prefix_nd6)
|
---|
1555 | + strlen(table_prefix_icmp6)
|
---|
1556 |
|
---|
1557 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
1558 | + strlen(table_prefix_tcp)
|
---|
1559 | + strlen(table_suffix) * 3
|
---|
1560 |
|
---|
1561 | #ifdef SUPPORT_PPP
|
---|
1562 | + strlen(table_prefix2)
|
---|
1563 | + strlen(table_prefix_ppp)
|
---|
1564 | + strlen(table_suffix) * 2
|
---|
1565 |
|
---|
1566 | #endif /* of #ifdef SUPPORT_PPP */
|
---|
1567 |
|
---|
1568 | #ifdef SUPPORT_ETHER
|
---|
1569 |
|
---|
1570 | + strlen(table_prefix_ether_nic)
|
---|
1571 | + strlen(table_suffix) * 1
|
---|
1572 |
|
---|
1573 | #endif /* of #ifdef SUPPORT_ETHER */
|
---|
1574 |
|
---|
1575 | + content_len
|
---|
1576 | - 2); /* 2 ã¯æåã® \r\n */
|
---|
1577 |
|
---|
1578 | len += put_str(cepid, srbuf, res_prefix);
|
---|
1579 | len += put_elapse_time(cepid, srbuf);
|
---|
1580 | len += put_str(cepid, srbuf, table_prefix1);
|
---|
1581 |
|
---|
1582 | #ifdef SUPPORT_PPP
|
---|
1583 |
|
---|
1584 | len += put_count_item1(cepid, srbuf, "HDLC", &net_count_hdlc);
|
---|
1585 |
|
---|
1586 | #endif /* of #ifdef SUPPORT_PPP */
|
---|
1587 |
|
---|
1588 | #ifdef SUPPORT_ETHER
|
---|
1589 |
|
---|
1590 | len += put_count_item1(cepid, srbuf, "Ethernet", &net_count_ether);
|
---|
1591 |
|
---|
1592 | #if defined(SUPPORT_INET4)
|
---|
1593 |
|
---|
1594 | len += put_count_item1(cepid, srbuf, "ARP", &net_count_arp);
|
---|
1595 |
|
---|
1596 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
1597 |
|
---|
1598 | #endif /* of #ifdef SUPPORT_ETHER */
|
---|
1599 |
|
---|
1600 | #if defined(SUPPORT_INET4)
|
---|
1601 |
|
---|
1602 | len += put_count_item1(cepid, srbuf, "ICMP", &net_count_icmp4);
|
---|
1603 |
|
---|
1604 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
1605 |
|
---|
1606 | #ifdef SUPPORT_UDP
|
---|
1607 |
|
---|
1608 | len += put_count_item1(cepid, srbuf, "UDP", &net_count_udp);
|
---|
1609 |
|
---|
1610 | #endif /* of #ifdef SUPPORT_UDP */
|
---|
1611 |
|
---|
1612 | len += put_str(cepid, srbuf, table_suffix);
|
---|
1613 |
|
---|
1614 | #ifdef SUPPORT_PPP
|
---|
1615 |
|
---|
1616 | len += put_str(cepid, srbuf, table_prefix2);
|
---|
1617 | len += put_count_item2(cepid, srbuf, "LCP",
|
---|
1618 | net_count_ppp_lcp_in_octets,
|
---|
1619 | net_count_ppp_lcp_in_packets);
|
---|
1620 | len += put_count_item2(cepid, srbuf, "IPCP",
|
---|
1621 | net_count_ppp_ipcp_in_octets,
|
---|
1622 | net_count_ppp_ipcp_in_packets);
|
---|
1623 | len += put_str(cepid, srbuf, table_suffix);
|
---|
1624 |
|
---|
1625 | len += put_count_ppp(cepid, srbuf);
|
---|
1626 |
|
---|
1627 | #endif /* of #ifdef SUPPORT_PPP */
|
---|
1628 |
|
---|
1629 | #ifdef SUPPORT_ETHER
|
---|
1630 |
|
---|
1631 | len += put_count_ether_nic(cepid, srbuf);
|
---|
1632 |
|
---|
1633 | #endif /* of #ifdef SUPPORT_ETHER */
|
---|
1634 |
|
---|
1635 | #if defined(SUPPORT_INET4)
|
---|
1636 |
|
---|
1637 | len += put_count_ip4(cepid, srbuf);
|
---|
1638 |
|
---|
1639 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
1640 |
|
---|
1641 | #if defined(SUPPORT_INET6)
|
---|
1642 |
|
---|
1643 | len += put_count_ip6(cepid, srbuf);
|
---|
1644 | len += put_count_nd6(cepid, srbuf);
|
---|
1645 | len += put_count_icmp6(cepid, srbuf);
|
---|
1646 |
|
---|
1647 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
1648 |
|
---|
1649 | len += put_count_tcp(cepid, srbuf);
|
---|
1650 |
|
---|
1651 | len += put_count_net_buf(cepid, srbuf);
|
---|
1652 |
|
---|
1653 | len += put_str(cepid, srbuf, res_suffix);
|
---|
1654 |
|
---|
1655 | get_tim(&finish);
|
---|
1656 | syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html, len: %4u, time: %lu [us]",
|
---|
1657 | cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
|
---|
1658 | return E_OK;
|
---|
1659 | }
|
---|
1660 |
|
---|
1661 | #endif /* of #if NET_COUNT_ENABLE */
|
---|
1662 |
|
---|
1663 | #ifdef USE_TCP_EXTENTIONS
|
---|
1664 |
|
---|
1665 | /*
|
---|
1666 | * get_tcp_rep -- TCP åä»å£ãç²å¾ããã
|
---|
1667 | */
|
---|
1668 |
|
---|
1669 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
|
---|
1670 |
|
---|
1671 | static ER
|
---|
1672 | get_tcp_rep (ID *repid)
|
---|
1673 | {
|
---|
1674 | ID tskid;
|
---|
1675 | T_TCP6_CREP crep6;
|
---|
1676 | T_TCP_CREP crep4;
|
---|
1677 |
|
---|
1678 | get_tid(&tskid);
|
---|
1679 | if (tskid == WWW4_SRV_TASK) {
|
---|
1680 | crep4.repatr = UINT_C(0);
|
---|
1681 | crep4.myaddr.portno = UINT_C(80);
|
---|
1682 | crep4.myaddr.ipaddr = IPV4_ADDRANY;
|
---|
1683 | return alloc_tcp4_rep(repid, tskid, &crep4);
|
---|
1684 | }
|
---|
1685 | else {
|
---|
1686 | crep6.repatr = UINT_C(0);
|
---|
1687 | crep6.myaddr.portno = UINT_C(80);
|
---|
1688 | memcpy(&crep6.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
|
---|
1689 | return alloc_tcp6_rep(repid, tskid, &crep6);
|
---|
1690 | }
|
---|
1691 | }
|
---|
1692 |
|
---|
1693 | #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
|
---|
1694 |
|
---|
1695 | static ER
|
---|
1696 | get_tcp_rep (ID *repid)
|
---|
1697 | {
|
---|
1698 | ID tskid;
|
---|
1699 | T_TCPN_CREP crep;
|
---|
1700 |
|
---|
1701 | get_tid(&tskid);
|
---|
1702 |
|
---|
1703 | crep.repatr = UINT_C(0);
|
---|
1704 | crep.myaddr.portno = UINT_C(80);
|
---|
1705 |
|
---|
1706 | #if defined(SUPPORT_INET6)
|
---|
1707 |
|
---|
1708 | memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
|
---|
1709 |
|
---|
1710 | #else /* #if defined(SUPPORT_INET6) */
|
---|
1711 |
|
---|
1712 | #if defined(SUPPORT_INET4)
|
---|
1713 | crep.myaddr.ipaddr = IPV4_ADDRANY;
|
---|
1714 | #endif
|
---|
1715 |
|
---|
1716 | #endif /* #if defined(SUPPORT_INET6) */
|
---|
1717 |
|
---|
1718 | return ALLOC_TCP_REP(repid, tskid, &crep);
|
---|
1719 | }
|
---|
1720 |
|
---|
1721 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
|
---|
1722 |
|
---|
1723 | /*
|
---|
1724 | * get_tcp_cep -- TCP é信端ç¹ãç²å¾ããã
|
---|
1725 | */
|
---|
1726 |
|
---|
1727 | static ER
|
---|
1728 | get_tcp_cep (ID *cepid)
|
---|
1729 | {
|
---|
1730 | ID tskid;
|
---|
1731 | T_TCP_CCEP ccep;
|
---|
1732 |
|
---|
1733 | get_tid(&tskid);
|
---|
1734 |
|
---|
1735 | ccep.cepatr = UINT_C(0);
|
---|
1736 | ccep.sbufsz = WWW_SRV_SWBUF_SIZE;
|
---|
1737 | ccep.rbufsz = WWW_SRV_RWBUF_SIZE;
|
---|
1738 | ccep.callback = NULL;
|
---|
1739 |
|
---|
1740 | #ifdef TCP_CFG_SWBUF_CSAVE
|
---|
1741 | ccep.sbuf = NADR;
|
---|
1742 | #else
|
---|
1743 | ccep.sbuf = www_srv_swbuf[0];
|
---|
1744 | #endif
|
---|
1745 | #ifdef TCP_CFG_RWBUF_CSAVE
|
---|
1746 | ccep.rbuf = NADR;
|
---|
1747 | #else
|
---|
1748 | ccep.rbuf = www_srv_rwbuf[0];
|
---|
1749 | #endif
|
---|
1750 |
|
---|
1751 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
|
---|
1752 |
|
---|
1753 | if (tskid == WWW4_SRV_TASK)
|
---|
1754 | return alloc_tcp4_cep(cepid, tskid, &ccep);
|
---|
1755 | else
|
---|
1756 | return alloc_tcp6_cep(cepid, tskid, &ccep);
|
---|
1757 |
|
---|
1758 | #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
|
---|
1759 |
|
---|
1760 | return ALLOC_TCP_CEP(cepid, tskid, &ccep);
|
---|
1761 |
|
---|
1762 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
|
---|
1763 |
|
---|
1764 | }
|
---|
1765 |
|
---|
1766 | #endif /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
1767 |
|
---|
1768 | /*
|
---|
1769 | * tcp_passive_open -- ååãªã¼ãã³ãå®è¡ããã
|
---|
1770 | *
|
---|
1771 | * USE_TCP_NON_BLOCKING OFF
|
---|
1772 | */
|
---|
1773 |
|
---|
1774 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
|
---|
1775 |
|
---|
1776 | static ER
|
---|
1777 | tcp_passive_open (T_WWW_SRV_INFO *info, char apip)
|
---|
1778 | {
|
---|
1779 | ER error = E_OK;
|
---|
1780 | T_IPV4EP dst4;
|
---|
1781 |
|
---|
1782 | if (apip == API_PROTO_IPV6) {
|
---|
1783 | /* åä»å£ã¯ IPv6 */
|
---|
1784 | if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
|
---|
1785 | return error;
|
---|
1786 |
|
---|
1787 | #ifdef USE_TCP_EXTENTIONS
|
---|
1788 | if ((error = free_tcp6_rep(info->repid, true)) != E_OK)
|
---|
1789 | return error;
|
---|
1790 | #endif /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
1791 |
|
---|
1792 | }
|
---|
1793 | else {
|
---|
1794 | /* åä»å£ã¯ IPv4 */
|
---|
1795 | if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK)
|
---|
1796 | return error;
|
---|
1797 | in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr);
|
---|
1798 | info->dst.portno = dst4.portno;
|
---|
1799 |
|
---|
1800 | #ifdef USE_TCP_EXTENTIONS
|
---|
1801 | if ((error = free_tcp4_rep(info->repid, true)) != E_OK)
|
---|
1802 | return error;
|
---|
1803 | #endif /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
1804 | }
|
---|
1805 |
|
---|
1806 | return error;
|
---|
1807 | }
|
---|
1808 |
|
---|
1809 | #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
|
---|
1810 |
|
---|
1811 | static ER
|
---|
1812 | tcp_passive_open (T_WWW_SRV_INFO *info, char apip)
|
---|
1813 | {
|
---|
1814 | ER error = E_OK;
|
---|
1815 |
|
---|
1816 | if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
|
---|
1817 | return error;
|
---|
1818 |
|
---|
1819 | #ifdef USE_TCP_EXTENTIONS
|
---|
1820 | if ((error = FREE_TCP_REP(info->repid, true)) != E_OK)
|
---|
1821 | return error;
|
---|
1822 | #endif /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
1823 |
|
---|
1824 | return error;
|
---|
1825 | }
|
---|
1826 |
|
---|
1827 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
|
---|
1828 |
|
---|
1829 | /*
|
---|
1830 | * WWW ãµã¼ã
|
---|
1831 | */
|
---|
1832 |
|
---|
1833 | static ER
|
---|
1834 | www_srv (uint_t six, char apip)
|
---|
1835 | {
|
---|
1836 | T_WWW_RWBUF *srbuf;
|
---|
1837 | ER error;
|
---|
1838 | SYSTIM now;
|
---|
1839 |
|
---|
1840 | if ((error = tcp_passive_open(&www_srv_info[six], apip)) != E_OK)
|
---|
1841 | return error;
|
---|
1842 |
|
---|
1843 | syscall(get_tim(&now));
|
---|
1844 |
|
---|
1845 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
|
---|
1846 |
|
---|
1847 | if (apip == API_PROTO_IPV6)
|
---|
1848 | syslog(LOG_NOTICE, "[WWW6:%02u ACP] conct: %6lu,from: %s.%u",
|
---|
1849 | www_srv_info[six].cepid, now / SYSTIM_HZ,
|
---|
1850 | ipv62str(NULL, &www_srv_info[six].dst.ipaddr),
|
---|
1851 | www_srv_info[six].dst.portno);
|
---|
1852 | else
|
---|
1853 | syslog(LOG_NOTICE, "[WWW4:%02u ACP] conct: %6lu,from: %s.%u",
|
---|
1854 | www_srv_info[six].cepid, now / SYSTIM_HZ,
|
---|
1855 | ip2str(NULL, &www_srv_info[six].dst.ipaddr.s6_addr32[3]),
|
---|
1856 | www_srv_info[six].dst.portno);
|
---|
1857 |
|
---|
1858 | #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
|
---|
1859 |
|
---|
1860 | syslog(LOG_NOTICE, "[WWWn:%02u ACP] conct: %6lu,from: %s.%u",
|
---|
1861 | www_srv_info[six].cepid, now / SYSTIM_HZ,
|
---|
1862 | IP2STR(NULL, &www_srv_info[six].dst.ipaddr),
|
---|
1863 | www_srv_info[six].dst.portno);
|
---|
1864 |
|
---|
1865 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
|
---|
1866 |
|
---|
1867 | if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) {
|
---|
1868 | syslog(LOG_CRIT, "[WWWn:%02u MPF] get buffer error: %s.",
|
---|
1869 | www_srv_info[six].cepid, itron_strerror(error));
|
---|
1870 | srbuf = NULL;
|
---|
1871 | }
|
---|
1872 | else {
|
---|
1873 | srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0;
|
---|
1874 |
|
---|
1875 | #ifdef USE_COPYSAVE_API
|
---|
1876 |
|
---|
1877 | srbuf->sbuf.len = 0;
|
---|
1878 |
|
---|
1879 | #else /* of #ifdef USE_COPYSAVE_API */
|
---|
1880 |
|
---|
1881 | srbuf->sbuf.len = sizeof(srbuf->sbuf.buf);
|
---|
1882 |
|
---|
1883 | #endif /* of #ifdef USE_COPYSAVE_API */
|
---|
1884 |
|
---|
1885 | if ((error = parse_request(www_srv_info[six].cepid, srbuf)) != E_OK)
|
---|
1886 | syslog(LOG_WARNING, "[WWWn:%02u RCV] parse request error: %s",
|
---|
1887 | www_srv_info[six].cepid, itron_strerror(error));
|
---|
1888 | }
|
---|
1889 |
|
---|
1890 | if ((error = tcp_sht_cep(www_srv_info[six].cepid)) != E_OK)
|
---|
1891 | syslog(LOG_WARNING, "[WWWn:%02u SHD] shutdown error: %s",
|
---|
1892 | www_srv_info[six].cepid, itron_strerror(error));
|
---|
1893 |
|
---|
1894 | if (srbuf != NULL) {
|
---|
1895 | while (get_char(www_srv_info[six].cepid, srbuf) != EOF)
|
---|
1896 | ;
|
---|
1897 | if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK)
|
---|
1898 | syslog(LOG_WARNING, "[WWWn:%02u REL] release buffer error: %s.",
|
---|
1899 | www_srv_info[six].cepid, itron_strerror(error));
|
---|
1900 | }
|
---|
1901 |
|
---|
1902 | if ((error = tcp_cls_cep(www_srv_info[six].cepid, TMO_FEVR)) != E_OK)
|
---|
1903 | syslog(LOG_WARNING, "[WWWn:%02u CLS] close error: %s",
|
---|
1904 | www_srv_info[six].cepid, itron_strerror(error));
|
---|
1905 |
|
---|
1906 | get_tim(&now);
|
---|
1907 | syslog(LOG_NOTICE, "[WWWn:%02u FIN] finsh: %6lu",
|
---|
1908 | www_srv_info[six].cepid, now / SYSTIM_HZ);
|
---|
1909 |
|
---|
1910 | return error;
|
---|
1911 | }
|
---|
1912 |
|
---|
1913 | #ifdef USE_TCP_EXTENTIONS
|
---|
1914 |
|
---|
1915 | /*
|
---|
1916 | * WWW ãµã¼ãã¿ã¹ã¯
|
---|
1917 | */
|
---|
1918 |
|
---|
1919 | void
|
---|
1920 | www_srv_task(intptr_t exinf)
|
---|
1921 | {
|
---|
1922 | ID tskid;
|
---|
1923 | ER error = E_OK;
|
---|
1924 | uint_t six;
|
---|
1925 | char apip;
|
---|
1926 |
|
---|
1927 | syscall(get_tid(&tskid));
|
---|
1928 | six = INDEX_SRV_INFO((ID)exinf);
|
---|
1929 |
|
---|
1930 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
|
---|
1931 |
|
---|
1932 | if (six >= NUM_WWW4_SRV_TASKS)
|
---|
1933 | apip = API_PROTO_IPV6;
|
---|
1934 | else
|
---|
1935 | apip = API_PROTO_IPV4;
|
---|
1936 |
|
---|
1937 | #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
|
---|
1938 |
|
---|
1939 | apip = API_PROTO_IPVn;
|
---|
1940 |
|
---|
1941 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
|
---|
1942 |
|
---|
1943 | syslog(LOG_NOTICE, "[WWW%c:%d] started.", apip, tskid);
|
---|
1944 | while (true) {
|
---|
1945 |
|
---|
1946 | syscall(slp_tsk());
|
---|
1947 | if ((error = get_tcp_cep(&www_srv_info[six].cepid)) != E_OK) {
|
---|
1948 | syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create CEP error: %s",
|
---|
1949 | apip, www_srv_info[six].cepid, itron_strerror(error));
|
---|
1950 | continue;
|
---|
1951 | }
|
---|
1952 |
|
---|
1953 | while (true) {
|
---|
1954 |
|
---|
1955 | if ((error = get_tcp_rep(&www_srv_info[six].repid)) != E_OK) {
|
---|
1956 | syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create REP error: %02u, %s",
|
---|
1957 | apip, www_srv_info[six].cepid, www_srv_info[six].repid, itron_strerror(error));
|
---|
1958 | break;
|
---|
1959 | }
|
---|
1960 | else if ((error = www_srv(six, apip)) != E_OK) {
|
---|
1961 |
|
---|
1962 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
|
---|
1963 |
|
---|
1964 | if (tskid == WWW4_SRV_TASK)
|
---|
1965 | error = free_tcp4_rep(www_srv_info[six].repid, error != E_DLT);
|
---|
1966 | else
|
---|
1967 | error = free_tcp6_rep(www_srv_info[six].repid, error != E_DLT);
|
---|
1968 |
|
---|
1969 | #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
|
---|
1970 |
|
---|
1971 | error = FREE_TCP_REP(www_srv_info[six].repid, error != E_DLT);
|
---|
1972 |
|
---|
1973 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
|
---|
1974 |
|
---|
1975 | if (error != E_OK) {
|
---|
1976 | syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete REP error: %02u, %s",
|
---|
1977 | apip, www_srv_info[six].cepid,
|
---|
1978 | www_srv_info[six].repid, itron_strerror(error));
|
---|
1979 |
|
---|
1980 | }
|
---|
1981 | break;
|
---|
1982 | }
|
---|
1983 | }
|
---|
1984 |
|
---|
1985 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
|
---|
1986 |
|
---|
1987 | if (tskid == WWW4_SRV_TASK) {
|
---|
1988 | if ((error = free_tcp4_cep(www_srv_info[six].cepid)) != E_OK)
|
---|
1989 | syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
|
---|
1990 | apip, www_srv_info[six].cepid, itron_strerror(error));
|
---|
1991 | }
|
---|
1992 | else {
|
---|
1993 | if ((error = free_tcp6_cep(www_srv_info[six].cepid)) != E_OK)
|
---|
1994 | syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
|
---|
1995 | apip, www_srv_info[six].cepid, itron_strerror(error));
|
---|
1996 | }
|
---|
1997 |
|
---|
1998 | #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
|
---|
1999 |
|
---|
2000 | if ((error = FREE_TCP_CEP(www_srv_info[six].cepid)) != E_OK)
|
---|
2001 | syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
|
---|
2002 | apip, www_srv_info[six].cepid, itron_strerror(error));
|
---|
2003 |
|
---|
2004 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
|
---|
2005 |
|
---|
2006 | }
|
---|
2007 | }
|
---|
2008 |
|
---|
2009 | /*
|
---|
2010 | * wakeup_www_srv -- WWW ãµã¼ãã¿ã¹ã¯ã®ä¼æ¢è§£é¤
|
---|
2011 | */
|
---|
2012 |
|
---|
2013 | ER
|
---|
2014 | wakeup_www_srv (char apip)
|
---|
2015 | {
|
---|
2016 | ID taskid;
|
---|
2017 |
|
---|
2018 | if (apip == API_PROTO_IPV6)
|
---|
2019 | taskid = WWW6_SRV_TASK;
|
---|
2020 | else
|
---|
2021 | taskid = WWW4_SRV_TASK;
|
---|
2022 | syslog(LOG_NOTICE, "[WWW%c(EXT):%d] wake up.", apip, taskid);
|
---|
2023 | return wup_tsk(taskid);
|
---|
2024 | }
|
---|
2025 |
|
---|
2026 | #else /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
2027 |
|
---|
2028 | /*
|
---|
2029 | * WWW ãµã¼ãã¿ã¹ã¯
|
---|
2030 | */
|
---|
2031 |
|
---|
2032 | void
|
---|
2033 | www_srv_task(intptr_t exinf)
|
---|
2034 | {
|
---|
2035 | ID tskid, cepid;
|
---|
2036 | uint_t six;
|
---|
2037 | char apip;
|
---|
2038 |
|
---|
2039 | get_tim(&srv_start);
|
---|
2040 | get_tid(&tskid);
|
---|
2041 | six = INDEX_SRV_INFO((ID)exinf);
|
---|
2042 | cepid = www_srv_info[INDEX_SRV_INFO((ID)exinf)].cepid;
|
---|
2043 |
|
---|
2044 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
|
---|
2045 |
|
---|
2046 | if (six >= NUM_WWW4_SRV_TASKS)
|
---|
2047 | apip = API_PROTO_IPV6;
|
---|
2048 | else
|
---|
2049 | apip = API_PROTO_IPV4;
|
---|
2050 |
|
---|
2051 | #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
|
---|
2052 |
|
---|
2053 | apip = API_PROTO_IPVn;
|
---|
2054 |
|
---|
2055 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
|
---|
2056 |
|
---|
2057 | syslog(LOG_NOTICE, "[WWW%c SRV:%d,%d] started.", apip, tskid, cepid);
|
---|
2058 |
|
---|
2059 | while (true) {
|
---|
2060 | while (www_srv(six, apip) == E_OK)
|
---|
2061 | ;
|
---|
2062 | }
|
---|
2063 | }
|
---|
2064 |
|
---|
2065 | #endif /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
2066 |
|
---|
2067 | #endif /* of #ifdef USE_WWW_SRV */
|
---|