OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [ethernet/] [FreeRTOS-uIP/] [uiplib.c] - Blame information for rev 606

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 606 jeremybenn
/*
2
 * Copyright (c) 2004, Adam Dunkels and the Swedish Institute of
3
 * Computer Science.
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
8
 * are met:
9
 * 1. Redistributions of source code must retain the above copyright
10
 *    notice, this list of conditions and the following disclaimer.
11
 * 2. Redistributions in binary form must reproduce the above copyright
12
 *    notice, this list of conditions and the following disclaimer in the
13
 *    documentation and/or other materials provided with the distribution.
14
 * 3. The name of the author may not be used to endorse or promote
15
 *    products derived from this software without specific prior
16
 *    written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 *
30
 * This file is part of the uIP TCP/IP stack
31
 *
32
 * $Id: uiplib.c 2 2011-07-17 20:13:17Z filepang@gmail.com $
33
 *
34
 */
35
#include "uip.h"
36
#include "uiplib.h"
37
 
38
/*-----------------------------------------------------------------------------------*/
39
unsigned char uiplib_ipaddrconv( char *addrstr, unsigned char *ipaddr )
40
{
41
        unsigned char   tmp;
42
        char                    c;
43
        unsigned char   i, j;
44
 
45
        tmp = 0;
46
 
47
        for( i = 0; i < 4; ++i )
48
        {
49
                j = 0;
50
                do
51
                {
52
                        c = *addrstr;
53
                        ++j;
54
                        if( j > 4 )
55
                        {
56
                                return 0;
57
                        }
58
 
59
                        if( c == '.' || c == 0 )
60
                        {
61
                                *ipaddr = tmp;
62
                                ++ipaddr;
63
                                tmp = 0;
64
                        }
65
                        else if( c >= '0' && c <= '9' )
66
                        {
67
                                tmp = ( tmp * 10 ) + ( c - '0' );
68
                        }
69
                        else
70
                        {
71
                                return 0;
72
                        }
73
 
74
                        ++addrstr;
75
                } while( c != '.' && c != 0 );
76
        }
77
 
78
        return 1;
79
}
80
 
81
/*-----------------------------------------------------------------------------------*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.