亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? inet.c

?? freertosV4.40 是一種small的嵌入式系統(tǒng)。利于嵌入式開好者入門學(xué)習(xí)嵌入式操作系統(tǒng)。通過對于源碼的學(xué)習(xí)可以很好的掌握freertos的運行機制。
?? C
字號:
/*
 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 *
 * Author: Adam Dunkels <adam@sics.se>
 *
 */


/* inet.c
 *
 * Functions common to all TCP/IP modules, such as the Internet checksum and the
 * byte order functions.
 *
 */


#include "lwip/opt.h"

#include "lwip/arch.h"

#include "lwip/def.h"
#include "lwip/inet.h"

#include "lwip/sys.h"

/* This is a reference implementation of the checksum algorithm, with the
 * aim of being simple, correct and fully portable. Checksumming is the
 * first thing you would want to optimize for your platform. You will
 * need to port it to your architecture and in your sys_arch.h:
 * 
 * #define LWIP_CHKSUM <your_checksum_routine> 
*/
#ifndef LWIP_CHKSUM
#define LWIP_CHKSUM lwip_standard_chksum

/**
 * lwip checksum
 *
 * @param dataptr points to start of data to be summed at any boundary
 * @param len length of data to be summed
 * @return host order (!) lwip checksum (non-inverted Internet sum) 
 *
 * @note accumulator size limits summable lenght to 64k
 * @note host endianess is irrelevant (p3 RFC1071)
 */
static u16_t
lwip_standard_chksum(void *dataptr, u16_t len)
{
  u32_t acc;
  u16_t src;
  u8_t *octetptr;

  acc = 0;
  /* dataptr may be at odd or even addresses */
  octetptr = (u8_t*)dataptr;
  while (len > 1)
  {
    /* declare first octet as most significant
       thus assume network order, ignoring host order */
    src = (*octetptr) << 8;
    octetptr++;
    /* declare second octet as least significant */
    src |= (*octetptr);
    octetptr++;
    acc += src;
    len -= 2;
  }
  if (len > 0)
  {
    /* accumulate remaining octet */
    src = (*octetptr) << 8;
    acc += src;
  }
  /* add deferred carry bits */
  acc = (acc >> 16) + (acc & 0x0000ffffUL);
  if ((acc & 0xffff0000) != 0) {
    acc = (acc >> 16) + (acc & 0x0000ffffUL);
  }
  /* This maybe a little confusing: reorder sum using htons()
     instead of ntohs() since it has a little less call overhead.
     The caller must invert bits for Internet sum ! */
  return htons((u16_t)acc);
}

#endif

#if 0
/*
 * Curt McDowell
 * Broadcom Corp.
 * csm@broadcom.com
 *
 * IP checksum two bytes at a time with support for
 * unaligned buffer.
 * Works for len up to and including 0x20000.
 * by Curt McDowell, Broadcom Corp. 12/08/2005
 */

static u16_t
lwip_standard_chksum2(void *dataptr, int len)
{
  u8_t *pb = dataptr;
  u16_t *ps, t = 0;
  u32_t sum = 0;
  int odd = ((u32_t)pb & 1);

  /* Get aligned to u16_t */
  if (odd && len > 0) {
    ((u8_t *)&t)[1] = *pb++;
    len--;
  }

  /* Add the bulk of the data */
  ps = (u16_t *)pb;
  while (len > 1) {
    sum += *ps++;
    len -= 2;
  }

  /* Consume left-over byte, if any */
  if (len > 0)
    ((u8_t *)&t)[0] = *(u8_t *)ps;;

  /* Add end bytes */
  sum += t;

  /*  Fold 32-bit sum to 16 bits */
  while (sum >> 16)
    sum = (sum & 0xffff) + (sum >> 16);

  /* Swap if alignment was odd */
  if (odd)
    sum = ((sum & 0xff) << 8) | ((sum & 0xff00) >> 8);

  return sum;
}

/**
 * An optimized checksum routine. Basically, it uses loop-unrolling on
 * the checksum loop, treating the head and tail bytes specially, whereas
 * the inner loop acts on 8 bytes at a time. 
 *
 * @arg start of buffer to be checksummed. May be an odd byte address.
 * @len number of bytes in the buffer to be checksummed.
 * 
 * @todo First argument type conflicts with generic checksum routine.
 * 
 * by Curt McDowell, Broadcom Corp. December 8th, 2005
 */

static u16_t
lwip_standard_chksum4(u8_t *pb, int len)
{
  u16_t *ps, t = 0;
  u32_t *pl;
  u32_t sum = 0, tmp;
  /* starts at odd byte address? */
  int odd = ((u32_t)pb & 1);

  if (odd && len > 0) {
    ((u8_t *)&t)[1] = *pb++;
    len--;
  }

  ps = (u16_t *)pb;

  if (((u32_t)ps & 3) && len > 1) {
    sum += *ps++;
    len -= 2;
  }

  pl = (u32_t *)ps;

  while (len > 7)  {
    tmp = sum + *pl++;          /* ping */
    if (tmp < sum)
      tmp++;                    /* add back carry */

    sum = tmp + *pl++;          /* pong */
    if (sum < tmp)
      sum++;                    /* add back carry */

    len -= 8;
  }

  /* make room in upper bits */
  sum = (sum >> 16) + (sum & 0xffff);

  ps = (u16_t *)pl;

  /* 16-bit aligned word remaining? */
  while (len > 1) {
    sum += *ps++;
    len -= 2;
  }

  /* dangling tail byte remaining? */
  if (len > 0)                  /* include odd byte */
    ((u8_t *)&t)[0] = *(u8_t *)ps;

  sum += t;                     /* add end bytes */

  while (sum >> 16)             /* combine halves */
    sum = (sum >> 16) + (sum & 0xffff);

  if (odd)
    sum = ((sum & 0xff) << 8) | ((sum & 0xff00) >> 8);

  return sum;
}
#endif

/* inet_chksum_pseudo:
 *
 * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain.
 */

u16_t
inet_chksum_pseudo(struct pbuf *p,
       struct ip_addr *src, struct ip_addr *dest,
       u8_t proto, u16_t proto_len)
{
  u32_t acc;
  struct pbuf *q;
  u8_t swapped;

  acc = 0;
  swapped = 0;
  /* iterate through all pbuf in chain */
  for(q = p; q != NULL; q = q->next) {
    LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n",
      (void *)q, (void *)q->next));
    acc += LWIP_CHKSUM(q->payload, q->len);
    /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/
    while (acc >> 16) {
      acc = (acc & 0xffffUL) + (acc >> 16);
    }
    if (q->len % 2 != 0) {
      swapped = 1 - swapped;
      acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8);
    }
    /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/
  }

  if (swapped) {
    acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8);
  }
  acc += (src->addr & 0xffffUL);
  acc += ((src->addr >> 16) & 0xffffUL);
  acc += (dest->addr & 0xffffUL);
  acc += ((dest->addr >> 16) & 0xffffUL);
  acc += (u32_t)htons((u16_t)proto);
  acc += (u32_t)htons(proto_len);

  while (acc >> 16) {
    acc = (acc & 0xffffUL) + (acc >> 16);
  }
  LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc));
  return (u16_t)~(acc & 0xffffUL);
}

/* inet_chksum:
 *
 * Calculates the Internet checksum over a portion of memory. Used primarely for IP
 * and ICMP.
 */

u16_t
inet_chksum(void *dataptr, u16_t len)
{
  u32_t acc;

  acc = LWIP_CHKSUM(dataptr, len);
  while (acc >> 16) {
    acc = (acc & 0xffff) + (acc >> 16);
  }
  return (u16_t)~(acc & 0xffff);
}

u16_t
inet_chksum_pbuf(struct pbuf *p)
{
  u32_t acc;
  struct pbuf *q;
  u8_t swapped;

  acc = 0;
  swapped = 0;
  for(q = p; q != NULL; q = q->next) {
    acc += LWIP_CHKSUM(q->payload, q->len);
    while (acc >> 16) {
      acc = (acc & 0xffffUL) + (acc >> 16);
    }
    if (q->len % 2 != 0) {
      swapped = 1 - swapped;
      acc = (acc & 0x00ffUL << 8) | (acc & 0xff00UL >> 8);
    }
  }

  if (swapped) {
    acc = ((acc & 0x00ffUL) << 8) | ((acc & 0xff00UL) >> 8);
  }
  return (u16_t)~(acc & 0xffffUL);
}

/* Here for now until needed in other places in lwIP */
#ifndef isascii
#define in_range(c, lo, up)  ((u8_t)c >= lo && (u8_t)c <= up)
#define isascii(c)           in_range(c, 0x20, 0x7f)
#define isdigit(c)           in_range(c, '0', '9')
#define isxdigit(c)          (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))
#define islower(c)           in_range(c, 'a', 'z')
#define isspace(c)           (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
#endif		
		

 /*
  * Ascii internet address interpretation routine.
  * The value returned is in network order.
  */

 /*  */
 /* inet_addr */
 u32_t inet_addr(const char *cp)
 {
     struct in_addr val;

     if (inet_aton(cp, &val)) {
         return (val.s_addr);
     }
     return (INADDR_NONE);
 }

 /*
  * Check whether "cp" is a valid ascii representation
  * of an Internet address and convert to a binary address.
  * Returns 1 if the address is valid, 0 if not.
  * This replaces inet_addr, the return value from which
  * cannot distinguish between failure and a local broadcast address.
  */
 /*  */
 /* inet_aton */
 s8_t
 inet_aton(const char *cp, struct in_addr *addr)
 {
     u32_t val;
     s32_t base, n;
     char c;
     u32_t parts[4];
     u32_t* pp = parts;

     c = *cp;
     for (;;) {
         /*
          * Collect number up to ``.''.
          * Values are specified as for C:
          * 0x=hex, 0=octal, isdigit=decimal.
          */
         if (!isdigit(c))
             return (0);
         val = 0; base = 10;
         if (c == '0') {
             c = *++cp;
             if (c == 'x' || c == 'X')
                 base = 16, c = *++cp;
             else
                 base = 8;
         }
         for (;;) {
             if (isdigit(c)) {
                 val = (val * base) + (s16_t)(c - '0');
                 c = *++cp;
             } else if (base == 16 && isxdigit(c)) {
                 val = (val << 4) |
                     (s16_t)(c + 10 - (islower(c) ? 'a' : 'A'));
                 c = *++cp;
             } else
             break;
         }
         if (c == '.') {
             /*
              * Internet format:
              *  a.b.c.d
              *  a.b.c   (with c treated as 16 bits)
              *  a.b (with b treated as 24 bits)
              */
             if (pp >= parts + 3)
                 return (0);
             *pp++ = val;
             c = *++cp;
         } else
             break;
     }
     /*
      * Check for trailing characters.
      */
     if (c != '\0' && (!isascii(c) || !isspace(c)))
         return (0);
     /*
      * Concoct the address according to
      * the number of parts specified.
      */
     n = pp - parts + 1;
     switch (n) {

     case 0:
         return (0);     /* initial nondigit */

     case 1:             /* a -- 32 bits */
         break;

     case 2:             /* a.b -- 8.24 bits */
         if (val > 0xffffff)
             return (0);
         val |= parts[0] << 24;
         break;

     case 3:             /* a.b.c -- 8.8.16 bits */
         if (val > 0xffff)
             return (0);
         val |= (parts[0] << 24) | (parts[1] << 16);
         break;

     case 4:             /* a.b.c.d -- 8.8.8.8 bits */
         if (val > 0xff)
             return (0);
         val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
         break;
     }
     if (addr)
         addr->s_addr = htonl(val);
     return (1);
 }

/* Convert numeric IP address into decimal dotted ASCII representation.
 * returns ptr to static buffer; not reentrant!
 */
char *inet_ntoa(struct in_addr addr)
{
  static char str[16];
  u32_t s_addr = addr.s_addr;
  char inv[3];
  char *rp;
  u8_t *ap;
  u8_t rem;
  u8_t n;
  u8_t i;

  rp = str;
  ap = (u8_t *)&s_addr;
  for(n = 0; n < 4; n++) {
    i = 0;
    do {
      rem = *ap % (u8_t)10;
      *ap /= (u8_t)10;
      inv[i++] = '0' + rem;
    } while(*ap);
    while(i--)
      *rp++ = inv[i];
    *rp++ = '.';
    ap++;
  }
  *--rp = 0;
  return str;
}


#ifndef BYTE_ORDER
#error BYTE_ORDER is not defined
#endif
#if BYTE_ORDER == LITTLE_ENDIAN

u16_t
htons(u16_t n)
{
  return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
}

u16_t
ntohs(u16_t n)
{
  return htons(n);
}

u32_t
htonl(u32_t n)
{
  return ((n & 0xff) << 24) |
    ((n & 0xff00) << 8) |
    ((n & 0xff0000) >> 8) |
    ((n & 0xff000000) >> 24);
}

u32_t
ntohl(u32_t n)
{
  return htonl(n);
}

#endif /* BYTE_ORDER == LITTLE_ENDIAN */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区三区不卡| 亚洲欧美日韩国产综合| 欧美在线免费观看亚洲| 精品无人码麻豆乱码1区2区| 亚洲福利一区二区| 1区2区3区精品视频| 欧美不卡激情三级在线观看| 欧美综合色免费| 色综合色综合色综合色综合色综合 | 久久精品夜色噜噜亚洲a∨| 中文字幕亚洲综合久久菠萝蜜| 欧美一级二级三级乱码| 在线综合视频播放| 91麻豆精品国产91久久久资源速度 | 国产麻豆精品在线观看| 蜜臀a∨国产成人精品| 日韩成人一级片| 日韩成人免费在线| 免费人成网站在线观看欧美高清| 亚洲福利电影网| 亚洲国产欧美在线| 亚洲高清视频在线| 日韩精品电影在线观看| 奇米亚洲午夜久久精品| 国内精品写真在线观看| 国产高清一区日本| 成人亚洲精品久久久久软件| 国产成人高清在线| 91在线观看地址| 欧美日韩dvd在线观看| 67194成人在线观看| 精品国产乱码久久久久久1区2区| 亚洲精品一线二线三线| 国产精品久久久久影院老司| 洋洋成人永久网站入口| 另类调教123区| 成人精品小蝌蚪| 欧美一区二区三区啪啪| 欧美激情综合五月色丁香小说| 一区二区三区中文在线| 久久国内精品视频| 在线免费观看日韩欧美| 欧美大白屁股肥臀xxxxxx| 国产精品福利影院| 精品一区二区三区在线播放| 日本精品免费观看高清观看| 欧美一区二区成人| 亚洲精品中文在线| 国产91在线看| 日韩三级电影网址| 亚洲综合一区在线| 成人黄色片在线观看| 91精品国产欧美日韩| 国产精品五月天| 极品少妇一区二区三区精品视频| 在线亚洲人成电影网站色www| 久久久精品国产免大香伊| 青青草一区二区三区| 欧美亚洲国产一卡| 亚洲人成人一区二区在线观看 | 国产一区二三区| 在线电影欧美成精品| 亚洲成人1区2区| 91同城在线观看| 国产精品蜜臀av| 99久久国产综合精品色伊| 国产精品入口麻豆原神| 国产成人免费9x9x人网站视频| 久久久久国色av免费看影院| 国产一区二区在线观看视频| 久久网站热最新地址| 国产真实乱子伦精品视频| 欧美va在线播放| 国产精品一线二线三线| 国产欧美日韩在线看| 成人av在线播放网址| 亚洲精品中文在线影院| 欧美群妇大交群的观看方式| 午夜精品久久久久久不卡8050| 欧美日韩中文字幕精品| 久久成人羞羞网站| 久久久一区二区三区| 不卡的电影网站| 亚洲一区免费在线观看| 精品福利av导航| 91官网在线免费观看| 美女性感视频久久| 亚洲激情自拍视频| 欧美大白屁股肥臀xxxxxx| 成人一区二区三区中文字幕| 一区二区三区av电影| 亚洲精品一区二区在线观看| 91成人网在线| 国产麻豆成人精品| 亚洲1区2区3区4区| 国产精品久久久久久久久快鸭 | 中文字幕亚洲综合久久菠萝蜜| 9191国产精品| 一本一道久久a久久精品| 另类小说图片综合网| 成人免费视频一区二区| 日本aⅴ精品一区二区三区| 亚洲欧美一区二区在线观看| 欧美电影免费观看高清完整版在| 91麻豆蜜桃一区二区三区| 国产精品影视在线| 麻豆91免费看| 日韩有码一区二区三区| 亚洲欧美视频在线观看视频| 久久久精品一品道一区| 日韩免费成人网| 欧美绝品在线观看成人午夜影视 | 99精品久久99久久久久| 国产黄人亚洲片| 韩国成人福利片在线播放| 美女一区二区久久| 经典三级在线一区| 极品少妇xxxx精品少妇| 韩国成人在线视频| 国产成人免费网站| av不卡免费在线观看| 99综合影院在线| 97精品久久久久中文字幕| 99久久99久久精品免费看蜜桃| 不卡影院免费观看| 在线亚洲欧美专区二区| 91精品国产综合久久蜜臀| 91精品国产欧美一区二区| 精品成a人在线观看| 国产欧美日韩亚州综合| 中文字幕一区二区在线播放| 亚洲人成亚洲人成在线观看图片| 亚洲人成伊人成综合网小说| 亚洲va天堂va国产va久| 美女高潮久久久| 成人激情黄色小说| 欧美日韩免费高清一区色橹橹 | 一区二区三区四区视频精品免费| 亚洲成人免费观看| 成人黄色综合网站| 欧美久久久久免费| 国产亚洲午夜高清国产拍精品| 亚洲男女一区二区三区| 国产乱国产乱300精品| 日本韩国欧美国产| 久久久久国产精品厨房| 亚洲v日本v欧美v久久精品| 久久av中文字幕片| 日本高清不卡一区| 国产欧美一区二区精品仙草咪| 午夜av区久久| 色老汉一区二区三区| 久久久久国产精品麻豆ai换脸| 一区二区三区在线观看视频| 精品亚洲porn| 精品国内二区三区| 午夜精品国产更新| 91福利社在线观看| 中文字幕一区二区三区在线不卡 | 亚洲一区二区欧美日韩| 懂色av噜噜一区二区三区av| 欧美一二三在线| 天堂午夜影视日韩欧美一区二区| www.日韩在线| 国产人成亚洲第一网站在线播放 | 成人晚上爱看视频| 久久影院电视剧免费观看| 日本不卡在线视频| 欧美日韩亚洲综合| 日产国产欧美视频一区精品| 欧美三区免费完整视频在线观看| 日韩一区中文字幕| 91啪九色porn原创视频在线观看| 国产欧美视频在线观看| 国产·精品毛片| 亚洲色图欧美在线| 欧美亚一区二区| 五月天国产精品| 精品欧美乱码久久久久久| 国产在线精品一区二区不卡了| 久久久噜噜噜久噜久久综合| 成人免费视频国产在线观看| 综合久久久久久| 91 com成人网| 国产.欧美.日韩| 亚洲一级电影视频| 欧美大片在线观看一区| av在线综合网| 视频精品一区二区| 国产免费成人在线视频| 色八戒一区二区三区| 久久精品99国产精品| 国产精品传媒在线| 日韩三级中文字幕| 在线中文字幕一区二区| 国产福利91精品| 日韩精品五月天| 亚洲激情自拍视频| 欧美国产日韩a欧美在线观看| 欧美性视频一区二区三区|