#include <stdlib.h>#include <string.h>#include <ctype.h>#include <sys/param.h>#include <netdb.h>#include <sys/socket.h>#include <unistd.h>#include "config.h"#include "inet.h"#include <netinet/in_systm.h>#include <netinet/ip.h>#include <stdio.h>Include dependency graph for inet.c:

Go to the source code of this file.
Functions | |
| u_int32_t | LookupHostAddr (const char *s) |
| u_int32_t | LookupLocalAddr (void) |
| const char * | intoa (u_int32_t addr) |
| char * | InetNtoa (u_int32_t addr) |
| char * | LookupHostName (u_int32_t addr) |
| u_short | in_cksum (addr, len) u_short *addr |
Variables | |
| const char | rcsid [] |
| int | len |
|
||||||||||||
|
|
|
|
Definition at line 99 of file inet.c. References intoa(). Referenced by LookupHostName().
00100 {
00101 const char *s = intoa(addr);
00102 char *p = (char *)malloc(strlen(s) + 1);
00103 strcpy(p, s);
00104 return p;
00105 }
|
Here is the call graph for this function:

|
|
Definition at line 69 of file inet.c. References NTOHL. Referenced by InetNtoa().
00070 {
00071 register char *cp;
00072 register u_int byte;
00073 register int n;
00074 static char buf[sizeof(".xxx.xxx.xxx.xxx")];
00075
00076 NTOHL(addr);
00077 cp = &buf[sizeof buf];
00078 *--cp = '\0';
00079
00080 n = 4;
00081 do {
00082 byte = addr & 0xff;
00083 *--cp = byte % 10 + '0';
00084 byte /= 10;
00085 if (byte > 0) {
00086 *--cp = byte % 10 + '0';
00087 byte /= 10;
00088 if (byte > 0)
00089 *--cp = byte + '0';
00090 }
00091 *--cp = '.';
00092 addr >>= 8;
00093 } while (--n > 0);
00094
00095 return cp + 1;
00096 }
|
|
|
Definition at line 38 of file inet.c. References u_int32_t. Referenced by UDPIPNetwork::command(), IPNetwork::command(), and LookupLocalAddr().
|
|
|
Definition at line 108 of file inet.c. References InetNtoa().
00109 {
00110 char *p;
00111 struct hostent* hp;
00112
00113 /*XXX*/
00114 if (IN_MULTICAST(ntohl(addr)))
00115 return (InetNtoa(addr));
00116
00117 hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET);
00118 if (hp == 0)
00119 return InetNtoa(addr);
00120 p = (char *)malloc(strlen(hp->h_name) + 1);
00121 strcpy(p, hp->h_name);
00122 return p;
00123 }
|
Here is the call graph for this function:

|
|
Definition at line 52 of file inet.c. References LookupHostAddr(), and u_int32_t.
00053 {
00054 static u_int32_t local_addr;
00055 char name[MAXHOSTNAMELEN];
00056
00057 if (local_addr == 0) {
00058 (void)gethostname(name, sizeof(name));
00059 local_addr = LookupHostAddr(name);
00060 }
00061 return (local_addr);
00062 }
|
Here is the call graph for this function:

|
|
|
Initial value:
"@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/emulate/inet.c,v 1.5 2000/02/08 23:35:13 salehi Exp $ (LBL)"
|
1.3.3