⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udp.c

📁 移植到440 下的uip
💻 C
字号:
/** * \addtogroup uip * @{ *//** * \defgroup uipdns uIP hostname resolver functions * @{ * * The uIP DNS resolver functions are used to lookup a hostname and * map it to a numerical IP address. It maintains a list of resolved * hostnames that can be queried with the resolv_lookup() * function. New hostnames can be resolved using the resolv_query() * function. * * When a hostname has been resolved (or found to be non-existant), * the resolver code calls a callback function called resolv_found() * that must be implemented by the module that uses the resolver. *//** * \file * DNS host name to IP address resolver. * \author Adam Dunkels <adam@dunkels.com> *  * This file implements a DNS host name to IP address resolver. *//* * Copyright (c) 2002-2003, Adam Dunkels. * 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 uIP TCP/IP stack. * * $Id: resolv.c,v 1.1.2.5 2003/10/06 22:56:44 adam Exp $ * */#include "udp.h"#include <string.h>#ifndef NULL#define NULL (void *)0#endif /* NULL */static struct uip_udp_conn *resolv_conn = NULL;/** \internal * The main UDP function./*-----------------------------------------------------------------------------------*/extern int uHALr_printf(const char *format, ...);voidudp_appcall(void){  if(uip_udp_conn->rport == HTONS(2340)) {    if(uip_poll()) {    	 static u8_t flag=0;    	 static u8_t str[100];      	 if(flag==0)    	 {      	  uHALr_printf("请输入:");          Uart_GetString((char *)uip_appdata);          uHALr_printf("输入完成!");          uip_slen =strlen((char *)uip_appdata);          memcpy(str, (u8_t *)uip_appdata,uip_slen);           flag=1;          }         else         {          //flag=0;          memcpy((u8_t *)uip_appdata,str,100);          uip_slen=100;          }     }    if(uip_newdata()) {      //newdata(); //      u8_t  *ptr=(u8_t *)uip_appdata;//      memcpy(ptr,(u8_t *)uip_appdata,3);//      uip_slen=3;        uip_appdata[uip_len]='\0';         uHALr_printf("%s\n", uip_appdata);    }         }}voidudp_conf(u16_t *server){       resolv_conn = uip_udp_new(server, 53,2340);}/*-----------------------------------------------------------------------------------*//** * Initalize the resolver. *//*-----------------------------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -