diff options
author | Nate Straz <nstraz@redhat.com> | 2005-09-13 16:01:28 +0000 |
---|---|---|
committer | Nathan Straz <nstraz@redhat.com> | 2008-09-23 09:37:44 -0400 |
commit | bf489daffc4902db3a9eb95d485fd867ac1ea524 (patch) | |
tree | c022f12c9d1bb8b56b566976cf5127b37112bbf1 /qarsh_packet.h | |
parent | c38e0fba0a10d5af0bb25f674177cb6404f73991 (diff) | |
download | qarsh-bf489daffc4902db3a9eb95d485fd867ac1ea524.tar.gz qarsh-bf489daffc4902db3a9eb95d485fd867ac1ea524.tar.xz qarsh-bf489daffc4902db3a9eb95d485fd867ac1ea524.zip |
Flatten the qarsh tree.
Diffstat (limited to 'qarsh_packet.h')
-rw-r--r-- | qarsh_packet.h | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/qarsh_packet.h b/qarsh_packet.h new file mode 100644 index 0000000..c4316fd --- /dev/null +++ b/qarsh_packet.h @@ -0,0 +1,129 @@ +#ifndef _QARSH_PACKET_H +# define _QARSH_PACKET_H 1 + +#include <sys/types.h> +#include <sys/stat.h> + +#define QARSH_MAX_PACKET_SIZE 32*1024 + +enum qa_packet_type { + QP_INVALID = 0, + QP_HELLO = 1, + QP_RETURNCODE = 2, + QP_RUNCMD = 3, + QP_ACK = 4, + QP_CMDEXIT = 5, + QP_SETUSER = 6, + QP_KILL = 7, + QP_RECVFILE = 8, + QP_SENDFILE = 9, + QP_RSTAT = 10 +}; + +struct qp_hello_pkt { + char *qp_greeting; +}; + +struct qp_returncode_pkt { + int qp_rc; + int qp_errno; + char *qp_strerror; +}; + +struct qp_runcmd_pkt { + char *qp_cmdline; + int qp_stdin_port; + int qp_stdout_port; + int qp_stderr_port; +}; + +/* General packet for acknowledging a command worked */ +struct qp_ack_pkt { + enum qa_packet_type qp_ack_type; + int qp_ack_seq; +}; + +struct qp_cmdexit_pkt { + pid_t qp_pid; + int qp_status; +}; + +struct qp_setuser_pkt { + char *qp_user; + char *qp_group; +}; + +struct qp_kill_pkt { + int qp_sig; +}; + +struct qp_recvfile_pkt { + char *qp_path; + mode_t qp_mode; + int qp_if_port; + size_t qp_count; +}; + +struct qp_sendfile_pkt { + char *qp_path; + int qp_of_port; + size_t qp_count; +}; + +struct qp_rstat_pkt { + char *qp_path; + mode_t qp_st_mode; + uid_t qp_st_uid; + gid_t qp_st_gid; + off_t qp_st_size; +}; + + +#define QP_VERSION 1 + +struct qa_packet { + enum qa_packet_type qp_type; + int qp_seq; /* Sequence number for this packet */ + union { + struct qp_hello_pkt hello; + struct qp_returncode_pkt returncode; + struct qp_runcmd_pkt runcmd; + struct qp_ack_pkt ack; + struct qp_cmdexit_pkt cmdexit; + struct qp_setuser_pkt setuser; + struct qp_kill_pkt kill; + struct qp_recvfile_pkt recvfile; + struct qp_sendfile_pkt sendfile; + struct qp_rstat_pkt rstat; + } qp_u; +}; + +#define qp_hello qp_u.hello +#define qp_returncode qp_u.returncode +#define qp_runcmd qp_u.runcmd +#define qp_ack qp_u.ack +#define qp_cmdexit qp_u.cmdexit +#define qp_setuser qp_u.setuser +#define qp_kill qp_u.kill +#define qp_recvfile qp_u.recvfile +#define qp_sendfile qp_u.sendfile +#define qp_rstat qp_u.rstat + +/* Prototypes */ +char *qp_packet_type(enum qa_packet_type t); +struct qa_packet *parse_packets(char *buf, int n); +struct qa_packet *make_qp_hello(char *greeting); +struct qa_packet *make_qp_returncode(int rc, int eno, char *strerr); +struct qa_packet *make_qp_ack(enum qa_packet_type t, int i); +struct qa_packet *make_qp_runcmd(char *cmdline, int p_in, int p_out, int p_err); +struct qa_packet *make_qp_cmdexit(pid_t pid, int status); +struct qa_packet *make_qp_setuser(char *user, char *group); +struct qa_packet *make_qp_kill(int sig); +struct qa_packet *make_qp_recvfile(const char *path, int if_port, size_t count, mode_t mode); +struct qa_packet *make_qp_sendfile(const char *path, int of_port, size_t count); +struct qa_packet *make_qp_rstat(const char *path, const struct stat *sb); +char *qptostr(struct qa_packet *qp, char **qpstr, int *qpsize); +void qpfree(struct qa_packet *qp); +void dump_qp(struct qa_packet *qp); + +#endif /* !_QARSH_PACKET_H */ |