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

TINETとSocket APIなどを更新

Location:
asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/net
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/net/ethernet.h

    r359 r364  
    9898#endif  /* of #ifndef IF_ETHER_NIC_HDR_ALIGN */
    9999
    100 #if defined(__RX) || defined(_MSC_VER)
    101100#if defined(__RX)
    102101#pragma pack
    103 #else
     102#elif defined(_MSC_VER)
    104103#pragma pack(push, 1)
    105104#endif
     105
     106#if defined(__RX) || defined(_MSC_VER)
     107
    106108typedef struct t_ether_header {
    107109
     
    116118        uint16_t        type;
    117119        } T_ETHER_HDR;
    118 #if defined(__RX)
    119 #pragma packoption
    120 #else
    121 #pragma pack(pop)
    122 #endif
    123120
    124121#elif defined(TOPPERS_S810_CLG3_85)     /* of #if defined(__RX) */
     
    166163        uint8_t         lladdr[ETHER_ADDR_LEN];
    167164        } __attribute__((packed, aligned(2))) T_ETHER_ADDR;
     165
     166#if defined(__RX)
     167#pragma packoption
     168#elif defined(_MSC_VER)
     169#pragma pack(pop)
     170#endif
    168171
    169172/*
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/net/net_asp.cfg

    r337 r364  
    4141
    4242INCLUDE("net/net.cfg");
     43
     44#ifndef NOUSE_MPF_NET_BUF
    4345
    4446/*
     
    169171                });
    170172#endif  /* of #if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0 */
     173
     174#endif
  • 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
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/net/net_rename.h

    r337 r364  
    7171#define tget_net_buf_ex         _tinet_tget_net_buf_ex
    7272#define tget_net_buf            _tinet_tget_net_buf
    73 #define rel_net_buf             _tinet_rel_net_buf
    74 #define rus_net_buf             _tinet_rus_net_buf
    75 #define net_buf_siz             _tinet_net_buf_siz
     73#define rel_net_buf                     _tinet_rel_net_buf
     74#define rus_net_buf                     _tinet_rus_net_buf
     75#define net_buf_siz                     _tinet_net_buf_siz
    7676#define net_buf_max_siz         _tinet_net_buf_max_siz
    7777#define nbuf_get_tbl            _tinet_nbuf_get_tbl
Note: See TracChangeset for help on using the changeset viewer.