• LWIP network interface 网卡 初始化 以 STM32 为例子 后面会有 用 2G 或者4G 模块 用 PPP拨号的 形式 虚拟出网卡 所以先以 这个为 前提


    LWIP   network interface   网卡 初始化    以  STM32  为例子  后面会有 用  2G 或者4G 模块 用 PPP拨号的 形式  虚拟出网卡  所以先以 这个为  前提 

    LWIP   有 一个 结构体 是 描述 物理 接口 的  即  netif Struct, 大神朱工 对这个 有个 详细的 解释 :http://blog.csdn.net/zhzht19861011/article/details/6690534

    LWIP  官网  对 这个  结构体 也有 详细 的 描述  :http://www.nongnu.org/lwip/2_0_x/structnetif.html

    我 使用 的 代码 是  ST  官方 提供   的 演示例程 , 可以在 这里下载到  STM32F407 + DP83848

    工程 打开路径  : C:UsersadminDesktopSTM32F4x7_ETH_LwIP_V1.1.0ProjectFreeRTOSudptcp_echo_server_netconnMDK-ARM

    看看 ST  是怎么 定义 一个 网卡 变量   并 初始化的 

    首先看 定义 的 地方  :

     

    然后  看看    对 这个变量  怎么 初始化 的  。。

    /* - netif_add(struct netif *netif, struct ip_addr *ipaddr,
    struct ip_addr *netmask, struct ip_addr *gw,
    void *state, err_t (* init)(struct netif *netif),
    err_t (* input)(struct pbuf *p, struct netif *netif))

    Adds your network interface to the netif_list. Allocate a struct
    netif and pass a pointer to this structure as the first argument.
    Give pointers to cleared ip_addr structures when using DHCP,
    or fill them with sane numbers otherwise. The state pointer may be NULL.

    The init function pointer must point to a initialization function for
    your ethernet netif interface. The following code illustrates it's use.*/
    netif_add(&xnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input);

    使用  了     netif_add(&xnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input); 这个 函数  对 这个 网卡 进行 了 初始化  。

    这个 函数 是   LWIP   提供的  函数  ,我们 看一下 官方 的 解释 :http://www.nongnu.org/lwip/2_0_x/group__netif.html#gade5498543e74067f28cc6bef0209e3be

     

    第一步 : 我 们 需要 先 定义 一个 netif Struct  类型 的变量 

  • 相关阅读:
    2020 11 21
    2020 11 20
    2020 11 19
    2020 11 18
    2020 11 17
    2020 11 16
    2020 11 15
    2020 11 14
    2020 11 14
    第五周学习进度报告
  • 原文地址:https://www.cnblogs.com/suozhang/p/7347520.html
Copyright © 2020-2023  润新知