|
Sunday Protocol Documentation This is the documentation for the Drink Sunday Protocol.The original protocol was written by Joe Sunday [sunday@csh.rit.edu]. See also: Sunday Protocol Error Codes Index
Introduction: The Sunday Drink Protocol is a SMTP-like interface to the CSH Drink server software. It was originally designed (quickly) by Joe Sunday in Fall 1999 when he rebuilt the drink hardware and wrote his own server to drive his hardware. While this new protocol was incompatible (and less feature-rich) than the existing protocol, many clients were written that support this protocol.Document Conventions:
Protocol Conventions
A Sunday Protocol Server listens for TCP connections on port 4242. As a connection to the server is made, the server sends one line (referred to as the 'banner') which the client can either discard or use in any way it sees fit. The server then waits for a command, and upon receiving a command, will process it, respond, and wait for another command.
Server Command/Response Pairs: There are several client commands. Each command is on a separate line, and if the command accepts arguments, the arguments are space-delimited, except where noted. Username and Password Formatting Specifications: Commands:
ACCTMGRCHK
Displays whether or not the Sunday Server has a valid pathway to the account management subsystem. If the Sunday Server does not have a valid pathway to the authentication management subsystem, then the USER and PASS command pairs will never return positive, nor will any of the other user account functions. This applies especially in the case the drink system uses the Networked Account Management system, since it is contained within a separate system, and therefore may not always be available when the Sunday Server system is available. Clients may use this query to check to see if authentication will work. They can then display an error to the user, thus saving the user valuable time from trying to authenticate. Note that this command and the drink software architecture is not specific to either the Networked Account Manager or the Basic (local) Account Manager. Does not require the user to be authenticated. Server responses: >OK Account server subsystem running.The subsystem is available and therefore authentication is operational. >ERR 350 Account server subsystem is not ready.The subsystem is not available and thus authentication is not available. CHPASS [user] <new password>
Changes the drink-specific password for the specified user. If the system is not using drink-specific passwords, their current password will not be changed, and this command will do nothing. If the user who is issuing the command is not an administrator, then they may only change the drink-specific password for their own account. In the instance the user is an administrator they may change the drink-specific password for anybody. Requires an authenticated user. Server Responses:
>OK Password changed.Indicates the password was successfully changed.
>ERR 200 Access denied.The current user (who is not an administrator) tried to change another user's password.
>ERR 204 You need to login.The USER and PASS commands have to be successfully issued before CHPASS can be called. >ERR 406 Invalid parameters.The number of parameters provided was not 2.
>ERR 407 Invalid password.The password specified does not meet password formatting standards.
>ERR 410 Invalid user.The specified user was not found in the account database. CODE <slot> <button indices>
Sets the drink server to drop the specified drink when the specified sequence of buttons is pressed on the front of the machine. This feature will only work on big drink. THIS FEATURE NOT YET COMPLETE. DROP <slot index> [delay]
Requests an actual drop from the machine. The client is disconnected following this command to ensure that someone doesn't hog the machine in the case of a single-threaded server. If the drop is not successful, i.e. an error is issued, then the client is not disconnected. Requires an authenticated user. NOTE: The initial version of this protocol did not have the delay argument. That version of the protocol is now DEPRECATED. The reasoning behind this is that if the client implements the delay, the server cannot, for instance, show a countdown on an LCD panel. The client can always countdown on it's end (with decent accuracy). Server responses: >OK Credits remaining: <n>Indicates that the drop was successful, returns the user's new balance and then disconnects the user. >ERR 100 Slot empty.Indicates that the selected slot is empty. >ERR 101 Drop failed, contact an admin.Indicates that there was a failure in dropping the drink, which is generally a bad thing. >ERR 203 User is poor.Indicates that the user's balance is not enough to purchase the drink contained in the specified slot. >ERR 204 You need to login.The USER and PASS commands have to be successfully issued before DROP can be called. >ERR 403 Invalid delay.The delay time provided was not a 32-bit number. This error is not generated if the delay is less than zero or larger than the maximum allowed delay (usually 60 seconds). The number of parameters was not 1 or 2. Indicates that the supplied slot number is not valid in the machine. GETBALANCE [user]
Returns the credit balance of the specified user. Only administrators may retrieve the balance of other users. Requires the user to be authenticated. user - The user to retrieve the
balance of. If this argument is not supplied, the current user is assumed.Server Responses:
>OK Credits: <credits>Indicates the command was successful, and displays the requested users credit balance. >ERR 204 You need to login.The USER and PASS commands have to be successfully issued before GETBALANCE may be called. >ERR 200 Access denied.The current user (who is not an administrator) tried to access another user's credit balance. >ERR 410 Invalid user.The specified user was not found in the account database. >ERR 406 Invalid parameters.The number of parameters specified was not 1. LOCATION
Displays the machines (stored) physical location, such as "NRH (North)". The format of this field is completely arbitrary at the moment. The current locations in use are "NRH (North)" for Big Drink and "NRH ( South)" for Little Drink. These two location specifications mean that the machines are on the 3rd floor of the Nathaniel Rochester Hall building in Rochester, NY. Note that the response is not in quotes, and that everything after the 'OK ' is to be interpreted as the actual location. Does not require the user to be logged in. Does not require any parameters. Server Responses: >OK NRH (North).Indicates that the specified machine is on the north end of the 3rd floor of NRH. PASS <password>
Specifies a password, which can only be successful when issued after the USER command. The password is (unfortunately) transmitted in plain-text, and the server response will indicate the user balance if successful. If this command fails for any reason, the ' USER'
command will have to be resent.Server responses:
Where <balance> is an integer representing the user's balance. This response
should be interpreted as a successful login.>ERR 202 Invalid username or password.Indicates that either the username supplied during the USER command is invalid, or the password supplied is invalid (insufficiently formatted), or not correct. >ERR 201 USER command needs to be issued first.This response will be generated if the USER command was not issued before PASS was issued. >ERR 406 Invalid parameters.The number of parameters specified was not 1. see also USER QUIT
Tells the server the session is over and to close the connection. Server response: Indicates that the server is going to disconnect the client. RAND [delay]
Requests a drop of a random drink from the machine. The client is disconnected following this command (to ensure that someone doesn't hog the machine in the case of a single-threaded server). The random slot will be selected from enabled slots which contain cans. Requires that the user be authenticated. Server responses:
>OK Credits remaining: <n>Indicates the users new balance. This should be interpreted as a successful drop. >ERR 204 You need to login.The USER and PASS commands have to be successfully issued before DROP can be called. >ERR 403 Invalid delay.The specified delay was not a number. >ERR 406 Invalid parameters.The number of parameters specified was not 1. >ERR 101 Drop failed, contact an admin.
Indicates that there was a failure in dropping the drink, which is generally
a bad thing>ERR 104 No slots available.Indicates that all of the slots are empty.>ERR 203 User is poor.Indicates that the user's balance is not enough to purchase the drink contained in this slot. STAT [index]
Requests the contents of the machines slot(s). Does not require the user to be authenticated. If the contents of only a single slot is desired, that slot index can be specified. Server responses:
Each line contains the stats for one slot. The fields are space-delimited, except for the drink name. Their contents are as follows:
<Slot Number> <Contents> <Cost> <Number Available> <Total Number Dropped>
<enable flag>NOTE: Contents is wrapped in quotes, and may contain spaces. The final line from the server is a typical status message, and it is in the form:
>OK <n> Slots retrievedn is the number of slots retrieved. NOTE: Clients should not assume that the slot numbers will be contiguous. The server may contains slots 0-4, but 3 may be disabled. The server may skip disabled/empty slots and simply subtract skipped slots from the 'OK' status message at the end of the output. TEMP
Displays the current machine cabinete temperature. Note that the temperature that is returned is in units of celsuis. This feature currently only works on Big Drink. Server Responses: >OK <temperature> The command was successful in retrieving the temperature. >ERR 351 Unable to determine temperature.There was a subsystem failure in retrieving the cabinete temperature. USER <username>
Specifies a username, beginning the login process. If a user was already logged in, it invalidates the current user. Server response: >OK Password required.
The command completed successfully; next, the ' PASS'
command should be specified.>ERR 406 Invalid parameters.The number of parameters specified was not 1. While you might expect to get an error if the username does not exist in the system, this could be a potential security hole (allowing a nefarious person to determine which usernames are valid). Therefore, this command can not be used to simply determine if the user is a valid user. The only way to determine this through the system is to log on as an administrator and issue the isvaliduser command.see also PASS
VERSION
Shows what version of the SundayServer the drink server is running. Server response: > OK SundayServer $Revision: #15 $Shows the current version. The version is always reported in this format. Administrator-Only Commands These are commands that only administrators can issue. All commands under this section may issue these two errors in the appropriate cases: >ERR 204 You need to login.The USER and PASS commands have to be successfully issued before the command can be called. >ERR 200 Access denied.The current user is not an administrator. ADDCREDITS <username> <credits>
Adds credits to the supplied users account. Both parameters are required.
Server Responses:
>OK Added credits.Indicates that the operation was successfully performed. >ERR 410 Invalid user.The specified username is unknown to the drink accounting system. >ERR 402 Invalid credits.The value given for the credits parameter was not a number. The only characters allowed are numbers and a single leading dash '-' to signify a negative integer. >ERR 406 Invalid parameters.The number of parameters specified was not 2 see also: EDITUSER ADDUSER <user name> [password]
Adds a user to the list of known users. If the drink software is using drink-specific passwords, then the password is required. If the system is using CSH IMAP (the default authentication mechanism), then the password will be discarded. Also with the CSH IMAP authentication mechanism, if the newly created username does not match a CSH username, then the new account is useless. The new user will be created with the defaults - zero credits, no administrator privileges. Server Responses:
>OK User created.
Indicates the account was properly created.>ERR 352 Unable to create user.The Account Manager subsystem was unable to create the user, for an unknown reason. >ERR 406 Invalid parameters.The number of parameters specified was not 2. >ERR 407 Invalid password.The supplied password does not meet password specifications. Passwords may not contain spaces. >ERR 410 Invalid user.The supplied username does not meet username formatting specifications. >ERR 412 User already registered.The specified username is already a registered user, and thus the name cannot be re-registered. CHPASS [user] <password>
See non-administrator commands, CHPASS EDITSLOT <slotnum> <name> <cost> <quantity> <num_dropped> <enabled>
Edits all values for a single slot. All arguments are required. Examples:
Server responses:
>OK Changes saved.
The requested change has been saved into the user database >ERR 409 Invalid slot.The user tried to edit a non-existent slot. >ERR 401 Invalid cost.The specified cost was not a number. >ERR 408 Invalid quantity.The specified quantity was not a number. >ERR 405 Invalid num_dropped.The specified number of cans that had already been served was not a number. >ERR 404 Invalid enable flag.The specified enabled/disabled flag was not either 'true' or 'false'. >ERR 406 Invalid parameters.The number of parameters provided was not 6. EDITUSER <username> <credits>[admin]
Changes another users credit and admin status in one command. NOTE: While there is nothing wrong with using this command to edit a user's balance, it can be somewhat limiting. First of all, if you wish to decrease a user's balance, you have to pass a negative value. Second, this command will NOT create a user if they don't already exist in the system. Server responses: >OK Changes saved.The requested change has been saved into the user database >ERR 410 Invalid user.The user tried to edit a non-existent user's account. >ERR 402 Invalid credits.The specified number of credits was not a number.>ERR 400 Invalid admin flag.The specified boolean admin flag was not either 'true' or 'false'.>ERR 406 Invalid parameters.The number of parameters specified was not 2 or 3.See also GETBALANCE, ADDCREDITS GETBALANCE [user]
See GETBALANCE, listed in the general commands section. ISVALIDUSER <user>
Determines whether or not the specified username is known to the accounting system. username
- The name of the user to test to see if it is known to the accounting system.
Server Responses: >OK true User is known.Indicates that the supplied user is known to the accounting system. >OK false User is not known.Indicates that the supplied user is not known to the accounting system. >ERR 406 Invalid parameters.
The number of parameters specified was not 1.LOG [message]
Adds a message to the drink logfile. The message may contain any characters. Everything that comes after the 'LOG ' command is printed to the logfile. The file is time stamped with the issuing users username. message - the message to leave in
the log file.If there is no message, then a simple timestamp with the users name is left. Server Responses: >OK Message added to log file.
QUERYADMIN <user>
Displays whether or not the specified user is an administrator. The single username parameter is required. username - the name of the user
whose administrator status is to be displayed.Server Responses: >OK true User is an administrator.Indicates that the user is an administrator >OK false User is not an administrator.Indicates that the user is not an administrator. >ERR 410 Invalid user.The specified username is not known to the drink accounting system. >ERR 406 Invalid parameters.The number of parameters specified did not equal 1. RMUSER <user>
Removes a user from the list of known users. This does not affect the user's CSH account. username - The user to delete
from the list of known users.
Server Responses:
>OK User removed.Indicates that the user was successfully removed from the list of known users. >ERR 353 Could not remove user.The Account Manager subsystem failed to remove the supplied, valid user. This error will only occur if the system has checked the validity of the request (IE, the issuing user is an admin user, and the provided username to remove is a valid username), and attempts to remove the user, but fails. >ERR 410 Invalid user.The user was not found in the list of known users. >ERR 406 Invalid parameters.The number of parameters specified did not equal 1.
SETADMIN <user name> <status>
Sets the status of the given users administrator flag. The status flag must be either 'true' or 'false'. Both the username and the status flag are required. Server Responses: >OK Admin flag set.Indicates the operation was successful. >ERR 354 Unable to set admin flag.The error will only occur after all the normal parameter validation has occured and properly validated. This error will only occur when the server actually attempts to change the user's admin status, and is unable to, due to the Account Manager subsystem failing to do so. >ERR 410 Invalid user.Indicates that the user specified is not known to the drink accounting system. >ERR 400 Invalid admin flag.Indicates that the status flag specified did not match either 'true' or 'false'. >ERR 406 Invalid parameters.Indicates that the number of parameters specified was not 2. see also: EDITUSER SHUTDOWN [-r]
Tells the server to close all active connections, cleanup and then exit. If the -r option is specified, the Operating System the software is running on is to be rebooted. This does not imply that the software is to be brought back up with the OS. That can be achieved by placing the correct commands in the appropriate startup scripts. Server Responses:
:shutdownThe software will exit.
:shutdown -r
The software will reboot the underlying Operating System.>ERR 406 Invalid ParametersMore than one parameter was specified. >ERR 411 Invalid reboot flag.The single parameter specified was not '-r'. This document is maintained by: Sean Graham [grahams@csh.rit.edu] and Kevin Thompson [antiduh@csh.rit.edu]. Last Revised: $Date: 2003/08/19 $ |