ia64/xen-unstable

view tools/vnet/libxutil/util.c @ 19848:5839491bbf20

[IA64] replace MAX_VCPUS with d->max_vcpus where necessary.

don't use MAX_VCPUS, and use vcpu::max_vcpus.
The changeset of 2f9e1348aa98 introduced max_vcpus to allow more vcpus
per guest. This patch is ia64 counter part.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Mon Jun 29 11:26:05 2009 +0900 (2009-06-29)
parents 9f22db685802
children
line source
1 /*
2 * Copyright (C) 2002 - 2004 Mike Wray <mike.wray@hp.com>.
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation; either version 2.1 of the
7 * License, or (at your option) any later version. This library is
8 * distributed in the hope that it will be useful, but WITHOUT ANY
9 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE.
11 * See the GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
18 #include "sys_net.h"
19 #include "sys_string.h"
21 #ifndef __KERNEL__
22 # include <grp.h>
23 # include <pwd.h>
24 #endif
26 #include "util.h"
29 /** @file Various utility functions.
30 */
32 /** Print an address (in network order) as an IPv4 address string
33 * in dot notation.
34 *
35 * @param io where to print address
36 * @param address to print (in network order)
37 * @return bytes printed
38 */
39 int print_address(IOStream *io, unsigned long address){
40 #ifdef __KERNEL__
41 address = ntohl(address);
42 return IOStream_print(io, "%u.%u.%u.%u",
43 (unsigned)((address >> 24) & 0xff),
44 (unsigned)((address >> 16) & 0xff),
45 (unsigned)((address >> 8) & 0xff),
46 (unsigned)((address ) & 0xff));
47 #else
48 struct in_addr inaddr = { s_addr: address };
49 return IOStream_print(io, inet_ntoa(inaddr));
50 #endif
51 }
53 /** Get the protocol number for a protocol.
54 *
55 * @param name protocol name
56 * @param protocol where to put the protocol number
57 * @return 0 if OK, error otherwise
58 */
59 int get_protocol_number(char *name, unsigned long *protocol){
60 #ifdef __KERNEL__
61 return -1;
62 #else
63 struct protoent *proto = getprotobyname(name);
64 if(!proto){
65 return -1;
66 }
67 *protocol = proto->p_proto;
68 return 0;
69 #endif
70 }
72 /** Get the protocol name for a protocol number.
73 *
74 * @param protocol number
75 * @return name or null
76 */
77 char *get_protocol_name(unsigned long protocol){
78 #ifdef __KERNEL__
79 return 0;
80 #else
81 struct protoent *proto = getprotobynumber(protocol);
82 if(!proto){
83 return 0;
84 }
85 return proto->p_name;
86 #endif
87 }
89 /** Get the host name for an address.
90 *
91 * @param addr address
92 * @return host name or null
93 */
94 char *get_host_name(unsigned long addr){
95 #ifdef __KERNEL__
96 return 0;
97 #else
98 struct in_addr inaddr;
99 struct hostent *host = 0;
101 inaddr.s_addr = addr;
102 host = gethostbyaddr((char*)&inaddr, sizeof(inaddr), AF_INET);
103 if(!host) return NULL;
104 return host->h_name;
105 #endif
106 }