UbixOS V2  2.0
ip.c
Go to the documentation of this file.
1 
24 /*
25  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
26  * All rights reserved.
27  *
28  * Redistribution and use in source and binary forms, with or without modification,
29  * are permitted provided that the following conditions are met:
30  *
31  * 1. Redistributions of source code must retain the above copyright notice,
32  * this list of conditions and the following disclaimer.
33  * 2. Redistributions in binary form must reproduce the above copyright notice,
34  * this list of conditions and the following disclaimer in the documentation
35  * and/or other materials provided with the distribution.
36  * 3. The name of the author may not be used to endorse or promote products
37  * derived from this software without specific prior written permission.
38  *
39  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
40  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
41  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
42  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
43  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
44  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
46  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
47  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
48  * OF SUCH DAMAGE.
49  *
50  * This file is part of the lwIP TCP/IP stack.
51  *
52  * Author: Adam Dunkels <adam@sics.se>
53  *
54  */
55 
56 #include "net/opt.h"
57 
58 #if LWIP_IPV4 || LWIP_IPV6
59 
60 #include "net/ip_addr.h"
61 #include "net/ip.h"
62 
64 struct ip_globals ip_data;
65 
66 #if LWIP_IPV4 && LWIP_IPV6
67 
68 const ip_addr_t ip_addr_any_type = IPADDR_ANY_TYPE_INIT;
69 
79 int
80 ipaddr_aton(const char *cp, ip_addr_t *addr)
81 {
82  if (cp != NULL) {
83  const char* c;
84  for (c = cp; *c != 0; c++) {
85  if (*c == ':') {
86  /* contains a colon: IPv6 address */
87  if (addr) {
89  }
90  return ip6addr_aton(cp, ip_2_ip6(addr));
91  } else if (*c == '.') {
92  /* contains a dot: IPv4 address */
93  break;
94  }
95  }
96  /* call ip4addr_aton as fallback or if IPv4 was found */
97  if (addr) {
99  }
100  return ip4addr_aton(cp, ip_2_ip4(addr));
101  }
102  return 0;
103 }
104 
110 err_t
111 ip_input(struct pbuf *p, struct netif *inp)
112 {
113  if (p != NULL) {
114  if (IP_HDR_GET_VERSION(p->payload) == 6) {
115  return ip6_input(p, inp);
116  }
117  return ip4_input(p, inp);
118  }
119  return ERR_VAL;
120 }
121 
122 #endif /* LWIP_IPV4 && LWIP_IPV6 */
123 
124 #endif /* LWIP_IPV4 || LWIP_IPV6 */
opt.h
ip_data
struct ip_globals ip_data
ip_addr_t
ip6_addr_t ip_addr_t
Definition: ip_addr.h:290
ipaddr_aton
#define ipaddr_aton(cp, addr)
Definition: ip_addr.h:327
netif
Definition: netif.h:233
ip_2_ip6
#define ip_2_ip6(ipaddr)
Definition: ip_addr.h:301
err_t
s8_t err_t
Definition: err.h:57
ip.h
IPADDR_TYPE_V6
Definition: ip_addr.h:58
IP_SET_TYPE_VAL
#define IP_SET_TYPE_VAL(ipaddr, iptype)
Definition: ip_addr.h:298
ERR_VAL
Definition: err.h:75
pbuf
Definition: pbuf.h:142
ip_addr.h
IP_HDR_GET_VERSION
#define IP_HDR_GET_VERSION(ptr)
Definition: ip.h:49
ip_globals
Definition: ip.h:105
IPADDR_TYPE_V4
Definition: ip_addr.h:56
pbuf::payload
void * payload
Definition: pbuf.h:147
NULL
#define NULL
Definition: fat_string.h:17