V22.0480-002 Special Topics: Networks

 
Homework 5: Create a networking application using the ONC RPC interface to implement a "remote telephone book" service over UDP.
 
You should define 3 procedures:
 
                ADD_TO_DATABASE
                REMOVE_FROM_DATABASE
                LOOKUP_NAME
                LIST
 
The procedure ADD_TO_DATABASE should take two strings as a parameter (the first containing the username and the second containing the phone number).  It adds the username and the phone number into a database (the database should be a simple file).  If the routine is successful, it returns the number of entries currently in the database.  If the routine is unsuccessful, it returns a string with an error message.  If authentication fails (described below) the procedure returns a void.
 
The procedure REMOVE_FROM_DATABASE should take a string containing a user name as a parameter.  It deletes the user's entry from the database.  If the routine is successful, it returns the number of entries currently in the database.  If the routine is unsuccessful, it returns a string with an error message.  If authentication fails, the procedure returns a void.
 
The procedure LOOKUP_NAME should take a string as a parameter. It retrieves all entries from the database whose name starts with the given string.  If the routine is successful, it returns a linked list of name/phone number pairs.  If the routine is unsuccessful, it returns a string with an error message.  If authentication fails, the procedure returns a void.
 
The procedure LIST should take a void as a parameter.  It retrieves all entries from the database.  If the routine is successful, it returns a linked list of name/phone number pairs.  If the routine is unsuccessful, it returns a string with an error message.  If authentication fails, the procedure returns a void.
 
The client side and the server side of your application must incorporate the UNIX flavor of RPC authentication.    On the server side, you should only allow a user with the same UNIX user ID as the server process to execute the procedures. If another user attempts to execute your procedures, the procedure should fail.
 
The client application reads requests from the command line. The requests are "add", "delete", "query", "list", and "quit". For example, you can invoke the client as follows:
 
        $ remotedb i5
        > add 212-555-1212  John Doe
        entries in database: 1
        > add 212-555-1212  John Doe
        error:  John Doe is already in the database
        > add 212-555-2345  Happy Happy Jack
        entries in database: 2
        > list
        John Doe 212-555-1212
        Happy Happy Jack 212-555-2345
        > delete John Do
        error: John Do is not in the database
        > delete John Doe
        entries in database: 1
        > add 212-555-2222 Harry Higgins
        entries in database: 2
        > add 212-555-2224 Jack Smith
        entries in database: 3
        > query Ha
        Happy Happy Jack 212-555-2345
        Harry Higgins 212-555-2222
        > list
        Happy Happy Jack 212-555-2345
        Harry Higgins 212-555-2222
        Jack Smith 212-555-2224
        > quit
        $
 
The program number should be a number that corresponds to 0x20 followed by the last 6 digits of your student ID.
 
What you must turn in:
 
1. A .x file that defines the protocol.
2. The C code that implements the client-side of the application.
3. The C code that implements the server-side of the application.
 
Due date: Tuesday, November 27