网络流量生成工具,开源软件,也可以作为网络流量检测软件使用

源代码在线查看: gethostname.c

软件大小: 1037 K
上传用户: l2335800
关键词: 网络流量 生成工具 开源软件 流量检测
下载地址: 免注册下载 普通下载 VIP

相关代码

				/* 				 * $smu-mark$ 				 * $name: gethostname.c$ 				 * $author: Salvatore Sanfilippo $ 				 * $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$ 				 * $license: This software is under GPL version 2 of license$ 				 * $date: Fri Nov  5 11:55:47 MET 1999$ 				 * $rev: 8$ 				 */ 								#include 				#include 				#include 				#include 				#include 				#include 				#include 								char *get_hostname(char* addr)				{					static char answer[1024];					static char lastreq[1024] = {'\0'};	/* last request */					struct hostent *he;					struct in_addr naddr;					static char *last_answerp = NULL;									printf(" get hostname..."); fflush(stdout);					printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"						"               "						"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");									if ( !strcmp(addr, lastreq)) return last_answerp;									strncpy(lastreq, addr, 1024);									inet_aton(addr, &naddr);					he = gethostbyaddr((char*)&naddr, 4, AF_INET);									if (he == NULL)					{						last_answerp = NULL;						return NULL;					}									strncpy(answer, he->h_name, 1024);					last_answerp = answer;									return answer;				}											

相关资源