Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.c

    r321 r331  
    22 *  TINET (TCP/IP Protocol Stack)
    33 *
    4  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
     4 *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
    55 *                   Tomakomai National College of Technology, JAPAN
    66 *
     
    7575#include <net/ethernet.h>
    7676#include <net/net.h>
     77#include <net/net_endian.h>
    7778#include <net/net_buf.h>
    78 #include <net/net_timer.h>
    7979#include <net/net_count.h>
    8080
    8181#include <netinet/in.h>
    8282#include <netinet/in_itron.h>
    83 #include <netinet/ip.h>
    84 #include <netinet/ip6.h>
    85 #include <netinet/tcp.h>
    86 
     83
     84#include <netapp/netapp.h>
    8785#include <netapp/netapp_var.h>
    8886#include <netapp/wwws.h>
     
    118116#endif  /* of #if NET_COUNT_ENABLE */
    119117
     118#ifdef USE_TCP_EXTENTIONS
     119
     120#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     121
     122#if NUM_WWW_SRV_TASKS >= 2              /* 2 を超える個数は想定していない。    */
     123
     124#define WWW4_SRV_TASK   WWW_SRV_TASK1
     125#define WWW6_SRV_TASK   WWW_SRV_TASK2
     126
     127#else   /* of #if NUM_WWW_SRV_TASKS >= 2 */
     128
     129#define WWW4_SRV_TASK   WWW_SRV_TASK1
     130#define WWW6_SRV_TASK   WWW_SRV_TASK1
     131
     132#endif  /* of #if NUM_WWW_SRV_TASKS >= 2 */
     133
     134#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     135
     136#define WWW4_SRV_TASK   WWW_SRV_TASK1
     137#define WWW6_SRV_TASK   WWW_SRV_TASK1
     138
     139#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     140
     141#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     142
     143
    120144/*
    121145 *  全域変数
     
    161185#define ST_NOT_FOUND    1
    162186
     187/*
     188 *  接続相手の情報構造体
     189 */
     190
     191#ifdef  NUM_WWW4_SRV_TASKS
     192#undef  NUM_WWW4_SRV_TASKS
     193#endif
     194#define NUM_WWW4_SRV_TASKS              1
     195
     196typedef struct t_www_srv_info {
     197        ID      cepid;          /* 通信端点 ID              */
     198        ID      repid;          /* 受付口   ID             */
     199        T_IPEP  dst;            /* 接続相手アドレス情報   */
     200        } T_WWW_SRV_INFO;
     201
     202#define INDEX_SRV_INFO(id)      ((id)-1)
     203
     204#ifdef USE_TCP_EXTENTIONS
     205
     206static T_WWW_SRV_INFO www_srv_info[NUM_WWW_SRV_TASKS];
     207                                        /* 2 を超える個数は想定していない。    */
     208
     209#else   /* of #ifdef USE_TCP_EXTENTIONS */
     210
     211static T_WWW_SRV_INFO www_srv_info[] = {
     212
     213#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     214
     215        { WWW4_SRV_CEPID1, WWW4_SRV_REPID },
     216
     217#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     218
     219        { WWW_SRV_CEPID1, WWW_SRV_REPID },
     220
     221#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     222
     223#if NUM_WWW_SRV_TASKS >= 2              /* 2 を超える個数は想定していない。    */
     224        { WWW_SRV_CEPID2, WWW_SRV_REPID },
     225#endif
     226
     227        };
     228
     229#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     230
    163231#ifdef USE_COPYSAVE_API
    164232
     
    180248                if (srbuf->rbuf.index >= srbuf->rbuf.len) {
    181249                        if ((error = tcp_rel_buf(cepid, srbuf->rbuf.len)) != E_OK)
    182                                 syslog(LOG_WARNING, "[WWW:%02d] tcp_rel_buf error: %s",
     250                                syslog(LOG_WARNING, "[WWWn:%02u REL] tcp_rel_buf error: %s",
    183251                                       cepid, itron_strerror(error));
    184252                        srbuf->rbuf.index = 0;
    185253                        if ((len = tcp_rcv_buf(cepid, (void**)&srbuf->rbuf.buf, TMO_FEVR)) <= 0) {
    186254                                if (len < 0)
    187                                         syslog(LOG_WARNING, "[WWW:%02d] tcp_rcv_buf error: %s",
     255                                        syslog(LOG_WARNING, "[WWWn:%02u RCV] tcp_rcv_buf error: %s",
    188256                                               cepid, itron_strerror(len));
    189257                                srbuf->rbuf.len = 0;
     
    228296                if (srbuf->sbuf.index >= srbuf->sbuf.len)
    229297                        if ((error = flush_sbuf(cepid, srbuf)) != E_OK) {
    230                                 syslog(LOG_WARNING, "[WWW:%02d] tcp_snd_dat error: %s", cepid, itron_strerror(error));
     298                                syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error));
    231299                        return 0;
    232300                        }
     
    234302                if (srbuf->sbuf.len == 0) {
    235303                        if ((blen = tcp_get_buf(cepid, (void**)&srbuf->sbuf.buf, TMO_FEVR)) < 0) {
    236                                 syslog(LOG_WARNING, "[WWW:%02d] tcp_get_buf error: %s", cepid, itron_strerror(srbuf->sbuf.len));
     304                                syslog(LOG_WARNING, "[WWWn:%02u GET] error: %s", cepid, itron_strerror(srbuf->sbuf.len));
    237305                                return 0;
    238306                                }
     
    272340                        if ((len = tcp_rcv_dat(cepid, srbuf->rbuf.buf, sizeof(srbuf->rbuf.buf), TMO_FEVR)) <= 0) {
    273341                                if (len < 0) {
    274                                         syslog(LOG_WARNING, "[WWW:%02d] tcp_rcv_dat error: %s",
     342                                        syslog(LOG_WARNING, "[WWWn:%02u RCV] error: %s",
    275343                                               cepid, itron_strerror(len));
    276344                                        }
     
    321389                if (srbuf->sbuf.index >= srbuf->sbuf.len)
    322390                        if ((error = flush_sbuf(cepid, srbuf)) != E_OK) {
    323                                 syslog(LOG_WARNING, "[WWW:%02d] tcp_snd_dat error: %s", cepid, itron_strerror(error));
     391                                syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error));
    324392                        return 0;
    325393                        }
     
    476544        int_t   ix;
    477545
    478         for (ix = NUM_FILES; ix -- > 0; )
     546        for (ix = NUM_FILES; ix -- > 0; ) {
    479547                if (!strcmp(file[ix].uri, &line->buf[line->off[1]])) {
     548                        //syslog(LOG_NOTICE, "[WWWn:%02u PTH] '%s'", cepid, &line->buf[line->off[1]]);
    480549                        return (*file[ix].func)(cepid, srbuf);
    481550                        }
     551                }
    482552        put_status(cepid, srbuf, ST_NOT_FOUND);
    483553        return E_NOEXS;
     
    494564        ER              error = E_OK;
    495565        int_t           blen = 0;
    496         uint16_t        len;
    497566
    498567        if ((error = tget_mpf(MPF_WWW_LINE, (void*)&method, TMO_FEVR)) != E_OK) {
    499                 syslog(LOG_CRIT, "[WWW:%02d] get line error: %s.",
     568                syslog(LOG_CRIT, "[WWWn:%02u MPF] get line error: %s.",
    500569                       cepid, itron_strerror(error));
    501570                return error;
    502571                }
    503572
    504         if ((len = get_line(cepid, method, srbuf)) == 0) {
     573        if (get_line(cepid, method, srbuf) == 0) {
    505574                if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
    506                         syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
     575                        syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
    507576                               cepid, itron_strerror(error));
    508577                return error;
     
    510579
    511580        if ((error = tget_mpf(MPF_WWW_LINE, (void*)&line, TMO_FEVR)) != E_OK) {
    512                 syslog(LOG_CRIT, "[WWW:%02d] get line buffer error: %s.",
     581                syslog(LOG_CRIT, "[WWWn:%02u MPF] get line buffer error: %s.",
    513582                       cepid, itron_strerror(error));
    514583                if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
    515                         syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
     584                        syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
    516585                               cepid, itron_strerror(error));
    517586                return error;
    518587                }
    519588
    520         while ((len = get_line(cepid, line, srbuf)) > 0) {      /* ヘッダをスキップする。*/
     589        while (get_line(cepid, line, srbuf) > 0) {      /* ヘッダをスキップする。*/
    521590                split_fields(line, ": ");
    522591                if (strcmp("Content-Length", &line->buf[line->off[0]]) == 0)
    523592                        blen = atoi(&line->buf[line->off[1]]);
    524593                }
    525         while (blen > 0 && (len = get_line(cepid, line, srbuf)) > 0) {
     594        while (blen > 0 && get_line(cepid, line, srbuf) > 0) {
    526595                /* エンティティ・ボディをスキップする。*/
    527596                blen -= line->len;
     
    529598
    530599        if ((error = rel_mpf(MPF_WWW_LINE, line)) != E_OK)
    531                 syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
     600                syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
    532601                       cepid, itron_strerror(error));
    533602       
     
    539608
    540609        if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
    541                 syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
     610                syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
    542611                       cepid, itron_strerror(error));
    543612
     
    567636
    568637#ifdef TARGET_KERNEL_ASP
    569                 "ASP Kernel Release 1.3 (patchlevel = 2) for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
     638                "ASP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
    570639#endif
    571640
    572641#ifdef TARGET_KERNEL_JSP
    573                 "JSP Kernel Release 1.4 (patchlevel = 3) for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
     642                "JSP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
    574643#endif
    575644
    576645                "TINET TCP/IP プロトコルスタックによりサービスしています。<br><hr>\r\n"
     646
     647#if NET_COUNT_ENABLE
     648
    577649                "<ul><li type=\"square\"><a href=\"stat.html\">ネットワーク統計情報</a></ul><hr>\r\n"
     650
     651#else   /* of #if NET_COUNT_ENABLE */
     652
     653                "<ul><li type=\"square\">ネットワーク統計情報</ul><hr>\r\n"
     654
     655#endif  /* of #if NET_COUNT_ENABLE */
     656
    578657                "FreeBSD: Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995<br>\r\n"
    579658                "The Regents of the University of California.  All rights reserved.<br><br>\r\n"
     
    629708        len += put_str(cepid, srbuf, response);
    630709        get_tim(&finish);
    631         syslog(LOG_NOTICE, "[WWW:%02u]     send:              index.html, len: %4u, time: %lu [ms]",
     710        syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [ms]",
    632711                           cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
    633712        return E_OK;
     
    15301609
    15311610        get_tim(&finish);
    1532         syslog(LOG_NOTICE, "[WWW:%02u]     send:              stat.html,  len: %4u, time: %lu [ms]",
     1611        syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html,  len: %4u, time: %lu [ms]",
    15331612                           cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
    15341613        return E_OK;
     
    15371616#endif  /* of #if NET_COUNT_ENABLE */
    15381617
    1539 /*
    1540  *  WWW サーバ
    1541  */
    1542 
    1543 static ER
    1544 www_srv (ID cepid, ID repid)
    1545 {
    1546 #if defined(SUPPORT_INET4)
    1547 
    1548         T_IPV4EP        dst;
    1549 
    1550 #endif  /* of #if defined(SUPPORT_INET4) */
    1551 
    1552 #if defined(SUPPORT_INET6)
    1553 
    1554         T_IPV6EP        dst;
    1555 
    1556 #endif  /* of #if defined(SUPPORT_INET6) */
    1557 
    1558         T_WWW_RWBUF     *srbuf;
    1559         ER              error;
    1560         SYSTIM          time;
    1561 
    1562         if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
    1563                 syslog(LOG_WARNING, "[WWW:%02d] accept error: %s", cepid, itron_strerror(error));
    1564                 return error;
    1565                 }
    1566 
    1567         get_tim(&time);
    1568         syslog(LOG_NOTICE, "[WWW:%02u]     connected:  %6lu, from: %s.%u",
    1569                            cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    1570 
    1571         if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) {
    1572                 syslog(LOG_CRIT, "[WWW:%02d] get buffer error: %s.", cepid, itron_strerror(error));
    1573                 srbuf = NULL;
    1574                 }
    1575         else {
    1576                 srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0;
    1577 
    1578 #ifdef USE_COPYSAVE_API
    1579 
    1580                 srbuf->sbuf.len = 0;
    1581 
    1582 #else   /* of #ifdef USE_COPYSAVE_API */
    1583 
    1584                 srbuf->sbuf.len = sizeof(srbuf->sbuf.buf);
    1585 
    1586 #endif  /* of #ifdef USE_COPYSAVE_API */
    1587 
    1588                 if ((error = parse_request(cepid, srbuf)) != E_OK)
    1589                         syslog(LOG_WARNING, "[WWW:%02d] parse request error: %s",
    1590                                cepid, itron_strerror(error));
    1591                 }
    1592 
    1593         if ((error = tcp_sht_cep(cepid)) != E_OK)
    1594                 syslog(LOG_WARNING, "[WWW:%02d] shutdown error: %s", cepid, itron_strerror(error));
    1595 
    1596         if (srbuf != NULL) {
    1597                 while (get_char(cepid, srbuf) != EOF)
    1598                         ;
    1599                 if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK)
    1600                         syslog(LOG_WARNING, "[WWW:%02d] release buffer error: %s.",
    1601                                cepid, itron_strerror(error));
    1602                 }
    1603 
    1604         if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
    1605                 syslog(LOG_WARNING, "[WWW:%02d] close error: %s", cepid, itron_strerror(error));
    1606 
    1607         get_tim(&time);
    1608         syslog(LOG_NOTICE, "[WWW:%02u]     finished:   %6lu", cepid, time / SYSTIM_HZ);
    1609 
    1610         return error;
    1611         }
    1612 
    16131618#ifdef USE_TCP_EXTENTIONS
    16141619
     
    16161621 *  get_tcp_rep -- TCP 受付口を獲得する。
    16171622 */
     1623
     1624#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
    16181625
    16191626static ER
     
    16211628{
    16221629        ID              tskid;
    1623         T_TCP_CREP      crep;
     1630        T_TCP6_CREP     crep6;
     1631        T_TCP_CREP      crep4;
     1632
     1633        get_tid(&tskid);
     1634        if (tskid == WWW4_SRV_TASK) {
     1635                crep4.repatr = UINT_C(0);
     1636                crep4.myaddr.portno = UINT_C(80);
     1637                crep4.myaddr.ipaddr = IPV4_ADDRANY;
     1638                return alloc_tcp4_rep(repid, tskid, &crep4);
     1639                }
     1640        else {
     1641                crep6.repatr = UINT_C(0);
     1642                crep6.myaddr.portno = UINT_C(80);
     1643                memcpy(&crep6.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
     1644                return alloc_tcp6_rep(repid, tskid, &crep6);
     1645                }
     1646        }
     1647
     1648#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1649
     1650static ER
     1651get_tcp_rep (ID *repid)
     1652{
     1653        ID              tskid;
     1654        T_TCPN_CREP     crep;
    16241655
    16251656        get_tid(&tskid);
     
    16271658        crep.repatr = UINT_C(0);
    16281659        crep.myaddr.portno = UINT_C(80);
     1660
     1661#if defined(SUPPORT_INET6)
     1662
     1663        memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
     1664
     1665#else   /* #if defined(SUPPORT_INET6) */
    16291666
    16301667#if defined(SUPPORT_INET4)
     
    16321669#endif
    16331670
    1634 #if defined(SUPPORT_INET6)
    1635         memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
    1636 #endif
    1637 
    1638 
    1639         return alloc_tcp_rep(repid, tskid, &crep);
    1640         }
    1641 
    1642 /*
    1643  *  get_tcp_cep -- TCP 通信端点とを獲得する。
     1671#endif  /* #if defined(SUPPORT_INET6) */
     1672
     1673        return ALLOC_TCP_REP(repid, tskid, &crep);
     1674        }
     1675
     1676#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1677
     1678/*
     1679 *  get_tcp_cep -- TCP 通信端点を獲得する。
    16441680 */
    16451681
     
    16681704#endif
    16691705
    1670         return alloc_tcp_cep(cepid, tskid, &ccep);
    1671         }
     1706#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     1707
     1708        if (tskid == WWW4_SRV_TASK)
     1709                return alloc_tcp4_cep(cepid, tskid, &ccep);
     1710        else
     1711                return alloc_tcp6_cep(cepid, tskid, &ccep);
     1712
     1713#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1714
     1715        return ALLOC_TCP_CEP(cepid, tskid, &ccep);
     1716
     1717#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1718
     1719        }
     1720
     1721#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     1722
     1723/*
     1724 *  tcp_passive_open -- 受動オープンを実行する。
     1725 *
     1726 *    USE_TCP_NON_BLOCKING      OFF
     1727 */
     1728
     1729#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     1730
     1731static ER
     1732tcp_passive_open (T_WWW_SRV_INFO *info, char apip)
     1733{
     1734        ER              error = E_OK;
     1735        T_IPV4EP        dst4;
     1736
     1737        if (apip == API_PROTO_IPV6) {
     1738                /* 受付口は IPv6 */
     1739                if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
     1740                        return error;
     1741
     1742#ifdef USE_TCP_EXTENTIONS
     1743                if ((error = free_tcp6_rep(info->repid, true)) != E_OK)
     1744                        return error;
     1745#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     1746
     1747                }
     1748        else {
     1749                /* 受付口は IPv4 */
     1750                if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK)
     1751                        return error;
     1752                in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr);
     1753                info->dst.portno = dst4.portno;
     1754
     1755#ifdef USE_TCP_EXTENTIONS
     1756                if ((error = free_tcp4_rep(info->repid, true)) != E_OK)
     1757                        return error;
     1758#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     1759                }
     1760
     1761        return error;
     1762        }
     1763
     1764#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1765
     1766static ER
     1767tcp_passive_open (T_WWW_SRV_INFO *info, char apip)
     1768{
     1769        ER              error = E_OK;
     1770
     1771        if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
     1772                return error;
     1773
     1774#ifdef USE_TCP_EXTENTIONS
     1775        if ((error = FREE_TCP_REP(info->repid, true)) != E_OK)
     1776                return error;
     1777#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     1778
     1779        return error;
     1780        }
     1781
     1782#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1783
     1784/*
     1785 *  WWW サーバ
     1786 */
     1787
     1788static ER
     1789www_srv (uint_t six, char apip)
     1790{
     1791        T_WWW_RWBUF     *srbuf;
     1792        ER              error;
     1793        SYSTIM          now;
     1794
     1795        if ((error = tcp_passive_open(&www_srv_info[six], apip)) != E_OK)
     1796                return error;
     1797
     1798        syscall(get_tim(&now));
     1799
     1800#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     1801
     1802        if (apip == API_PROTO_IPV6)
     1803                syslog(LOG_NOTICE, "[WWW6:%02u ACP] conct:  %6lu,from: %s.%u",
     1804                                   www_srv_info[six].cepid, now / SYSTIM_HZ,
     1805                                   ipv62str(NULL, &www_srv_info[six].dst.ipaddr),
     1806                                   www_srv_info[six].dst.portno);
     1807        else
     1808                syslog(LOG_NOTICE, "[WWW4:%02u ACP] conct:  %6lu,from: %s.%u",
     1809                                   www_srv_info[six].cepid, now / SYSTIM_HZ,
     1810                                   ip2str(NULL, &www_srv_info[six].dst.ipaddr.s6_addr32[3]),
     1811                                   www_srv_info[six].dst.portno);
     1812
     1813#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     1814
     1815        syslog(LOG_NOTICE, "[WWWn:%02u ACP] conct:  %6lu,from: %s.%u",
     1816                           www_srv_info[six].cepid, now / SYSTIM_HZ,
     1817                           IP2STR(NULL, &www_srv_info[six].dst.ipaddr),
     1818                           www_srv_info[six].dst.portno);
     1819
     1820#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     1821
     1822        if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) {
     1823                syslog(LOG_CRIT, "[WWWn:%02u MPF] get buffer error: %s.",
     1824                                 www_srv_info[six].cepid, itron_strerror(error));
     1825                srbuf = NULL;
     1826                }
     1827        else {
     1828                srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0;
     1829
     1830#ifdef USE_COPYSAVE_API
     1831
     1832                srbuf->sbuf.len = 0;
     1833
     1834#else   /* of #ifdef USE_COPYSAVE_API */
     1835
     1836                srbuf->sbuf.len = sizeof(srbuf->sbuf.buf);
     1837
     1838#endif  /* of #ifdef USE_COPYSAVE_API */
     1839
     1840                if ((error = parse_request(www_srv_info[six].cepid, srbuf)) != E_OK)
     1841                        syslog(LOG_WARNING, "[WWWn:%02u RCV] parse request error: %s",
     1842                                            www_srv_info[six].cepid, itron_strerror(error));
     1843                }
     1844
     1845        if ((error = tcp_sht_cep(www_srv_info[six].cepid)) != E_OK)
     1846                syslog(LOG_WARNING, "[WWWn:%02u SHD] shutdown error: %s",
     1847                                    www_srv_info[six].cepid, itron_strerror(error));
     1848
     1849        if (srbuf != NULL) {
     1850                while (get_char(www_srv_info[six].cepid, srbuf) != EOF)
     1851                        ;
     1852                if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK)
     1853                        syslog(LOG_WARNING, "[WWWn:%02u REL] release buffer error: %s.",
     1854                                            www_srv_info[six].cepid, itron_strerror(error));
     1855                }
     1856
     1857        if ((error = tcp_cls_cep(www_srv_info[six].cepid, TMO_FEVR)) != E_OK)
     1858                syslog(LOG_WARNING, "[WWWn:%02u CLS] close error: %s",
     1859                                    www_srv_info[six].cepid, itron_strerror(error));
     1860
     1861        get_tim(&now);
     1862        syslog(LOG_NOTICE, "[WWWn:%02u FIN] finsh:  %6lu",
     1863                           www_srv_info[six].cepid, now / SYSTIM_HZ);
     1864
     1865        return error;
     1866        }
     1867
     1868#ifdef USE_TCP_EXTENTIONS
    16721869
    16731870/*
     
    16781875www_srv_task(intptr_t exinf)
    16791876{
    1680         ID      tskid, cepid, repid;
     1877        ID      tskid;
    16811878        ER      error = E_OK;
     1879        uint_t  six;
     1880        char    apip;
    16821881
    16831882        syscall(get_tid(&tskid));
    1684         syslog(LOG_NOTICE, "[WWW:%d] started.", tskid);
     1883        six = INDEX_SRV_INFO((ID)exinf);
     1884
     1885#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     1886
     1887        if (six >= NUM_WWW4_SRV_TASKS)
     1888                apip = API_PROTO_IPV6;
     1889        else
     1890                apip = API_PROTO_IPV4;
     1891
     1892#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     1893
     1894        apip = API_PROTO_IPVn;
     1895
     1896#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     1897
     1898        syslog(LOG_NOTICE, "[WWW%c:%d] started.", apip, tskid);
    16851899        while (true) {
    16861900
    16871901                syscall(slp_tsk());
    1688                 if ((error = get_tcp_cep (&cepid)) != E_OK) {
    1689                         syslog(LOG_NOTICE, "[WWW:00 EXT] CEP create error: %s", itron_strerror(error));
     1902                if ((error = get_tcp_cep(&www_srv_info[six].cepid)) != E_OK) {
     1903                        syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create CEP error: %s",
     1904                                           apip, www_srv_info[six].cepid, itron_strerror(error));
    16901905                        continue;
    16911906                        }
    16921907
    1693                 if ((error = get_tcp_rep (&repid)) != E_OK) {
    1694                         syslog(LOG_NOTICE, "[WWW:00 EXT] REP create error: %s", itron_strerror(error));
    1695                         free_tcp_cep(cepid);
    1696                         continue;
    1697                         }
    1698 
    1699                 while (true)
    1700                         if ((error = www_srv(cepid, repid)) != E_OK) {
    1701                                 error = free_tcp_rep(repid, error != E_DLT);
     1908                while (true) {
     1909
     1910                        if ((error = get_tcp_rep(&www_srv_info[six].repid)) != E_OK) {
     1911                                syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create REP error: %02u, %s",
     1912                                                   apip, www_srv_info[six].cepid, www_srv_info[six].repid, itron_strerror(error));
    17021913                                break;
    17031914                                }
    1704 
    1705                 if ((error = free_tcp_cep(cepid)) != E_OK)
    1706                         syslog(LOG_NOTICE, "[WWW:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error));
    1707 
    1708                 }
     1915                        else if ((error = www_srv(six, apip)) != E_OK) {
     1916
     1917#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     1918
     1919                                if (tskid == WWW4_SRV_TASK)
     1920                                        error = free_tcp4_rep(www_srv_info[six].repid, error != E_DLT);
     1921                                else
     1922                                        error = free_tcp6_rep(www_srv_info[six].repid, error != E_DLT);
     1923
     1924#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1925
     1926                                error = FREE_TCP_REP(www_srv_info[six].repid, error != E_DLT);
     1927
     1928#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1929
     1930                                if (error != E_OK) {
     1931                                        syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete REP error: %02u, %s",
     1932                                                           apip, www_srv_info[six].cepid,
     1933                                                                              www_srv_info[six].repid, itron_strerror(error));
     1934
     1935                                        }
     1936                                break;
     1937                                }
     1938                        }
     1939
     1940#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     1941
     1942                if (tskid == WWW4_SRV_TASK) {
     1943                        if ((error = free_tcp4_cep(www_srv_info[six].cepid)) != E_OK)
     1944                                syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
     1945                                                   apip, www_srv_info[six].cepid, itron_strerror(error));
     1946                        }
     1947                else {
     1948                        if ((error = free_tcp6_cep(www_srv_info[six].cepid)) != E_OK)
     1949                                syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
     1950                                                   apip, www_srv_info[six].cepid, itron_strerror(error));
     1951                        }
     1952
     1953#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1954
     1955                if ((error = FREE_TCP_CEP(www_srv_info[six].cepid)) != E_OK)
     1956                        syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
     1957                                           apip, www_srv_info[six].cepid, itron_strerror(error));
     1958
     1959#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1960
     1961                }
     1962        }
     1963
     1964/*
     1965 *  wakeup_www_srv -- WWW サーバタスクの休止解除
     1966 */
     1967
     1968ER
     1969wakeup_www_srv (char apip)
     1970{
     1971        ID      taskid;
     1972
     1973        if (apip == API_PROTO_IPV6)
     1974                taskid = WWW6_SRV_TASK;
     1975        else
     1976                taskid = WWW4_SRV_TASK;
     1977        syslog(LOG_NOTICE, "[WWW%c(EXT):%d] wake up.", apip, taskid);
     1978        return wup_tsk(taskid);
    17091979        }
    17101980
     
    17181988www_srv_task(intptr_t exinf)
    17191989{
    1720         ID      tskid;
     1990        ID      tskid, cepid;
     1991        uint_t  six;
     1992        char    apip;
    17211993
    17221994        get_tim(&srv_start);
    17231995        get_tid(&tskid);
    1724         syslog(LOG_NOTICE, "[WWW:%d,%d] started.", tskid, (int_t)exinf);
     1996        six = INDEX_SRV_INFO((ID)exinf);
     1997        cepid = www_srv_info[INDEX_SRV_INFO((ID)exinf)].cepid;
     1998
     1999#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     2000
     2001        if (six >= NUM_WWW4_SRV_TASKS)
     2002                apip = API_PROTO_IPV6;
     2003        else
     2004                apip = API_PROTO_IPV4;
     2005
     2006#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     2007
     2008        apip = API_PROTO_IPVn;
     2009
     2010#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     2011
     2012        syslog(LOG_NOTICE, "[WWW%c SRV:%d,%d] started.", apip, tskid, cepid);
     2013
    17252014        while (true) {
    1726                 while (www_srv((int_t)exinf, WWW_SRV_REPID) == E_OK)
     2015                while (www_srv(six, apip) == E_OK)
    17272016                        ;
    17282017                }
Note: See TracChangeset for help on using the changeset viewer.