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

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

?? dhcp.c

?? 包含lwip這個精簡IP協議棧的ucos源代碼.
?? C
?? 第 1 頁 / 共 4 頁
字號:
/** * @file * * Dynamic Host Configuration Protocol client *//* * * Copyright (c) 2001-2004 Leon Woestenberg <leon.woestenberg@gmx.net> * Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands. * 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 a contribution to the lwIP TCP/IP stack. * The Swedish Institute of Computer Science and Adam Dunkels * are specifically granted permission to redistribute this * source code. * * Author: Leon Woestenberg <leon.woestenberg@gmx.net> * * This is a DHCP client for the lwIP TCP/IP stack. It aims to conform * with RFC 2131 and RFC 2132. * * TODO: * - Proper parsing of DHCP messages exploiting file/sname field overloading. * - Add JavaDoc style documentation (API, internals). * - Support for interfaces other than Ethernet (SLIP, PPP, ...) * * Please coordinate changes and requests with Leon Woestenberg * <leon.woestenberg@gmx.net> * * Integration with your code: * * In lwip/dhcp.h * #define DHCP_COARSE_TIMER_SECS (recommended 60 which is a minute) * #define DHCP_FINE_TIMER_MSECS (recommended 500 which equals TCP coarse timer) * * Then have your application call dhcp_coarse_tmr() and * dhcp_fine_tmr() on the defined intervals. * * dhcp_start(struct netif *netif); * starts a DHCP client instance which configures the interface by * obtaining an IP address lease and maintaining it. * * Use dhcp_release(netif) to end the lease and use dhcp_stop(netif) * to remove the DHCP client. * */ #include <string.h> #include "lwip/stats.h"#include "lwip/mem.h"#include "lwip/udp.h"#include "lwip/ip_addr.h"#include "lwip/netif.h"#include "lwip/inet.h"#include "netif/etharp.h"#include "lwip/sys.h"#include "lwip/opt.h"#include "lwip/dhcp.h"#if LWIP_DHCP /* don't build if not configured for use in lwipopt.h *//** global transaction identifier, must be *  unique for each DHCP request. We simply increment, starting *  with this value (easy to match with a packet analyzer) */static u32_t xid = 0xABCD0000;/** DHCP client state machine functions */static void dhcp_handle_ack(struct netif *netif);static void dhcp_handle_nak(struct netif *netif);static void dhcp_handle_offer(struct netif *netif);static err_t dhcp_discover(struct netif *netif);static err_t dhcp_select(struct netif *netif);static void dhcp_check(struct netif *netif);static void dhcp_bind(struct netif *netif);static err_t dhcp_decline(struct netif *netif);static err_t dhcp_rebind(struct netif *netif);static void dhcp_set_state(struct dhcp *dhcp, unsigned char new_state);/** receive, unfold, parse and free incoming messages */static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port);static err_t dhcp_unfold_reply(struct dhcp *dhcp);static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type);static u8_t dhcp_get_option_byte(u8_t *ptr);static u16_t dhcp_get_option_short(u8_t *ptr);static u32_t dhcp_get_option_long(u8_t *ptr);static void dhcp_free_reply(struct dhcp *dhcp);/** set the DHCP timers */static void dhcp_timeout(struct netif *netif);static void dhcp_t1_timeout(struct netif *netif);static void dhcp_t2_timeout(struct netif *netif);/** build outgoing messages *//** create a DHCP request, fill in common headers */static err_t dhcp_create_request(struct netif *netif);/** free a DHCP request */static void dhcp_delete_request(struct netif *netif);/** add a DHCP option (type, then length in bytes) */static void dhcp_option(struct dhcp *dhcp, u8_t option_type, u8_t option_len);/** add option values */static void dhcp_option_byte(struct dhcp *dhcp, u8_t value);static void dhcp_option_short(struct dhcp *dhcp, u16_t value);static void dhcp_option_long(struct dhcp *dhcp, u32_t value);/** always add the DHCP options trailer to end and pad */static void dhcp_option_trailer(struct dhcp *dhcp);/** * Back-off the DHCP client (because of a received NAK response). * * Back-off the DHCP client because of a received NAK. Receiving a * NAK means the client asked for something non-sensible, for * example when it tries to renew a lease obtained on another network. * * We back-off and will end up restarting a fresh DHCP negotiation later. * * @param state pointer to DHCP state structure */static void dhcp_handle_nak(struct netif *netif) {  struct dhcp *dhcp = netif->dhcp;  u16_t msecs = 10 * 1000;  LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_nak(netif=%p) %c%c%u\n", netif,    netif->name[0], netif->name[1], (unsigned int)netif->num));  dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;  LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_handle_nak(): set request timeout %u msecs\n", msecs));  dhcp_set_state(dhcp, DHCP_BACKING_OFF);}/** * Checks if the offered IP address is already in use. * * It does so by sending an ARP request for the offered address and * entering CHECKING state. If no ARP reply is received within a small * interval, the address is assumed to be free for use by us. */static void dhcp_check(struct netif *netif){  struct dhcp *dhcp = netif->dhcp;  err_t result;  u16_t msecs;  LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_check(netif=%p) %c%c\n", (void *)netif, (unsigned int)netif->name[0],    (unsigned int)netif->name[1]));  /* create an ARP query for the offered IP address, expecting that no host     responds, as the IP address should not be in use. */  result = etharp_query(netif, &dhcp->offered_ip_addr, NULL);  if (result != ERR_OK) {    LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_check: could not perform ARP query\n"));  }  dhcp->tries++;  msecs = 500;  dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;  LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_check(): set request timeout %u msecs\n", msecs));  dhcp_set_state(dhcp, DHCP_CHECKING);}/** * Remember the configuration offered by a DHCP server. * * @param state pointer to DHCP state structure */static void dhcp_handle_offer(struct netif *netif){  struct dhcp *dhcp = netif->dhcp;  /* obtain the server address */  u8_t *option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_SERVER_ID);  LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_offer(netif=%p) %c%c%u\n", netif,    netif->name[0], netif->name[1], netif->num));  if (option_ptr != NULL)  {    dhcp->server_ip_addr.addr = htonl(dhcp_get_option_long(&option_ptr[2]));    LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): server 0x%08lx\n", dhcp->server_ip_addr.addr));    /* remember offered address */    ip_addr_set(&dhcp->offered_ip_addr, (struct ip_addr *)&dhcp->msg_in->yiaddr);    LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08lx\n", dhcp->offered_ip_addr.addr));    dhcp_select(netif);  }}/** * Select a DHCP server offer out of all offers. * * Simply select the first offer received. * * @param netif the netif under DHCP control * @return lwIP specific error (see error.h) */static err_t dhcp_select(struct netif *netif){  struct dhcp *dhcp = netif->dhcp;  err_t result;  u32_t msecs;  LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_select(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num));  /* create and initialize the DHCP message header */  result = dhcp_create_request(netif);  if (result == ERR_OK)  {    dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN);    dhcp_option_byte(dhcp, DHCP_REQUEST);    dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN);    dhcp_option_short(dhcp, 576);    /* MUST request the offered IP address */    dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4);    dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr));    dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4);    dhcp_option_long(dhcp, ntohl(dhcp->server_ip_addr.addr));    dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, 4/*num options*/);    dhcp_option_byte(dhcp, DHCP_OPTION_SUBNET_MASK);    dhcp_option_byte(dhcp, DHCP_OPTION_ROUTER);    dhcp_option_byte(dhcp, DHCP_OPTION_BROADCAST);    dhcp_option_byte(dhcp, DHCP_OPTION_DNS_SERVER);    dhcp_option_trailer(dhcp);    /* shrink the pbuf to the actual content length */    pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len);    /* TODO: we really should bind to a specific local interface here       but we cannot specify an unconfigured netif as it is addressless */    udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);    /* send broadcast to any DHCP server */    udp_connect(dhcp->pcb, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);    udp_send(dhcp->pcb, dhcp->p_out);    /* reconnect to any (or to server here?!) */    udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);    dhcp_delete_request(netif);    LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_select: REQUESTING\n"));    dhcp_set_state(dhcp, DHCP_REQUESTING);  } else {    LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_select: could not allocate DHCP request\n"));  }  dhcp->tries++;  msecs = dhcp->tries < 4 ? dhcp->tries * 1000 : 4 * 1000;  dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;  LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_select(): set request timeout %u msecs\n", msecs));  return result;}/** * The DHCP timer that checks for lease renewal/rebind timeouts. * */void dhcp_coarse_tmr(){  struct netif *netif = netif_list;  LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_coarse_tmr()\n"));  /* iterate through all network interfaces */  while (netif != NULL) {    /* only act on DHCP configured interfaces */    if (netif->dhcp != NULL) {      /* timer is active (non zero), and triggers (zeroes) now? */      if (netif->dhcp->t2_timeout-- == 1) {        LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout\n"));        /* this clients' rebind timeout triggered */        dhcp_t2_timeout(netif);      /* timer is active (non zero), and triggers (zeroes) now */      } else if (netif->dhcp->t1_timeout-- == 1) {        LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout\n"));        /* this clients' renewal timeout triggered */        dhcp_t1_timeout(netif);      }    }    /* proceed to next netif */    netif = netif->next;  }}/** * DHCP transaction timeout handling * * A DHCP server is expected to respond within a short period of time. * This timer checks whether an outstanding DHCP request is timed out. *  */void dhcp_fine_tmr(){  struct netif *netif = netif_list;  /* loop through netif's */  while (netif != NULL) {    /* only act on DHCP configured interfaces */    if (netif->dhcp != NULL) {      /* timer is active (non zero), and is about to trigger now */      if (netif->dhcp->request_timeout-- == 1) {        /* { netif->dhcp->request_timeout == 0 } */        LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_fine_tmr(): request timeout\n"));        /* this clients' request timeout triggered */        dhcp_timeout(netif);      }    }    /* proceed to next network interface */    netif = netif->next;  }}/** * A DHCP negotiation transaction, or ARP request, has timed out. * * The timer that was started with the DHCP or ARP request has * timed out, indicating no response was received in time. * * @param netif the netif under DHCP control * */static void dhcp_timeout(struct netif *netif){  struct dhcp *dhcp = netif->dhcp;  LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_timeout()\n"));  /* back-off period has passed, or server selection timed out */  if ((dhcp->state == DHCP_BACKING_OFF) || (dhcp->state == DHCP_SELECTING)) {    LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_timeout(): restarting discovery\n"));    dhcp_discover(netif);  /* receiving the requested lease timed out */  } else if (dhcp->state == DHCP_REQUESTING) {    LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, DHCP request timed out\n"));    if (dhcp->tries <= 5) {      dhcp_select(netif);    } else {      LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, releasing, restarting\n"));      dhcp_release(netif);      dhcp_discover(netif);    }  /* received no ARP reply for the offered address (which is good) */  } else if (dhcp->state == DHCP_CHECKING) {    LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): CHECKING, ARP request timed out\n"));    if (dhcp->tries <= 1) {      dhcp_check(netif);    /* no ARP replies on the offered address,       looks like the IP address is indeed free */    } else {      /* bind the interface to the offered address */      dhcp_bind(netif);    }  }  /* did not get response to renew request? */  else if (dhcp->state == DHCP_RENEWING) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91精品精华液一区二区三区 | 一区二区三国产精华液| 亚洲欧洲日韩av| 亚洲一区二区三区视频在线播放| 午夜欧美视频在线观看| 高清在线不卡av| 在线影院国内精品| 久久久国产精品麻豆 | 欧美日韩电影一区| 国产人成一区二区三区影院| 亚洲欧美日韩国产综合在线| 精一区二区三区| 91久久精品一区二区三区| 欧美v国产在线一区二区三区| 亚洲综合一区在线| 92精品国产成人观看免费| 国产日韩三级在线| 亚洲精品日韩一| 国产成人av影院| 91精品国产全国免费观看| 国产精品久久久久影院色老大| 日本美女一区二区三区| 色婷婷香蕉在线一区二区| 欧美主播一区二区三区美女| 国产日韩一级二级三级| 亚洲成av人片在线| 99国产精品视频免费观看| 欧美www视频| 婷婷一区二区三区| 99久久婷婷国产综合精品电影| 2024国产精品| 蜜臀99久久精品久久久久久软件| 色狠狠色狠狠综合| 亚洲欧洲精品一区二区三区不卡| 国产精品自在在线| 精品国产一二三区| 免费高清视频精品| 67194成人在线观看| 一区二区三区在线免费观看| 成人av电影免费在线播放| 久久久久久久久久看片| 国产在线播放一区二区三区| 日韩久久精品一区| 日日夜夜一区二区| 91精品国产综合久久福利 | 日韩av中文字幕一区二区| 欧美在线高清视频| 亚洲午夜一区二区| 欧美日本国产一区| 人人狠狠综合久久亚洲| 91麻豆精品国产91久久久久久 | 久久毛片高清国产| 精品系列免费在线观看| 精品卡一卡二卡三卡四在线| 麻豆精品在线观看| 精品国产免费视频| 国内精品久久久久影院薰衣草| 日韩欧美国产麻豆| 九一九一国产精品| 日本一区二区高清| 一本久道中文字幕精品亚洲嫩| 最新中文字幕一区二区三区| 成人精品国产一区二区4080 | 毛片av一区二区| 欧美影院一区二区| 青娱乐精品在线视频| 日韩欧美中文一区二区| 国产福利一区二区三区| 成人欧美一区二区三区| 欧美亚洲国产一卡| 视频一区在线播放| 久久综合资源网| 99久久国产综合精品色伊| 亚洲高清免费在线| 精品国产免费人成电影在线观看四季 | 欧美性猛交xxxxxx富婆| 日日摸夜夜添夜夜添国产精品 | 又紧又大又爽精品一区二区| 欧美欧美午夜aⅴ在线观看| 免费日本视频一区| 国产精品国产三级国产aⅴ中文| 99riav久久精品riav| 丝袜美腿高跟呻吟高潮一区| 久久精品视频在线看| 在线观看一区二区精品视频| 激情欧美一区二区三区在线观看| 亚洲欧洲三级电影| 日韩免费性生活视频播放| 不卡在线观看av| 青青草国产成人av片免费| 国产精品网站在线| 99视频精品全部免费在线| 婷婷激情综合网| 久久精品男人天堂av| 91国在线观看| 精品影视av免费| 亚洲伦在线观看| 欧美一级夜夜爽| 成人精品一区二区三区中文字幕| 亚洲一区二区三区四区五区中文| 久久―日本道色综合久久 | 91视视频在线观看入口直接观看www| 亚洲电影一级黄| 国产精品少妇自拍| 精品久久久久av影院| 在线亚洲高清视频| 成人一级黄色片| 久久se这里有精品| 视频一区视频二区在线观看| 亚洲欧洲中文日韩久久av乱码| 日韩精品一区二区三区四区 | 日韩国产精品久久久久久亚洲| 国产精品嫩草影院com| 欧美亚洲综合另类| 成人小视频在线观看| 久久av老司机精品网站导航| 亚洲免费色视频| 国产精品萝li| 国产日韩欧美一区二区三区乱码 | 1024成人网色www| 久久综合久色欧美综合狠狠| 欧美一区二区在线播放| 欧美日韩综合色| 欧美在线看片a免费观看| 色综合一区二区| 99r精品视频| 粉嫩绯色av一区二区在线观看| 久久99久久99精品免视看婷婷| 无码av免费一区二区三区试看 | 国产精品一区久久久久| 日韩综合小视频| 日韩高清在线观看| 天天免费综合色| 日韩不卡一区二区三区 | 午夜精品久久久久久不卡8050| 亚洲精品videosex极品| 亚洲精品免费播放| 亚洲一区二区三区在线| 亚洲最快最全在线视频| 亚洲一区二区三区四区不卡| 亚洲国产精品久久人人爱蜜臀| 亚洲一区二区三区中文字幕| 亚洲国产一区二区三区 | 亚洲国产精品精华液2区45| 国产丝袜欧美中文另类| 日本一二三四高清不卡| 亚洲欧美国产高清| 亚洲无人区一区| 日本91福利区| 国产在线视视频有精品| 成人在线综合网| 欧美性生活久久| 日韩欧美亚洲国产精品字幕久久久| 欧美xxxxxxxx| 国产精品电影院| 亚洲三级久久久| 五月婷婷另类国产| 国产综合色在线| 91啪九色porn原创视频在线观看| 日韩一区二区精品| 国产精品美女久久久久久久久| 久久美女艺术照精彩视频福利播放| 2欧美一区二区三区在线观看视频| 26uuu亚洲综合色欧美| 国产精品日韩精品欧美在线| 亚洲一区二区美女| 久久精品国产免费看久久精品| 国产91丝袜在线观看| 欧美综合亚洲图片综合区| 在线不卡一区二区| 国产精品久久久久三级| 香港成人在线视频| 国产91对白在线观看九色| 欧美日精品一区视频| 欧美激情在线一区二区| 午夜av区久久| 91在线精品一区二区| 日韩欧美电影一区| 亚洲欧美成aⅴ人在线观看| 天天亚洲美女在线视频| 国产精品一线二线三线精华| 男女男精品视频网| 成人综合婷婷国产精品久久蜜臀| 91精品国产综合久久久久久久 | 欧美激情一区二区三区不卡| 久久精品国产第一区二区三区| 欧美精品一卡两卡| 三级欧美在线一区| 欧美精品电影在线播放| 成人精品视频.| 国产精品女人毛片| 成人高清免费观看| 国产精品毛片高清在线完整版| 国产精品亚洲第一| 久久久精品国产免大香伊| 国产中文一区二区三区| 久久婷婷色综合| 丁香一区二区三区| 欧美精选在线播放| 国产精品美女久久福利网站|