#ifndef SYSMOND_H #define SYSMOND_H /*************************************************************************/ /* Default port number for daemon. */ #define DEFAULT_PORT 497 /*************************************************************************/ /* Basic structure for a query and response. These are not actually used * in the code, but are here for explanatory purposes. Every query will * have exactly one response (which may be an error), with the exception of * Q_CLOSE, Q_REBOOT, and Q_RESTART. */ typedef struct { unsigned int magic; /* QUERY_MAGIC */ int len; /* Of everything else, not including this */ unsigned char query; /* From the list below */ char param[1]; /* Extended as long as needed */ } Query; typedef struct { unsigned int magic; /* RESPONSE_MAGIC */ int len; /* Of everything else */ unsigned char query; /* What we're responding to */ char result[1]; /* As long as needed */ } Response; #define QUERY_MAGIC 0xC0DEBEAD #define RESPONSE_MAGIC 0xFEE1D1FF /* Query types. Parameters and results are listed for each query type. * Strings are shown as "description" and are sent null-terminated; * characters are shown as 'description'; integers are 4 bytes in network * order and are shown as . Success values are either 1 * (success) or 0 (failure). */ #define Q_PASSWORD 0 /* Identify; must be first query sent * * param: "password" * * result: * * If incorrect, connection is closed. */ #define Q_CLOSE 1 /* Explicitly close the connection; does * * not return a response or take params */ #define Q_UPTIME 10 /* Return parameters like "uptime" * * param: (none) * * result: * * * * */ #define Q_DISKFREE 20 /* Return free space on the given FS * * param: "/fs/mount/point" * * result: "/fs/mount/point" * * * * * * */ #define Q_QUOTA 21 /* Return user's use and quota on FS * * param: "/mount/point" * * result: "/mount/point" * * * * */ #define Q_MEMORY 30 /* Return information on system memory * * param: (none) * * result: * * * * * * */ #define Q_PROCSTAT 40 /* Return status of process * * param: * * result: "string-from-/proc/N/stat"*/ #define Q_PROCQUERY 41 /* Return PIDs with given command name * * param: "name" * * result: "name" ... */ #define Q_PROCLIST 42 /* Return all PIDs on system * * param: (none) * * result: ... */ #define Q_KILL 100 /* Kill the given process * * param: * * result: (none) */ #define Q_EXEC 101 /* Execute the given program with args * * param: "path" "arg0"... * * result: */ #define Q_REBOOT 199 /* Reboot the system. Does not return a * * response. If parameter is zero, will * * try to do "reboot -t3"; otherwise, * * will reboot immediately. * * param: */ #define Q_RESTART 254 /* Restart sysmond. Does not take a * * parameter or return a response. */ #define Q_ERROR 255 /* Indicate an error; only in responses * * result: 'query' "error-message" */ /*************************************************************************/ #endif /* SYSMOND_H */