~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/u-boot/lib/net_utils.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Generic network code. Moved from net.c
 
3
 *
 
4
 * Copyright 1994 - 2000 Neil Russell.
 
5
 * Copyright 2000 Roland Borde
 
6
 * Copyright 2000 Paolo Scaffardi
 
7
 * Copyright 2000-2002 Wolfgang Denk, wd@denx.de
 
8
 * Copyright 2009 Dirk Behme, dirk.behme@googlemail.com
 
9
 *
 
10
 * SPDX-License-Identifier:     GPL-2.0+
 
11
 */
 
12
 
 
13
#include <common.h>
 
14
 
 
15
IPaddr_t string_to_ip(const char *s)
 
16
{
 
17
        IPaddr_t addr;
 
18
        char *e;
 
19
        int i;
 
20
 
 
21
        if (s == NULL)
 
22
                return(0);
 
23
 
 
24
        for (addr=0, i=0; i<4; ++i) {
 
25
                ulong val = s ? simple_strtoul(s, &e, 10) : 0;
 
26
                addr <<= 8;
 
27
                addr |= (val & 0xFF);
 
28
                if (s) {
 
29
                        s = (*e) ? e+1 : e;
 
30
                }
 
31
        }
 
32
 
 
33
        return (htonl(addr));
 
34
}