netcat源代码分析,gethostpoop()函数
来源:互联网 发布:html js select 添加 编辑:程序博客网 时间:2024/05/21 09:31
errno = 0;
if (name)
poop = (HINF *) Hmalloc (sizeof (HINF));
if (! poop)
bail ("gethostpoop fuxored");
strcpy (poop->name, unknown); /* preload it */
/* see wzv:workarounds.c for dg/ux return-a-struct inet_addr lossage */
iaddr.s_addr = inet_addr (name);
if (iaddr.s_addr == INADDR_NONE) { /* here's the great split: names... */
if (numeric)
bail ("Can't parse %s as an IP address", name);
fprintf(stderr,"name = %s \n",name);
hostent = gethostbyname (name);
if (! hostent)
/* failure to look up a name is fatal, since we can't do anything with it */
/* XXX: h_errno only if BIND? look up how telnet deals with this */
bail ("%s: forward host lookup failed: h_errno %d", name, h_errno);
strncpy (poop->name, hostent->h_name, sizeof (poop->name));
for (x = 0; hostent->h_addr_list[x] && (x < 8); x++) {
memcpy (&poop->iaddrs[x], hostent->h_addr_list[x], sizeof (IA));
strncpy (poop->addrs[x], inet_ntoa (poop->iaddrs[x]),
sizeof (poop->addrs[0]));
} /* for x -> addrs, part A */
if (! o_verbose) /* if we didn't want to see the */
return (poop); /* inverse stuff, we're done. */
/* do inverse lookups in separate loop based on our collected forward addrs,
since gethostby* tends to crap into the same buffer over and over */
for (x = 0; poop->iaddrs[x].s_addr && (x < 8); x++) {
hostent = gethostbyaddr ((char *)&poop->iaddrs[x],
sizeof (IA), AF_INET);
if ((! hostent) || (! hostent-> h_name))
holler ("Warning: inverse host lookup failed for %s: h_errno %d",
poop->addrs[x], h_errno);
else
(void) comparehosts (poop, hostent);
} /* for x -> addrs, part B */
if (name)
poop = (HINF *) Hmalloc (sizeof (HINF));
if (! poop)
bail ("gethostpoop fuxored");
strcpy (poop->name, unknown); /* preload it */
/* see wzv:workarounds.c for dg/ux return-a-struct inet_addr lossage */
iaddr.s_addr = inet_addr (name);
if (iaddr.s_addr == INADDR_NONE) { /* here's the great split: names... */
if (numeric)
bail ("Can't parse %s as an IP address", name);
fprintf(stderr,"name = %s \n",name);
hostent = gethostbyname (name);
if (! hostent)
/* failure to look up a name is fatal, since we can't do anything with it */
/* XXX: h_errno only if BIND? look up how telnet deals with this */
bail ("%s: forward host lookup failed: h_errno %d", name, h_errno);
strncpy (poop->name, hostent->h_name, sizeof (poop->name));
for (x = 0; hostent->h_addr_list[x] && (x < 8); x++) {
memcpy (&poop->iaddrs[x], hostent->h_addr_list[x], sizeof (IA));
strncpy (poop->addrs[x], inet_ntoa (poop->iaddrs[x]),
sizeof (poop->addrs[0]));
} /* for x -> addrs, part A */
if (! o_verbose) /* if we didn't want to see the */
return (poop); /* inverse stuff, we're done. */
/* do inverse lookups in separate loop based on our collected forward addrs,
since gethostby* tends to crap into the same buffer over and over */
for (x = 0; poop->iaddrs[x].s_addr && (x < 8); x++) {
hostent = gethostbyaddr ((char *)&poop->iaddrs[x],
sizeof (IA), AF_INET);
if ((! hostent) || (! hostent-> h_name))
holler ("Warning: inverse host lookup failed for %s: h_errno %d",
poop->addrs[x], h_errno);
else
(void) comparehosts (poop, hostent);
} /* for x -> addrs, part B */
} else { /* not INADDR_NONE: numeric addresses... */
else之前的是gethostpoop()函数的第一个参数是域名的形式,
而else语句中是处理的ip地址的形式。
G:\nc\nc114-debug>nc example.org 55
in res_init
after recycle
after go: x now , optarg 0 optind 1
name = example.org
Single 1, curport 55
in doconnect
in doconnect ,listen socket nnetfd = 1864.
in arm num = 1 stdhnd = 7
handle is 7
in doconnect setjmp
- netcat源代码分析,gethostpoop()函数
- netcat源代码分析,doconnect()函数的作用
- netcat源代码分析,dolisten()函数中的whoisit
- netcat源代码分析,doexec ()函数和readwrite ()函数的关系
- netcat源代码分析(4)doexec.c文件中的SessionWriteShellThreadFn ()函数
- 知识收藏---netcat源代码分析
- netcat源代码分析,doexec.c中的句柄
- NetCat代码分析
- NetCat代码分析
- 分析netcat程序代码
- 分析netcat程序代码
- netcat源代码分析,udp模式(1)服务端如何得到客户端的ip地址和端口号?
- gcc源代码分析 gen_rtx()函数
- gcc源代码分析emit_call_insn()函数
- GCC源代码分析,recog_memoized()函数
- gcc源代码分析,output_asm_insn()函数
- gcc源代码分析,expand_expr_stmt()函数
- IPVS源代码分析---hook函数
- 当灵感出现时,立即抓住它你可以有很多idea,但如果不实践,他们都等于零
- MongoDB:"errmsg" : "DBClientBase::findN: transport error: 10.xxx.9.xx:37017 query
- C#拾遗
- Struts2的优点
- 自绘按钮的实现
- netcat源代码分析,gethostpoop()函数
- 使用Geany编写一个 HelloWorld 的C语言程序+100以内素数+java helloworld
- strcmp函数的几点记录
- VB.NET入门基础篇
- ↖(^ω^)↗
- 继承后方法抛出异常的问题
- java 自学日志【十四】---IO流中其他对象
- Frankenstein——4
- EJDesktop开源项目