示例#1
0
static void sys_net2_up()
{
    struct netif *netif = tls_get_netif();
    struct ip_addr ip_addr, net_mask;

    /* netif1的ip1.ip2.ip3.ip4  -->  netif2则为 ip1.ip2.ip3+1.1 */
    ip_addr.addr = ((netif->ip_addr.addr + 0x00010000) & 0x00ffffff) | 0x01000000;

    /* 子网掩码为255.255.255.0 */
    net_mask.addr = (0 << 24) | (255 << 16) | (255 << 8) | (255 << 0);

    tls_netif2_set_addr(&ip_addr, &net_mask, &ip_addr);
    tls_netif2_set_up();

    /* 先停止再启动,避免之前已启动再启动的时候udp绑定失败使用任意端口 */
    tls_dhcps_stop();
    tls_dhcps_start();

    tls_dhcps_setdns(0);
    tls_dhcps_setdns(1);

    tls_sys_clk_set(CPU_CLK_160M);

    return;
}
示例#2
0
/**
 * \brief This function should be called when a packet is ready to be
 * read from the interface. It uses the function low_level_input()
 * that should handle the actual reception of bytes from the network
 * interface. Then the type of the received packet is determined and
 * the appropriate input function is called.
 *
 * \param args the lwip network interface structure for this
 * ethernetif.
 */
int ethernetif_input(u8 *buf, u32 buf_len)
{
    struct netif    *netif = tls_get_netif();
    struct pbuf       *p;

    /* move received packet into a new pbuf */
    p = low_level_input(netif, buf, buf_len);
    if (p) {
        if (ERR_OK != netif->input(p, netif)) {
            //LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
            pbuf_free(p);
            p = NULL;
        }
        return 0;
    } else {
        return -1;
    }
}
示例#3
0
int tls_cmd_get_link2_status(struct tls_cmd_link_status_t *lks)
{
    struct tls_ethif *ni;
    struct netif *netif;

    ni=tls_netif_get_ethif();
    netif = tls_get_netif();
    netif = netif->next;

    if (netif_is_up(netif))
        lks->status = 1;
    else
        lks->status = 0;

    MEMCPY(lks->ip, (char *)&netif->ip_addr.addr, 4);
    MEMCPY(lks->netmask, (char *)&netif->netmask.addr, 4);
    MEMCPY(lks->gw, (char *)&netif->gw.addr, 4);

    MEMCPY(lks->dns1, (char *)&ni->dns1.addr, 4);
    MEMCPY(lks->dns2, (char *)&ni->dns2.addr, 4);

    return 0;
}