Use sideband also for challenge response.
[paraslash.git] / command.h
index 347dd81ceedc753eb7f89a204ae5372ddb079dc7..851b8f13485a042f8747031ebed1a3bb2e0e3128 100644 (file)
--- a/command.h
+++ b/command.h
@@ -1,5 +1,23 @@
 /** \file command.h The structure of server and afs commands. */
 
 /** \file command.h The structure of server and afs commands. */
 
+/** Per connection data available to command handlers. */
+struct command_context {
+       /** Network address of the peer. */
+       const char *peer;
+       /** The paraslash user that executes this command. */
+       struct user *u;
+       /** Argument count. */
+       int argc;
+       /** Argument vector. */
+       char **argv;
+       /** The command being executed. */
+       struct server_command *cmd;
+       /** File descriptor and crypto keys. */
+       struct stream_cipher_context scc;
+       /** Whether to use the sideband API for this command. */
+       bool use_sideband;
+};
+
 /**
  * Defines one command of para_server.
  */
 /**
  * Defines one command of para_server.
  */
@@ -7,7 +25,7 @@ struct server_command {
        /** The name of the command. */
        const char *name;
        /** Pointer to the function that handles the command. */
        /** The name of the command. */
        const char *name;
        /** Pointer to the function that handles the command. */
-       int (*handler)(struct rc4_context *, int, char * const * const);
+       int (*handler)(struct command_context *);
        /** The privileges a user must have to execute this command. */
        unsigned int perms;
        /** One-line description of the command. */
        /** The privileges a user must have to execute this command. */
        unsigned int perms;
        /** One-line description of the command. */
@@ -17,3 +35,11 @@ struct server_command {
        /** The long help text. */
        const char *help;
 };
        /** The long help text. */
        const char *help;
 };
+
+int send_sb(struct stream_cipher_context *scc, void *buf, size_t numbytes,
+               int band, bool dont_free);
+__printf_3_4 int send_sb_va(struct stream_cipher_context *scc, int band,
+               const char *fmt, ...);
+int recv_sb(struct stream_cipher_context *scc,
+               enum sb_designator expected_band,
+               size_t max_size, struct iovec *result);