Ignore:
Timestamp:
Jul 3, 2020, 7:19:17 PM (4 years ago)
Author:
coas-nagasima
Message:

ASP3, TINET, mbed を更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.c

    r331 r429  
    195195
    196196/**
    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 */
     199void
     200ether_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)(&ether_ifnet);
     216                        }
     217                }
     218        }
    224219
    225220/**
    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 */
     223void
     224ether_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)(&ether_ifnet);
     230                        }
     231                }
     232        }
     233
     234/*
     235 * ether_set_up -- DHCPでアドレスが設定されたとき呼び出される
     236 */
     237
     238void
     239ether_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)(&ether_ifnet);
     245                        }
     246                }
     247        }
     248
     249/*
     250 * ether_set_down -- DHCPでアドレスが解放されたとき呼び出される
     251 */
     252
     253void
     254ether_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)(&ether_ifnet);
     260                        }
     261                }
     262        }
     263
     264/*
     265 * ether_set_link_callback -- リンク状態変化時のコールバック登録
     266 */
     267
     268void
     269ether_set_link_callback(ether_status_callback_fn link_callback)
    242270{
    243271        ether_ifnet.link_callback = link_callback;
    244 }
     272        if (ether_ifnet.link_callback) {
     273                (ether_ifnet.link_callback)(&ether_ifnet);
     274                }
     275        }
    245276
    246277/*
Note: See TracChangeset for help on using the changeset viewer.