Changeset 429 for EcnlProtoTool/trunk/asp3_dcre/tinet/net
- Timestamp:
- Jul 3, 2020, 7:19:17 PM (4 years ago)
- Location:
- EcnlProtoTool/trunk/asp3_dcre/tinet/net
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.c
r331 r429 195 195 196 196 /** 197 * Called by a driver when its link goes up 198 */ 199 void ether_set_link_up(T_IFNET *ether) 200 { 201 if (!(ether->flags & IF_FLAG_LINK_UP)) { 202 ether->flags |= IF_FLAG_LINK_UP; 203 204 if (ether->flags & IF_FLAG_UP) { 205 #if LWIP_ARP 206 /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ 207 if (ether->flags & IF_FLAG_ETHARP) { 208 etharp_gratuitous(ether); 209 } 210 #endif /* LWIP_ARP */ 211 212 #if LWIP_IGMP 213 /* resend IGMP memberships */ 214 if (ether->_flags & IF_FLAG_IGMP) { 215 igmp_report_groups(ether); 216 } 217 #endif /* LWIP_IGMP */ 218 } 219 if (ether->link_callback) { 220 (ether->link_callback)(ether); 221 } 222 } 223 } 197 * ether_set_link_up -- リンクしたときにNICから呼び出される 198 */ 199 void 200 ether_set_link_up() 201 { 202 if (!(ether_ifnet.flags & IF_FLAG_LINK_UP)) { 203 ether_ifnet.flags |= IF_FLAG_LINK_UP; 204 205 if (ether_ifnet.flags & IF_FLAG_UP) { 206 #if defined(_IP4_CFG) && defined(SUPPORT_ETHER) 207 /* ARP再構築? */ 208 #endif /* #if defined(_IP4_CFG) && defined(SUPPORT_ETHER) */ 209 210 #ifdef SUPPORT_IGMP 211 /* IGMP参加 */ 212 #endif /* #ifdef SUPPORT_IGMP */ 213 } 214 if (ether_ifnet.link_callback) { 215 (ether_ifnet.link_callback)(ðer_ifnet); 216 } 217 } 218 } 224 219 225 220 /** 226 * Called by a driver when its link goes down 227 */ 228 void ether_set_link_down(T_IFNET *ether) 229 { 230 if (ether->flags & IF_FLAG_LINK_UP) { 231 ether->flags &= ~IF_FLAG_LINK_UP; 232 if (ether->link_callback) { 233 (ether->link_callback)(ether); 234 } 235 } 236 } 237 238 /** 239 * Set callback to be called when link is brought up/down 240 */ 241 void ether_set_link_callback(ether_status_callback_fn link_callback) 221 * ether_set_link_up -- リンクが切断したときにNICから呼び出される 222 */ 223 void 224 ether_set_link_down() 225 { 226 if (ether_ifnet.flags & IF_FLAG_LINK_UP) { 227 ether_ifnet.flags &= ~IF_FLAG_LINK_UP; 228 if (ether_ifnet.link_callback) { 229 (ether_ifnet.link_callback)(ðer_ifnet); 230 } 231 } 232 } 233 234 /* 235 * ether_set_up -- DHCPでアドレスが設定されたとき呼び出される 236 */ 237 238 void 239 ether_set_up() 240 { 241 if (!(ether_ifnet.flags & IF_FLAG_UP)) { 242 ether_ifnet.flags |= IF_FLAG_UP; 243 if (ether_ifnet.link_callback) { 244 (ether_ifnet.link_callback)(ðer_ifnet); 245 } 246 } 247 } 248 249 /* 250 * ether_set_down -- DHCPでアドレスが解放されたとき呼び出される 251 */ 252 253 void 254 ether_set_down() 255 { 256 if (ether_ifnet.flags & IF_FLAG_UP) { 257 ether_ifnet.flags &= ~IF_FLAG_UP; 258 if (ether_ifnet.link_callback) { 259 (ether_ifnet.link_callback)(ðer_ifnet); 260 } 261 } 262 } 263 264 /* 265 * ether_set_link_callback -- リンク状態変化時のコールバック登録 266 */ 267 268 void 269 ether_set_link_callback(ether_status_callback_fn link_callback) 242 270 { 243 271 ether_ifnet.link_callback = link_callback; 244 } 272 if (ether_ifnet.link_callback) { 273 (ether_ifnet.link_callback)(ðer_ifnet); 274 } 275 } 245 276 246 277 /* -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.h
r331 r429 99 99 100 100 #if defined(__RX) 101 102 101 #pragma pack 102 #elif defined(_MSC_VER) 103 #pragma pack(push, 1) 104 #endif 105 106 #if defined(__RX) || defined(_MSC_VER) 107 103 108 typedef struct t_ether_header { 104 109 … … 113 118 uint16_t type; 114 119 } T_ETHER_HDR; 115 #pragma packoption116 120 117 121 #elif defined(TOPPERS_S810_CLG3_85) /* of #if defined(__RX) */ … … 143 147 uint8_t shost[ETHER_ADDR_LEN]; 144 148 uint16_t type; 145 } __attribute__((packed, aligned(2))) T_ETHER_HDR;149 } __attribute__((packed, aligned(2))) T_ETHER_HDR; 146 150 147 151 #endif /* of #if defined(__RX) */ … … 158 162 typedef struct t_ether_addr { 159 163 uint8_t lladdr[ETHER_ADDR_LEN]; 160 } __attribute__((packed, aligned(2)))T_ETHER_ADDR; 164 } __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 161 171 162 172 /* … … 208 218 /* インタフェースのマルチキャストアドレスへの変換 */ 209 219 220 #define IF_FLAG_UP 0x01U 221 #define IF_FLAG_LINK_UP 0x10U 222 210 223 /* 211 224 * 前方参照 … … 266 279 #endif /* of #ifdef T_IF_ETHER_NIC_SOFTC */ 267 280 268 #define IF_FLAG_UP 0x01U269 #define IF_FLAG_LINK_UP 0x10U270 271 281 /* 272 282 * 変数 … … 304 314 extern uint32_t ether_srand (void); 305 315 306 /** Function prototype for netif status- or link-callback functions. */307 316 typedef void (*ether_status_callback_fn)(T_IFNET *ether); 308 317 extern void ether_set_link_callback(ether_status_callback_fn link_callback); 309 extern void ether_set_link_up(T_IFNET *ether); 310 extern void ether_set_link_down(T_IFNET *ether); 318 extern void ether_set_link_up(); 319 extern void ether_set_link_down(); 320 extern void ether_set_up(); 321 extern void ether_set_down(); 311 322 312 323 #endif /* of #ifdef SUPPORT_ETHER */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_arp.h
r331 r429 91 91 uint8_t proto_len; /* プロトコル長 */ 92 92 uint16_t opcode; /* 命令コード */ 93 } __attribute__((packed, aligned(2))) T_ARP_HDR;93 } __attribute__((packed, aligned(2))) T_ARP_HDR; 94 94 95 95 #define ARP_HDR_SIZE (sizeof(T_ARP_HDR)) … … 119 119 typedef struct arpcom { 120 120 uint8_t mac_addr[ETHER_ADDR_LEN]; 121 } __attribute__((packed, aligned(2))) T_ARPCOM;121 } __attribute__((packed, aligned(2))) T_ARPCOM; 122 122 123 123 /* -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_asp.cfg
r331 r429 41 41 42 42 INCLUDE("net/net.cfg"); 43 44 #ifndef NOUSE_MPF_NET_BUF 43 45 44 46 /* … … 169 171 }); 170 172 #endif /* of #if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0 */ 173 174 #endif -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.c
r331 r429 68 68 #include <netinet/tcp_var.h> 69 69 70 #ifndef NOUSE_MPF_NET_BUF 71 70 72 /* 71 73 * 関数 … … 226 228 #endif /* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */ 227 229 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) */ 229 247 230 248 #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 … … 242 260 #endif /* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */ 243 261 244 # endif /* of #if defined(_IP4_CFG) */262 #if defined(_IP4_CFG) && !defined(_IP6_CFG) 245 263 246 264 #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 … … 257 275 }, 258 276 #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) */ 259 279 260 280 }; … … 307 327 308 328 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) { 310 330 (*buf)->idix = (uint8_t)ix; 311 331 (*buf)->len = (uint16_t)minlen; 312 332 (*buf)->flags = 0; 313 333 #ifdef IF_ETHER_MULTI_NIC 334 (*buf)->conn_pos = 0; 335 #endif 314 336 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF 315 337 NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1); … … 318 340 return error; 319 341 } 320 else if (ix == 0 || net_buf_table[ix].size > maxlen) 342 ix --; 343 if (ix < 0 || net_buf_table[ix].size > maxlen) 321 344 break; 322 ix --;323 345 } 324 346 … … 349 371 350 372 while (1) { 351 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, 352 374 ix == sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY) - 1 ? tmout : TMO_POL)) == E_OK) { 353 375 (*buf)->idix = (uint8_t)ix; 354 376 (*buf)->len = net_buf_table[ix].size; 355 377 (*buf)->flags = 0; 378 #ifdef IF_ETHER_MULTI_NIC 379 (*buf)->conn_pos = 0; 380 #endif 356 381 357 382 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF … … 450 475 /* 固定メモリプールに返す。*/ 451 476 452 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF 453 net_buf_table[buf->idix].busies --; 454 #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); 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); 457 483 } 458 484 } … … 505 531 return (uint_t)net_buf_table[0].size; 506 532 } 533 534 #else 535 #include <stdlib.h> 536 537 /* 538 * tget_net_buf_ex -- ネットワークバッファを獲得する(拡張機能)。 539 */ 540 541 ER 542 tget_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 563 ER 564 tget_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 574 ER 575 rel_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 587 uint_t 588 net_buf_max_siz (void) 589 { 590 return (uint_t)IF_PDU_SIZE; 591 } 592 593 #endif -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.h
r331 r429 55 55 uint8_t idix; /* mpfid のインデックス */ 56 56 uint8_t flags; /* フラグ */ 57 #ifdef IF_ETHER_MULTI_NIC 58 uint8_t conn_pos; 59 #endif 57 60 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN 58 61 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN]; … … 80 83 uint8_t idix; /* mpfid のインデックス */ 81 84 uint8_t flags; /* フラグ */ 85 #ifdef IF_ETHER_MULTI_NIC 86 uint8_t conn_pos; 87 #endif 82 88 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN 83 89 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN]; … … 97 103 uint8_t idix; /* mpfid のインデックス */ 98 104 uint8_t flags; /* フラグ */ 105 #ifdef IF_ETHER_MULTI_NIC 106 uint8_t conn_pos; 107 #endif 99 108 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN 100 109 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN]; … … 114 123 uint8_t idix; /* mpfid のインデックス */ 115 124 uint8_t flags; /* フラグ */ 125 #ifdef IF_ETHER_MULTI_NIC 126 uint8_t conn_pos; 127 #endif 116 128 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN 117 129 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN]; … … 131 143 uint8_t idix; /* mpfid のインデックス */ 132 144 uint8_t flags; /* フラグ */ 145 #ifdef IF_ETHER_MULTI_NIC 146 uint8_t conn_pos; 147 #endif 133 148 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN 134 149 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN]; … … 148 163 uint8_t idix; /* mpfid のインデックス */ 149 164 uint8_t flags; /* フラグ */ 165 #ifdef IF_ETHER_MULTI_NIC 166 uint8_t conn_pos; 167 #endif 150 168 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN 151 169 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN]; … … 167 185 uint8_t idix; /* mpfid のインデックス */ 168 186 uint8_t flags; /* フラグ */ 187 #ifdef IF_ETHER_MULTI_NIC 188 uint8_t conn_pos; 189 #endif 169 190 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN 170 191 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN]; -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.c
r331 r429 222 222 T_NET_COUNT net_count_igmp; 223 223 224 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_I CMP4*/224 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_IGMP */ 225 225 226 226 #endif /* of #if defined(_IP4_CFG) */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_rename.h
r331 r429 71 71 #define tget_net_buf_ex _tinet_tget_net_buf_ex 72 72 #define tget_net_buf _tinet_tget_net_buf 73 #define rel_net_buf _tinet_rel_net_buf74 #define rus_net_buf _tinet_rus_net_buf75 #define net_buf_siz _tinet_net_buf_siz73 #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 76 76 #define net_buf_max_siz _tinet_net_buf_max_siz 77 77 #define nbuf_get_tbl _tinet_nbuf_get_tbl
Note:
See TracChangeset
for help on using the changeset viewer.