source: trunk/athena/etc/larvnetd/larvnetd.h @ 12051

Revision 12051, 3.4 KB checked in by ghudson, 26 years ago (diff)
Support grouping of net names into a single report name. To properly handle reloading of the config file, this means remembering the reported net name and translating it to a report name at report time.
Line 
1/* $Id: larvnetd.h,v 1.2 1998-10-13 17:12:58 ghudson Exp $ */
2
3/* Copyright 1998 by the Massachusetts Institute of Technology.
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for any purpose and without
7 * fee is hereby granted, provided that the above copyright
8 * notice appear in all copies and that both that copyright
9 * notice and this permission notice appear in supporting
10 * documentation, and that the name of M.I.T. not be used in
11 * advertising or publicity pertaining to distribution of the
12 * software without specific, written prior permission.
13 * M.I.T. makes no representations about the suitability of
14 * this software for any purpose.  It is provided "as is"
15 * without express or implied warranty.
16 */
17
18#ifndef LARVNETD__H
19#define LARVNETD__H
20
21#include <sys/types.h>
22#include <netinet/in.h>
23#include <stdio.h>
24#include <time.h>
25#include <ares.h>
26#include "timer.h"
27
28enum busystate { BUSY, FREE, UNKNOWN_BUSYSTATE };
29
30struct cluster {
31  char *name;
32  char *phone;
33  int cgroup;                   /* Index into config.cgroups, or -1 */
34};
35
36struct archname {
37  char *reportname;
38  char **netnames;
39  int nnetnames;
40};
41
42struct machine {
43  /* Configuration data */
44  char *name;
45  int cluster;                  /* Index into config.clusters */
46
47  /* State information */
48  enum busystate busy;
49  char *arch;                   /* Architecture name reported in status */
50  time_t laststatus;            /* Time of last status report */
51  time_t lastpoll;              /* Time of last poll we sent */
52  int numpolls;                 /* Number of polls since laststatus */
53};
54
55struct printer {
56  /* Configuration data */
57  char *name;
58  int cluster;                  /* Index into config.clusters */
59
60  /* State information */
61  int up;
62  int jobs;
63  int s;                        /* Communications socket for polling */
64  int to_send;                  /* Non-zero if we want to send data */
65  char buf[BUFSIZ];             /* Data to send or data received */
66  int buflen;                   /* Amount of data in buf */
67  int jobs_counted;             /* Jobs counted from data received so far */
68  int up_so_far;                /* 1 until we find out the printer is down */
69  Timer *timer;                 /* Timer for next poll (when s == -1) */
70};
71
72struct cgroup {
73  char *name;
74  int x;
75  int y;
76};
77
78struct config {
79  struct cluster *clusters;
80  int nclusters;
81  struct archname *arches;
82  int narch;
83  struct machine *machines;     /* Sorted by name */
84  int nmachines;
85  struct printer *printers;     
86  int nprinters;
87  struct cgroup *cgroups;
88  int ncgroups;
89  char *report_other;
90  char *report_unknown;
91};
92
93struct serverstate {
94  struct config config;
95  ares_channel channel;
96  void *hescontext;
97  int server_socket;
98  unsigned short poll_port;
99  int startmachine;
100  const char *configfile;
101};
102
103/* config.c */
104void read_initial_config(struct serverstate *state);
105void reread_config(struct serverstate *state);
106
107/* printer.c */
108void printer_start_polls(struct serverstate *state);
109void printer_handle_output(struct serverstate *state, struct printer *printer);
110void printer_handle_input(struct serverstate *state, struct printer *printer);
111
112/* report.c */
113void report(void *arg);
114
115/* util.c */
116void *emalloc(size_t size);
117void *erealloc(void *ptr, size_t size);
118char *estrdup(const char *s);
119char *estrndup(const char *s, size_t n);
120int read_line(FILE *fp, char **buf, int *bufsize);
121
122/* ws.c */
123void ws_poll(void *arg);
124void ws_handle_status(int s, struct config *config);
125struct machine *ws_find(struct config *config, const char *name);
126void ws_sort(struct config *config);
127
128#endif /* LARVNETD__H */
Note: See TracBrowser for help on using the repository browser.