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_rx/trunk/asp3_dcre/tinet/net/net_buf.c

    r337 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;
     
    318338                        return error;
    319339                        }
    320                 else if (ix == 0 || net_buf_table[ix].size > maxlen)
     340                ix --;
     341                if (ix < 0 || net_buf_table[ix].size > maxlen)
    321342                        break;
    322                 ix --;
    323343                }
    324344
     
    349369
    350370        while (1) {
    351                 if ((error = tget_mpf((ID)net_buf_table[ix].index, (void*)buf,
     371                if ((error = tget_mpf((ID)net_buf_table[ix].index, (void **)buf,
    352372                                      ix == sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY) - 1 ? tmout : TMO_POL)) == E_OK) {
    353373                        (*buf)->idix  = (uint8_t)ix;
    354374                        (*buf)->len   = net_buf_table[ix].size;
    355375                        (*buf)->flags = 0;
     376#ifdef IF_ETHER_MULTI_NIC
     377                        (*buf)->conn_pos = 0;
     378#endif
    356379
    357380#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
     
    450473                /* 固定メモリプールに返す。*/
    451474
    452 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
    453                 net_buf_table[buf->idix].busies --;
     475                int idix = buf->idix;
     476#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
     477                net_buf_table[idix].busies --;
    454478#endif
    455                 if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK) {
    456                         syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), buf->idix);
     479                if ((error = rel_mpf((ID)net_buf_table[idix].index, buf)) != E_OK) {
     480                        syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), idix);
    457481                        }
    458482                }
     
    505529        return (uint_t)net_buf_table[0].size;
    506530        }
     531
     532#else
     533#include <stdlib.h>
     534
     535/*
     536 *  tget_net_buf_ex -- ネットワークバッファを獲得する(拡張機能)。
     537 */
     538
     539ER
     540tget_net_buf_ex (T_NET_BUF **buf, uint_t minlen, uint_t maxlen, ATR nbatr, TMO tmout)
     541{
     542        uint_t len = (minlen > maxlen) ? minlen : maxlen;
     543        *buf = (T_NET_BUF *)malloc(sizeof(T_NET_BUF) - sizeof(((T_NET_BUF *)0)->buf) + len);
     544        if (*buf == NULL)
     545                return E_NOMEM;
     546
     547        (*buf)->idix = 0;
     548        (*buf)->len = (uint16_t)len;
     549        (*buf)->flags = 0;
     550
     551        return E_OK;
     552        }
     553
     554/*
     555 *  tget_net_buf -- ネットワークバッファを獲得する(互換)。
     556 */
     557
     558ER
     559tget_net_buf (T_NET_BUF **buf, uint_t len, TMO tmout)
     560{
     561        return tget_net_buf_ex(buf, len, len, NBA_SEARCH_ASCENT, tmout);
     562        }
     563
     564
     565/*
     566 * rel_net_buf -- ネットワークバッファを返却する。
     567 */
     568
     569ER
     570rel_net_buf (T_NET_BUF *buf)
     571{
     572        free(buf);
     573
     574        return E_OK;
     575        }
     576
     577
     578/*
     579 * net_buf_max_siz -- ネットワークバッファの最大サイズを返す。
     580 */
     581
     582uint_t
     583net_buf_max_siz (void)
     584{
     585        return (uint_t)IF_PDU_SIZE;
     586        }
     587
     588#endif
Note: See TracChangeset for help on using the changeset viewer.