SCSI wait for scans
[ovirt-node/TEMP.git] / ovirt-identify-node / ovirt-identify-node.h
blob405ca4bf5b06e302b70d4389e30f9117393aec76
1 /* Copyright (C) 2008 Red Hat, Inc.
2 * Written by Darryl L. Pierce <dpierce@redhat.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA. A copy of the GNU General Public License is
17 * also available at http://www.gnu.org/copyleft/gpl.html.
20 #ifndef __OVIRT_IDENTIFY_NODE_H
21 #define __OVIRT_IDENTIFY_NODE_H
23 #include <errno.h>
24 #include <getopt.h>
25 #include <netdb.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <unistd.h>
31 #include <arpa/inet.h>
33 #include <hal/libhal.h>
35 #include <libvirt/libvirt.h>
37 #include <linux/types.h>
38 #include <linux/ethtool.h>
39 #include <linux/sockios.h>
40 #include <linux/if.h>
42 #include <netinet/in.h>
44 #include <sys/ioctl.h>
45 #include <sys/types.h>
46 #include <sys/socket.h>
48 #define BUFFER_LENGTH 128
49 #define CPU_FLAGS_BUFFER_LENGTH 256
51 typedef struct _cpu_info {
52 char cpu_num[BUFFER_LENGTH];
53 char core_num[BUFFER_LENGTH];
54 char number_of_cores[BUFFER_LENGTH];
55 char vendor[BUFFER_LENGTH];
56 char model[BUFFER_LENGTH];
57 char family[BUFFER_LENGTH];
58 char cpuid_level[BUFFER_LENGTH];
59 char speed[BUFFER_LENGTH];
60 char cache[BUFFER_LENGTH];
61 char flags[CPU_FLAGS_BUFFER_LENGTH];
62 struct _cpu_info* next;
63 } t_cpu_info;
65 typedef t_cpu_info* cpu_info_ptr;
67 typedef struct _nic_info {
68 char mac_address[BUFFER_LENGTH];
69 char bandwidth[BUFFER_LENGTH];
70 char ip_address[BUFFER_LENGTH];
71 char netmask[BUFFER_LENGTH];
72 char iface_name[BUFFER_LENGTH];
73 char broadcast[BUFFER_LENGTH];
74 struct _nic_info* next;
75 } t_nic_info;
77 typedef t_nic_info* nic_info_ptr;
79 int config(int argc,char** argv);
80 void usage(void);
82 void get_label_and_value(char* text,
83 char* label,size_t label_length,
84 char* value,size_t value_length);
86 int send_text(char* text);
87 int get_text(const char *const expected);
89 /* comm.c */
90 ssize_t saferead(int fd, char *buf, size_t count);
91 ssize_t safewrite(int fd, const void *buf, size_t count);
93 /* debug.c */
94 void debug_cpu_info(void);
96 /* gather.c */
97 int init_gather(void);
98 int get_uuid(void);
99 int get_cpu_info(void);
100 int get_nic_info(void);
102 /* hal_support.c */
103 LibHalContext* get_hal_ctx(void);
105 /* protocol.c */
106 int create_connection(void);
107 int start_conversation(void);
108 int send_details(void);
109 int end_conversation(void);
110 int send_value(char* label,char* value);
111 int send_text(char* text);
113 /* variables */
114 extern int debug;
115 extern int verbose;
116 extern int testing;
118 extern char arch[BUFFER_LENGTH];
119 extern char uuid[BUFFER_LENGTH];
120 extern char memsize[BUFFER_LENGTH];
121 extern char numcpus[BUFFER_LENGTH];
122 extern char cpuspeed[BUFFER_LENGTH];
123 extern char *hostname;
124 extern int hostport;
125 extern int socketfd;
126 extern cpu_info_ptr cpu_info;
127 extern nic_info_ptr nic_info;
129 extern DBusConnection* dbus_connection;
130 extern DBusError dbus_error;
131 extern LibHalContext* hal_ctx;
133 /* macros */
134 #define DEBUG(arg...) if(debug) fprintf(stderr, ##arg)
135 #define VERBOSE(arg...) if(verbose) fprintf(stdout, ##arg)
136 #define COPY_VALUE_TO_BUFFER(value,buffer,length) \
137 snprintf(buffer,length,"%s",value)
139 #endif