#include "lwip/arch.h"
#include "lwip/opt.h"
#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"
Include dependency graph for ipv6/lwip/inet.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Functions | |
u16_t | inet_chksum (void *data, u16_t len) |
u16_t | inet_chksum_pbuf (struct pbuf *p) |
u16_t | inet_chksum_pseudo (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t proto, u32_t proto_len) |
u32_t | inet_addr (const char *cp) |
int | inet_aton (const char *cp, struct in_addr *addr) |
u16_t | htons (u16_t n) |
u16_t | ntohs (u16_t n) |
u32_t | htonl (u32_t n) |
u32_t | ntohl (u32_t n) |
|
|
|
|
|
Definition at line 221 of file inet.c. References INADDR_NONE, inet_aton(), in_addr::s_addr, and u32_t. Referenced by dns_client(), and fake_hostent().
00222 { 00223 struct in_addr val; 00224 00225 if (inet_aton(cp, &val)) { 00226 return (val.s_addr); 00227 } 00228 return (INADDR_NONE); 00229 } |
Here is the call graph for this function:
|
Definition at line 240 of file inet.c. References htonl, in_addr::s_addr, and u32_t. Referenced by dns_client(), inet_addr(), and sock_udpclient().
00241 { 00242 u32_t val; 00243 int base, n; 00244 char c; 00245 // u_int parts[4]; 00246 // u_int *pp = parts; 00247 u32_t parts[4]; 00248 u32_t* pp = parts; 00249 00250 c = *cp; 00251 for (;;) { 00252 /* 00253 * Collect number up to ``.''. 00254 * Values are specified as for C: 00255 * 0x=hex, 0=octal, isdigit=decimal. 00256 */ 00257 if (!isdigit(c)) 00258 return (0); 00259 val = 0; base = 10; 00260 if (c == '0') { 00261 c = *++cp; 00262 if (c == 'x' || c == 'X') 00263 base = 16, c = *++cp; 00264 else 00265 base = 8; 00266 } 00267 for (;;) { 00268 if (isascii(c) && isdigit(c)) { 00269 val = (val * base) + (c - '0'); 00270 c = *++cp; 00271 } else if (base == 16 && isascii(c) && isxdigit(c)) { 00272 val = (val << 4) | 00273 (c + 10 - (islower(c) ? 'a' : 'A')); 00274 c = *++cp; 00275 } else 00276 break; 00277 } 00278 if (c == '.') { 00279 /* 00280 * Internet format: 00281 * a.b.c.d 00282 * a.b.c (with c treated as 16 bits) 00283 * a.b (with b treated as 24 bits) 00284 */ 00285 if (pp >= parts + 3) 00286 return (0); 00287 *pp++ = val; 00288 c = *++cp; 00289 } else 00290 break; 00291 } 00292 /* 00293 * Check for trailing characters. 00294 */ 00295 if (c != '\0' && (!isascii(c) || !isspace(c))) 00296 return (0); 00297 /* 00298 * Concoct the address according to 00299 * the number of parts specified. 00300 */ 00301 n = pp - parts + 1; 00302 switch (n) { 00303 00304 case 0: 00305 return (0); /* initial nondigit */ 00306 00307 case 1: /* a -- 32 bits */ 00308 break; 00309 00310 case 2: /* a.b -- 8.24 bits */ 00311 if (val > 0xffffff) 00312 return (0); 00313 val |= parts[0] << 24; 00314 break; 00315 00316 case 3: /* a.b.c -- 8.8.16 bits */ 00317 if (val > 0xffff) 00318 return (0); 00319 val |= (parts[0] << 24) | (parts[1] << 16); 00320 break; 00321 00322 case 4: /* a.b.c.d -- 8.8.8.8 bits */ 00323 if (val > 0xff) 00324 return (0); 00325 val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); 00326 break; 00327 } 00328 if (addr) 00329 addr->s_addr = htonl(val); 00330 return (1); 00331 } |
|
Definition at line 141 of file inet.c. References chksum(), len, lwip_chksum(), u16_t, and u32_t. Referenced by icmp_dest_unreach(), icmp_time_exceeded(), ip_frag(), ip_input(), ip_output_if(), and ip_reass().
00142 { 00143 u32_t acc; 00144 00145 acc = lwip_chksum(dataptr, len); 00146 while(acc >> 16) { 00147 acc = (acc & 0xffff) + (acc >> 16); 00148 } 00149 return ~(acc & 0xffff); 00150 } |
Here is the call graph for this function:
|
Definition at line 153 of file inet.c. References chksum(), lwip_chksum(), NULL, u32_t, and u8_t. Referenced by icmp_input().
00154 { 00155 u32_t acc; 00156 struct pbuf *q; 00157 u8_t swapped; 00158 00159 acc = 0; 00160 swapped = 0; 00161 for(q = p; q != NULL; q = q->next) { 00162 acc += lwip_chksum(q->payload, q->len); 00163 while(acc >> 16) { 00164 acc = (acc & 0xffffUL) + (acc >> 16); 00165 } 00166 if(q->len % 2 != 0) { 00167 swapped = 1 - swapped; 00168 acc = (acc & 0x00ffUL << 8) | (acc & 0xff00UL >> 8); 00169 } 00170 } 00171 00172 if(swapped) { 00173 acc = ((acc & 0x00ffUL) << 8) | ((acc & 0xff00UL) >> 8); 00174 } 00175 return ~(acc & 0xffffUL); 00176 } |
Here is the call graph for this function:
|
Definition at line 90 of file inet6.c. References ip_addr::addr, chksum(), htons, NULL, u16_t, u32_t, and u8_t. Referenced by icmp_input().
00093 { 00094 u32_t acc; 00095 struct pbuf *q; 00096 u8_t swapped, i; 00097 00098 acc = 0; 00099 swapped = 0; 00100 for(q = p; q != NULL; q = q->next) { 00101 acc += chksum(q->payload, q->len); 00102 while(acc >> 16) { 00103 acc = (acc & 0xffff) + (acc >> 16); 00104 } 00105 if(q->len % 2 != 0) { 00106 swapped = 1 - swapped; 00107 acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); 00108 } 00109 } 00110 00111 if(swapped) { 00112 acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); 00113 } 00114 00115 for(i = 0; i < 8; i++) { 00116 acc += ((u16_t *)src->addr)[i] & 0xffff; 00117 acc += ((u16_t *)dest->addr)[i] & 0xffff; 00118 while(acc >> 16) { 00119 acc = (acc & 0xffff) + (acc >> 16); 00120 } 00121 } 00122 acc += (u16_t)htons((u16_t)proto); 00123 acc += ((u16_t *)&proto_len)[0] & 0xffff; 00124 acc += ((u16_t *)&proto_len)[1] & 0xffff; 00125 00126 while(acc >> 16) { 00127 acc = (acc & 0xffff) + (acc >> 16); 00128 } 00129 return ~(acc & 0xffff); 00130 } |
Here is the call graph for this function:
|
|
|
|