Ignore:
Timestamp:
Feb 1, 2019, 9:57:09 PM (5 years ago)
Author:
coas-nagasima
Message:

TINETとSocket APIなどを更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/net/net_buf.c

    r352 r364  
    6868#include <netinet/tcp_var.h>
    6969
     70#ifndef NOUSE_MPF_NET_BUF
     71
    7072/*
    7173 *  関数
     
    226228#endif  /* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */
    227229
    228 #if defined(_IP4_CFG)
     230#if defined(_IP6_CFG)
     231
     232#if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
     233        {
     234                MPF_NET_BUF_CSEG,
     235                IF_HDR_SIZE + IP_HDR_SIZE + TCP_HDR_SIZE,
     236
     237#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
     238
     239                NUM_MPF_NET_BUF_CSEG,
     240
     241#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
     242
     243                },
     244#endif  /* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
     245
     246#endif  /* of #if defined(_IP6_CFG) */
    229247
    230248#if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0
     
    242260#endif  /* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */
    243261
    244 #endif  /* of #if defined(_IP4_CFG) */
     262#if defined(_IP4_CFG) && !defined(_IP6_CFG)
    245263
    246264#if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
     
    257275                },
    258276#endif  /* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
     277
     278#endif  /* of #if defined(_IP4_CFG) && !defined(_IP6_CFG) */
    259279
    260280        };
     
    307327
    308328        while (1) {
    309                 if ((error = tget_mpf((ID)net_buf_table[ix].index, (void*)buf, ix == 0 ? tmout : TMO_POL)) == E_OK) {
     329                if ((error = tget_mpf((ID)net_buf_table[ix].index, (void **)buf, ix == 0 ? tmout : TMO_POL)) == E_OK) {
    310330                        (*buf)->idix  = (uint8_t)ix;
    311331                        (*buf)->len   = (uint16_t)minlen;
     
    320340                        return error;
    321341                        }
    322                 else if (ix == 0 || net_buf_table[ix].size > maxlen)
     342                ix --;
     343                if (ix < 0 || net_buf_table[ix].size > maxlen)
    323344                        break;
    324                 ix --;
    325345                }
    326346
     
    351371
    352372        while (1) {
    353                 if ((error = tget_mpf((ID)net_buf_table[ix].index, (void*)buf,
     373                if ((error = tget_mpf((ID)net_buf_table[ix].index, (void **)buf,
    354374                                      ix == sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY) - 1 ? tmout : TMO_POL)) == E_OK) {
    355375                        (*buf)->idix  = (uint8_t)ix;
     
    359379                        (*buf)->conn_pos = 0;
    360380#endif
     381
    361382#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
    362383                        NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1);
     
    454475                /* 固定メモリプールに返す。*/
    455476
    456 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
    457                 net_buf_table[buf->idix].busies --;
    458 #endif
    459                 if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK) {
    460                         syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), buf->idix);
     477                int idix = buf->idix;
     478#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
     479                net_buf_table[idix].busies --;
     480#endif
     481                if ((error = rel_mpf((ID)net_buf_table[idix].index, buf)) != E_OK) {
     482                        syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), idix);
    461483                        }
    462484                }
     
    509531        return (uint_t)net_buf_table[0].size;
    510532        }
     533
     534#else
     535#include <stdlib.h>
     536
     537/*
     538 *  tget_net_buf_ex -- ネットワークバッファを獲得する(拡張機能)。
     539 */
     540
     541ER
     542tget_net_buf_ex (T_NET_BUF **buf, uint_t minlen, uint_t maxlen, ATR nbatr, TMO tmout)
     543{
     544        uint_t len = (minlen > maxlen) ? minlen : maxlen;
     545        *buf = (T_NET_BUF *)malloc(sizeof(T_NET_BUF) - sizeof(((T_NET_BUF *)0)->buf) + len);
     546        if (*buf == NULL)
     547                return E_NOMEM;
     548
     549        (*buf)->idix = 0;
     550        (*buf)->len = (uint16_t)len;
     551        (*buf)->flags = 0;
     552#ifdef IF_ETHER_MULTI_NIC
     553        (*buf)->conn_pos = 0;
     554#endif
     555
     556        return E_OK;
     557        }
     558
     559/*
     560 *  tget_net_buf -- ネットワークバッファを獲得する(互換)。
     561 */
     562
     563ER
     564tget_net_buf (T_NET_BUF **buf, uint_t len, TMO tmout)
     565{
     566        return tget_net_buf_ex(buf, len, len, NBA_SEARCH_ASCENT, tmout);
     567        }
     568
     569
     570/*
     571 * rel_net_buf -- ネットワークバッファを返却する。
     572 */
     573
     574ER
     575rel_net_buf (T_NET_BUF *buf)
     576{
     577        free(buf);
     578
     579        return E_OK;
     580        }
     581
     582
     583/*
     584 * net_buf_max_siz -- ネットワークバッファの最大サイズを返す。
     585 */
     586
     587uint_t
     588net_buf_max_siz (void)
     589{
     590        return (uint_t)IF_PDU_SIZE;
     591        }
     592
     593#endif
Note: See TracChangeset for help on using the changeset viewer.