netstringtoip.c

来自「lwIP-Softools-11Jul2002-alpha」· C语言 代码 · 共 38 行

C
38
字号
/* * Functions to start the ethernet system. * * (C) 2002 Compendium Technologies, Inc. * (C) 2002 Softools, Inc. * All rights reserved. * * This software is the proprietary information of Compendium Technologies, Inc. * and Softools, Inc. Use is subject to license terms. */#include <string.h>#include <stdlib.h>#include "rabbitlwip.h"/** * Note: this only converts ipv4 right now. It also only currently works for * little endian systems. */int netStringToIP(char * address, struct ip_addr * nsip){    char i;    nsip->addr = 0L;    for (i = 0; i <= 24; i += 8)    {        //nsip->addr += (long)atoi(address) << (long)i;         long byte = atol(address);        nsip->addr += byte << (long)i;         address = strchr(address, '.');        if (address == NULL)        {            break;        }        address++;    }    return (i == 24);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?