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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? net.c

?? 針對德州儀器DM270開發板的bootloader,其實現了內核的下載以及文件系統的下載
?? C
字號:
/* * File: net.c * * This is an implementation exposing the net.h interface and providing the * UDP and IP levels of a network stack. It depends on an external module to * supply the underlying ethernet level. * * See Also *   net.h, ether.h * * Copyright (C) 2002 RidgeRun, Inc. * Author: RidgeRun, Inc  <skranz@ridgerun.com> * *  This program is free software; you can redistribute  it and/or modify it *  under  the terms of  the GNU General  Public License as published by the *  Free Software Foundation;  either version 2 of the  License, or (at your *  option) any later version. * *  THIS  SOFTWARE  IS  PROVIDED  ``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. * *  You should have received a copy of the  GNU General Public License along *  with this program; if not, write  to the Free Software Foundation, Inc., *  675 Mass Ave, Cambridge, MA 02139, USA. * * Please report all bugs/problems to the author or <support@dsplinux.net> * * key: RRGPLCR (do not remove) * */#include "types.h"#include "io.h"#include "util.h"#include "net.h"#include "ether.h"/****************************** Routine: Description:   Return 16-bit ones compliment of 16-bit ones compliment sum   Return value is converted to network byte order if necessary. ******************************/static unsigned short ip_chksum(unsigned short *iphdr, int num_bytes){  // Algorithm as per page 72,  "Internetworking With TCP/IP (2nd edition, vol 2)"  // Algorithm as per page 100, "Internetworking With TCP/IP (3rd edition, vol 1)"  //   unsigned long sum;  int nwords = num_bytes >> 1;  for (sum=0; nwords>0; nwords--) {    sum += ntohs(*iphdr);    iphdr++;  }  sum = (sum >> 16) + (sum & 0xffff); /* add in carry */  sum += (sum >> 16);                 /* maybe one more */  sum = ~sum;  sum = htons((unsigned short)sum);  return sum;}/****************************** Routine: Description: ******************************/static void ip_submit(submit_mode mode,         // in                      char *device_IP,          // in                      char *server_IP,          // in                      char *device_MAC,         // in, can be NULL only if our chipset has built in MAC.                      char *server_MAC,         // in, can be NULL only if our net stack has ARP.                      void *datagram,           // in/out                      unsigned short *num_bytes)// in/out{  ip_hdr_t *ipdatagram;  unsigned short ip_len;  unsigned long dev_IP;  unsigned long serv_IP;  switch(mode) {    case SEND:    case RECV:    case SEND_AND_GET_REPLY:      // --Stage One--      // Add the IP header and submit resulting datagram to ether layer.      // Recall that the client has provided the space for us to      // back the pointer up like this and add our header.      ipdatagram = (ip_hdr_t *)(datagram - sizeof(ip_hdr_t));      dev_IP  = util_IPstr_to_num(device_IP);      serv_IP = util_IPstr_to_num(server_IP);      // Fields, page 98, "Internetworking With TCP/IP (3rd edition, vol 1)"      ipdatagram->vers_hlen = 0x45;      ipdatagram->serv_type = 0x00;      ip_len = sizeof(ip_hdr_t) + *num_bytes;      ipdatagram->tot_len = htons(ip_len);      ipdatagram->ident = htons(0x0000);      ipdatagram->flags_fragoffset = htons(0x4000);      ipdatagram->timetolive = 0xFF;      ipdatagram->protocol = 0x11; // UDP code; as per /etc/protocols list.      ipdatagram->hdr_chksum = 0x0000;      ipdatagram->src_IP_addr  = htonl(dev_IP);      ipdatagram->dest_IP_addr = htonl(serv_IP);      ipdatagram->hdr_chksum = ip_chksum((unsigned short *)ipdatagram, sizeof(ip_hdr_t));      // util_printf("ip_submit: submitting frame 0x%X\n",ipdatagram); // *revisit-skranz* temp. //     ether_submit(mode,               // in //                  device_MAC,         // in //                  server_MAC,         // in //                  (void *)ipdatagram, // in/out //                  &ip_len);           // in/out      break;    case FLUSH:      // flush the net channel of any pending data.//      ether_submit(FLUSH,device_MAC,server_MAC,NULL,NULL);      break;    default:      SYSTEM_FATAL("Logic Error");      break;  }  switch(mode) {    case RECV:    case SEND_AND_GET_REPLY:      {        unsigned long d_IP;        if (ip_len < sizeof(ip_hdr_t)) {          // must of had some ehter errors. Upper level to address.          util_printf("num_bytes being set to zero\n"); // *debug* temp.          *num_bytes = 0;          return;        }        // Okay, *ipdatagram now contains the IP datagram which was        // recieved from the remote server. Any previous contents we        // had there have been overwritten. The dest_IP contained        // within now represents the machine the remote server has        // addressed this IP datagram to. Hopefully it matches our        // IP; e.g. our device_IP        d_IP = ntohl(ipdatagram->dest_IP_addr);        if (d_IP == dev_IP) {          // --Stage Two--          // Great, all done, *datagram now holds the newly received datagram,          // (minus the IP header) now we'll compute the length and hand it          // up to the UDP level above.          *num_bytes = ntohs(ipdatagram->tot_len) - sizeof(ip_hdr_t);        }        else {          // What? we just recieved something from a remote host which          // was destinted for some other IP than ours. Was this an ARP          // broadcast? possible some other form of broadcast? At any rate          // discard this datagram and cycle back down the network stack          // to get its contents replaced with the data we are expecting.          // (recursive call).          // util_printf("disregarding IP msg from 0x%x\n",d_IP); // *revisit-skranz* temp.          // util_printf("ip_submit2: submitting frame 0x%X\n",datagram); // *revisit-skranz* temp.          ip_submit(RECV,       // in                    device_IP,  // in                    server_IP,  // in                    device_MAC, // in                    server_MAC, // in                    datagram,   // in, discard and replace.                    num_bytes); // in        }      }      break;    default:      break;  }    }/****************************** Routine: Description:    See net.h for more info. ******************************/void udp_submit(submit_mode mode,           // in                unsigned short src_port,    // in (local device port number).                unsigned short dest_port,   // in (remote server port number).                char *device_IP,            // in                char *server_IP,            // in                char *device_MAC,           // in, can be NULL only if our chipset has built in MAC.                char *server_MAC,           // in, can be NULL only if our net stack has ARP.                void *datagram,             // in/out                unsigned short *num_bytes,  // in/out                unsigned short *reply_port) // out.{  udp_hdr_t *udatagram;  unsigned short u_len;  switch(mode) {    case SEND:    case RECV:    case SEND_AND_GET_REPLY:      // --Stage One--      // Add the UDP header and submit resulting datagram to IP layer.      // Recall that the client has provided the space for us to      // back the pointer up like this and add our header.      udatagram = (udp_hdr_t *)(datagram - sizeof(udp_hdr_t));      udatagram->src_port = htons(src_port);      udatagram->dest_port = htons(dest_port);      u_len = sizeof(udp_hdr_t) + *num_bytes;      udatagram->tot_len = htons(u_len);      udatagram->chksum = 0x0000; // Checksum optional. zero indicates not using it.                                  // page 182, "Internetworking With TCP/IP (3rd edition, vol 1)"      // util_printf("udp_submit: submitting frame 0x%X\n",udatagram); // *revisit-skranz* temp.      ip_submit(mode,              // in                device_IP,         // in                server_IP,         // in                device_MAC,        // in, can be NULL only if our chipset has built in MAC.                server_MAC,        // in, can be NULL only if our net stack has ARP.                (void *)udatagram, // in/out                &u_len);           // in      break;    case FLUSH:      // flush the net channel of any pending data.      ip_submit(FLUSH,      // in                device_IP,  // in                server_IP,  // in                device_MAC, // in, can be NULL only if our chipset has built in MAC.                server_MAC, // in, can be NULL only if our net stack has ARP.                NULL,       // in                NULL);      // in      break;    default:      SYSTEM_FATAL("Logic Error");      break;  }  switch(mode) {    case RECV:    case SEND_AND_GET_REPLY:      {        unsigned short dev_port;        if (u_len < sizeof(udp_hdr_t)) {          // must of had some ehter errors. Upper level to address.          util_printf("num_bytes being set to zero\n"); // *debug* temp.          *num_bytes = 0;          return;        }        // Okay, *udatagram now contains the UDP datagram which was        // recieved from the remote server. Any previous contents we        // had there have been overwritten. The dest_port contained        // within now represents the port the remote server has addressed        // this UDP datagram to. Hopefully it matches the port we        // sent from; e.g., our src_port.        dev_port = ntohs(udatagram->dest_port);        *reply_port = ntohs(udatagram->src_port);        if (dev_port == src_port) {          // --Stage Two--          // Great, all done, *datagram now holds the newly received datagram,          // (minus the UDP header) now we'll compute the length and hand it          // up to the application level above.          *num_bytes = ntohs(udatagram->tot_len) - sizeof(udp_hdr_t);        }        else {          // What? we just recieved something from a remote host which          // was destinted for some other port than the one we are          // interested in. Therefore, discard this datagram and cycle          // back down the network stack to get its contents replaced with          // the data we are expecting. (recursive call).          // util_printf("udp: disregarding port msg from 0x%x\n",dev_port); // *revisit-skranz* temp.          // util_printf("udp_submit2: submitting frame 0x%X\n",datagram); // *revisit-skranz* temp.          udp_submit(RECV,        // in                     src_port,    // in                     dest_port,   // in                     device_IP,   // in                     server_IP,   // in                     device_MAC,  // in                     server_MAC,  // in                     datagram,    // in, discard and replace.                     num_bytes,   // in,                     reply_port); // out        }      }      break;    default:      break;  }    }/****************************** Routine: Description:    See net.h for more info. ******************************/void net_init(void){}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
狠狠色综合日日| 国产精品亚洲一区二区三区妖精| 亚洲国产精品久久艾草纯爱| 亚洲va在线va天堂| 韩国在线一区二区| 日本电影亚洲天堂一区| 日韩欧美卡一卡二| 国产精品乱码一区二三区小蝌蚪| 一区二区在线观看不卡| 亚洲精品菠萝久久久久久久| 美日韩一级片在线观看| 91免费国产在线观看| 日韩亚洲欧美成人一区| 中文字幕乱码日本亚洲一区二区| 亚洲成人先锋电影| 北条麻妃一区二区三区| 日韩三级.com| 亚洲一区二区三区视频在线 | 国产精品天干天干在线综合| 亚洲午夜av在线| av资源网一区| 久久精品视频在线免费观看 | 曰韩精品一区二区| 精品亚洲porn| 日韩免费在线观看| 五月天网站亚洲| 在线看日韩精品电影| 久久色.com| 蜜桃av噜噜一区| 欧美日本一区二区在线观看| 一区二区三区中文字幕电影| 成人性生交大片免费看视频在线| 日韩视频中午一区| 蜜桃在线一区二区三区| 欧美军同video69gay| 亚洲国产aⅴ成人精品无吗| 99国产欧美另类久久久精品 | 国产精品夜夜嗨| 精品福利一区二区三区| 国产一区二区剧情av在线| 亚洲成av人影院在线观看网| 欧美激情艳妇裸体舞| 99热国产精品| 韩国女主播成人在线| 亚洲图片另类小说| 亚洲综合色噜噜狠狠| 欧美成va人片在线观看| 欧洲一区在线电影| 99久久精品99国产精品| 丁香婷婷深情五月亚洲| 国产成人午夜视频| 亚洲在线视频一区| 一区二区在线观看视频 | 欧美精品一二三| 91视频免费观看| 9色porny自拍视频一区二区| 国产精品911| 亚洲精品国产一区二区三区四区在线| 91精品黄色片免费大全| 91免费版在线看| 一区二区成人在线| 久久综合网色—综合色88| 在线观看免费亚洲| 精品少妇一区二区三区视频免付费 | 日韩一二三四区| 国产91精品欧美| 欧美色倩网站大全免费| 国产精品素人一区二区| 韩国精品在线观看| 国产在线不卡一区| 国产蜜臀97一区二区三区| 奇米综合一区二区三区精品视频| 欧美一级日韩不卡播放免费| 国产一区视频导航| 中文字幕一区二区三区四区不卡 | 国产一区中文字幕| 国产精品美女久久福利网站| 成人18视频日本| 亚洲成人免费在线| 国产午夜精品一区二区三区视频 | 不卡av在线免费观看| 一区二区三区鲁丝不卡| 欧美一区二区三区视频免费播放| 国产一区二区三区黄视频 | 日韩一区二区视频在线观看| 国产在线不卡一区| 国产精品午夜免费| 欧美一级免费大片| 不卡视频一二三| 日韩av在线播放中文字幕| 国产亚洲精品超碰| 欧美欧美欧美欧美| 成人黄色片在线观看| 日韩中文字幕区一区有砖一区| 国产亚洲欧美一区在线观看| 在线看国产日韩| 国产一区 二区 三区一级| 亚洲成av人影院在线观看网| www国产成人| 欧美日韩一区二区三区不卡| 日韩av成人高清| 一区二区三区色| 中文字幕一区二区三区不卡| 精品国产不卡一区二区三区| 色婷婷综合久久久久中文| 久久精品国产亚洲一区二区三区| 国产精品情趣视频| 精品国产三级a在线观看| 精品视频在线免费看| 国产suv一区二区三区88区| 亚洲一区二区免费视频| 国产精品久久久久久久久久久免费看| 日韩亚洲欧美中文三级| 欧美日韩在线三级| 91久久免费观看| 成人午夜私人影院| 久久se精品一区精品二区| 亚洲国产成人porn| 亚洲一级不卡视频| 亚洲柠檬福利资源导航| 一区精品在线播放| 国产精品护士白丝一区av| 国产免费成人在线视频| 久久女同精品一区二区| 日韩午夜av电影| 日韩三级伦理片妻子的秘密按摩| 91麻豆123| 99麻豆久久久国产精品免费| 粗大黑人巨茎大战欧美成人| 国产一本一道久久香蕉| 极品美女销魂一区二区三区| 国产一区二三区好的| 久国产精品韩国三级视频| 污片在线观看一区二区| 国产精品三级视频| 中文字幕成人在线观看| 国产精品夫妻自拍| 亚洲一区欧美一区| 日本vs亚洲vs韩国一区三区二区| 一区二区三区色| 亚洲在线免费播放| 中文字幕一区二区三区蜜月| 久久久99精品久久| 国产精品另类一区| 国产精品久久久久久久久图文区 | 日韩精品影音先锋| 久久这里只有精品视频网| 久久色成人在线| 中文字幕亚洲视频| 污片在线观看一区二区| 蜜桃传媒麻豆第一区在线观看| 国产精品2024| 色婷婷av一区二区三区之一色屋| 欧美日韩国产美女| 国产精品午夜春色av| 丝袜脚交一区二区| 成人黄色a**站在线观看| 欧美日本韩国一区二区三区视频| 国产亚洲成aⅴ人片在线观看| 一区二区三区资源| 国产成人aaaa| 欧美一区二区三区免费在线看| 中文成人av在线| 日本三级韩国三级欧美三级| 99久久99久久精品免费看蜜桃| 日韩精品自拍偷拍| 天天色综合成人网| 色噜噜狠狠成人中文综合| 欧美激情中文字幕| 麻豆国产精品视频| 欧美日韩国产123区| 国产精品污网站| 国产在线一区二区| 91精品免费观看| 亚洲国产日韩精品| 91麻豆国产福利在线观看| 久久久综合网站| 蜜桃av一区二区三区| 欧美日韩一区成人| 亚洲视频小说图片| 成人免费毛片片v| 久久精品无码一区二区三区 | 亚洲男人都懂的| 懂色av一区二区夜夜嗨| 日韩欧美精品在线| 看电影不卡的网站| 91精品国产日韩91久久久久久| 亚洲五码中文字幕| 欧美偷拍一区二区| 亚洲一区在线观看视频| 色乱码一区二区三区88| 国产精品电影院| av在线综合网| 成人免费在线播放视频| 91在线观看污| 亚洲视频一区在线观看| 91麻豆精品视频| 一区二区激情小说| 欧美亚洲综合网| 亚洲第一搞黄网站|