From bb780e4a89af6a0629619b7c5929f22de1a10ec3 Mon Sep 17 00:00:00 2001 From: CSRG Date: Thu, 4 Jan 1990 04:13:17 -0800 Subject: [PATCH] BSD 4_3_Net_2 development Work on file usr/src/sys/tests/nfs/billboard/src/billboard_rpc.c Work on file usr/src/sys/tests/nfs/billboard/src/bb_codata.c Work on file usr/src/sys/tests/nfs/billboard/src/bb_hash.c Work on file usr/src/sys/tests/nfs/billboard/src/bb_phase.c Work on file usr/src/sys/tests/nfs/billboard/src/bb_passwd.c Work on file usr/src/sys/tests/nfs/billboard/src/bb_board.c Work on file usr/src/sys/tests/nfs/billboard/src/bb_set.c Work on file usr/src/sys/tests/nfs/billboard/src/bb_ip.c Work on file usr/src/sys/tests/nfs/billboard/src/bb_grid.c Work on file usr/src/sys/tests/nfs/billboard/src/billboard.c Work on file usr/src/sys/tests/nfs/billboard/src/bb_list.c Work on file usr/src/sys/tests/nfs/billboard/src/server.h Work on file usr/src/sys/tests/nfs/billboard/src/common.h Work on file usr/src/sys/tests/nfs/billboard/src/billboard_util.c Work on file usr/src/sys/tests/nfs/billboard/src/protocol.x Synthesized-from: CSRG/cd2/net.2 --- .../sys/tests/nfs/billboard/src/bb_board.c | 304 ++++++++++ .../sys/tests/nfs/billboard/src/bb_codata.c | 218 ++++++++ usr/src/sys/tests/nfs/billboard/src/bb_grid.c | 44 ++ usr/src/sys/tests/nfs/billboard/src/bb_hash.c | 118 ++++ usr/src/sys/tests/nfs/billboard/src/bb_ip.c | 122 ++++ usr/src/sys/tests/nfs/billboard/src/bb_list.c | 324 +++++++++++ .../sys/tests/nfs/billboard/src/bb_passwd.c | 225 ++++++++ .../sys/tests/nfs/billboard/src/bb_phase.c | 242 ++++++++ usr/src/sys/tests/nfs/billboard/src/bb_set.c | 134 +++++ .../sys/tests/nfs/billboard/src/billboard.c | 454 +++++++++++++++ .../tests/nfs/billboard/src/billboard_rpc.c | 151 +++++ .../tests/nfs/billboard/src/billboard_util.c | 529 ++++++++++++++++++ usr/src/sys/tests/nfs/billboard/src/common.h | 33 ++ .../sys/tests/nfs/billboard/src/protocol.x | 126 +++++ usr/src/sys/tests/nfs/billboard/src/server.h | 69 +++ 15 files changed, 3093 insertions(+) create mode 100644 usr/src/sys/tests/nfs/billboard/src/bb_board.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/bb_codata.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/bb_grid.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/bb_hash.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/bb_ip.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/bb_list.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/bb_passwd.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/bb_phase.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/bb_set.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/billboard.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/billboard_rpc.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/billboard_util.c create mode 100644 usr/src/sys/tests/nfs/billboard/src/common.h create mode 100644 usr/src/sys/tests/nfs/billboard/src/protocol.x create mode 100644 usr/src/sys/tests/nfs/billboard/src/server.h diff --git a/usr/src/sys/tests/nfs/billboard/src/bb_board.c b/usr/src/sys/tests/nfs/billboard/src/bb_board.c new file mode 100644 index 0000000000..3dca1c23e9 --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/bb_board.c @@ -0,0 +1,304 @@ +/* + ****************************************************************************** + * + * Module: bb_board.c + * + * Description: + * + * Functions: + * bb_read_board() - Read or create the board data file. + * bb_board_tag() - Change an entry in the board. + * bb_get_clients() - Return a list of clients. + * bb_get_servers() - Return a list of servers. + * bb_board_update() - Update the board file on disk. + * + * + ****************************************************************************** + */ + +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" +#include "server.h" + + + +/************************************************************************* +** ** +** bb_read_board() - If the board data file exists then read it and ** +** store it in the board array. Otherwise create the file with zeroed ** +** entries. ** +** ** +*************************************************************************/ +BB_board board; /* The board of tested imps. */ + +int +bb_read_board() +{ + FILE *board_file; /* Pointer to the board file. */ + int i; /* Index into board array. */ + int j; /* Index into board array. */ + int num_imps; /* The number of implementations*/ + + num_imps = bb_get_imp_cnt(); + + /* + ** If the file exists read it into the board array. + */ + if ( (board_file = fopen( BB_BOARD_FILE, "r")) != NULL ) + { + for ( i = 0; i < num_imps; i++ ) + { + for ( j = 0; j < num_imps; j++ ) + { + if ( (board[i][j] = getw( board_file)) == (u_char)EOF ) + { + fprintf( stderr, "ERROR: Board data file incomplete.\n"); + return BB_FAILURE; + } + } + } + + fclose( board_file); + return BB_SUCCESS; + } + + /* + ** The file did not exist so create it. + */ + if ( (board_file = fopen( BB_BOARD_FILE, "w")) == NULL ) + { + fprintf( stderr, "FAILED opening the board data file '%s'.\n", + BB_BOARD_FILE); + fclose( board_file); + return BB_FAILURE; + } + + /* + ** Fill the file with zeroed entries. + */ + for ( i = 0; i < num_imps; i++ ) + { + for ( j = 0; j < num_imps; j++ ) + { + if ( putw( (int)BB_BOARD_UNSET, board_file) == 1 ) + { + fprintf( stderr, "FAILED writting new board file.\n"); + fclose( board_file); + return BB_FAILURE; + } + } + } + + fclose( board_file); + return BB_SUCCESS; +} + + + + +/************************************************************************* +** ** +** bb_board_tag() - Change the value of the board slot to either set it ** +** or unset it. Struct p_in contains a BB_id the client and the server.** +** The p_out struct contains most of the company data. ** +** ** +*************************************************************************/ +void +bb_board_tag( p_in, p_out, set) + BB_set_in *p_in; /* Set input, client id, server id. */ + BB_set_out *p_out; /* Set output, most company data. */ + int set; +{ + int client_id; /* The client identifier. */ + int server_id; /* The server identifier. */ + BB_co_data codata; /* The company data. */ + + /* + ** Get the client and server id's. + */ + if ( (client_id = bb_get_hash( p_in->client)) == BB_HASH_ID_NOT_FOUND ) + { + p_out->status = BB_BAD_CLIENT; + return; + } + + if ( (server_id = bb_get_hash( p_in->server)) == BB_HASH_ID_NOT_FOUND ) + { + p_out->status = BB_BAD_SERVER; + return; + } + + if ( set == BB_SET ) + { + if ( board[server_id][client_id] == BB_BOARD_SET ) + { + p_out->status = BB_ALREADY_SET; + } + board[server_id][client_id] = BB_BOARD_SET; + } + else if ( set == BB_UNSET ) + { + if ( board[server_id][client_id] == BB_BOARD_UNSET ) + { + p_out->status = BB_ALREADY_UNSET; + } + board[server_id][client_id] = BB_BOARD_UNSET; + } + else + { + fprintf( stderr, "Unknown set operation.\n"); + p_out->status = BB_FAILURE; + return; + } + + /* + ** Fill in the company data parts of the output structure. + */ + if ( bb_get_codata( client_id, &codata) != BB_SUCCESS ) + { + /* OOOPS...this wasn't supposed to happen! */ + p_out->status = BB_FAILURE; + return; + } + p_out->client.booth = codata.booth; + strncpy( p_out->client.company, codata.company, BB_COMPANY_NAME_LEN); + strncpy( p_out->client.imp, codata.imp, BB_IMP_NAME_LEN); + strncpy( p_out->client.id, codata.id, BB_ID_NAME_LEN); + if ( bb_get_codata( server_id, &codata) != BB_SUCCESS ) + { + /* OOOPS...this wasn't supposed to happen! */ + p_out->status = BB_FAILURE; + return; + } + p_out->server.booth = codata.booth; + strncpy( p_out->server.company, codata.company, BB_COMPANY_NAME_LEN); + strncpy( p_out->server.imp, codata.imp, BB_IMP_NAME_LEN); + strncpy( p_out->server.id, codata.id, BB_ID_NAME_LEN); + + /* + ** Set the status to indicate whether or not the write to disk + ** succeeded otherwise use the previously set status. + */ + if ( bb_board_update( client_id, server_id) != BB_SUCCESS ) + { + p_out->status = BB_FAILURE; + } +} + + + +/************************************************************************* +** ** +** bb_get_clients() - Get the list of all the clients and their test ** +** status for a particular server. ** +** ** +*************************************************************************/ +int +bb_get_clients( id, list) + BB_id id; /* Id of the client. */ + BB_row list; /* List of all the servers. */ +{ + int index; /* Index of the client. */ + + if ( (index = bb_get_hash( id)) == BB_HASH_ID_NOT_FOUND ) + { + return BB_BAD_CLIENT; + } + + memcpy( list, board[index], sizeof( list)); + return BB_SUCCESS; +} + + + +/************************************************************************* +** ** +** bb_get_servers() - Get the list of all the servers and their test ** +** status for a particular client. ** +** ** +*************************************************************************/ +int +bb_get_servers( id, list) + BB_id id; /* Id of the client. */ + BB_row list; /* List of all the servers. */ +{ + int index; /* Index of the client. */ + int i; /* Nice loop variable name. */ + + if ( (index = bb_get_hash( id)) == BB_HASH_ID_NOT_FOUND ) + { + return BB_BAD_CLIENT; + } + + for( i = 0; i < BB_MAX_IMP; i++ ) + { + list[i] = board[i][index]; + } + + return BB_SUCCESS; +} + + +/************************************************************************* +** ** +** bb_board_update() - Update the billboard on the disk. Since these ** +** only happen one at a time, update is for client,server pair. ** +** ** +*************************************************************************/ +int +bb_board_update( client, server) + int client; /* The index of the client to update. */ + int server; /* The index of the server to update. */ +{ + int num_imps; /* The number of implementations. */ + FILE *board_file; /* Pointer to the board file. */ + long seek_to; /* The position to seek to in the file. */ + + num_imps = bb_get_imp_cnt(); + + if ( (client >= num_imps) || (server >= num_imps) ) + { + return BB_FAILURE; + } + + /* + ** The word that we want to write is at a location server rows + ** down and client rows across. Since the output is written in + ** integers, multiply this number by the sizeof an integer and + ** that is where in the file to write the number. + */ + seek_to = ((server * num_imps) + client) * sizeof(int); + + /* + ** Open the board file. + */ + if ( (board_file = fopen( BB_BOARD_FILE, "r+")) == NULL ) + { + fprintf( stderr, "ERROR: Could not open board file for update.\n"); + return BB_FAILURE; + } + + if ( fseek( board_file, seek_to, 0) != 0 ) + { + fprintf( stderr, "ERROR: Could not seek in board file.\n"); + fclose( board_file); + return BB_FAILURE; + } + + if ( putw( (int)board[server][client], board_file) == 1 ) + { + fprintf( stderr, "ERROR: Could not update board file.\n"); + fclose( board_file); + return BB_FAILURE; + } + + fclose( board_file); + return BB_SUCCESS; +} diff --git a/usr/src/sys/tests/nfs/billboard/src/bb_codata.c b/usr/src/sys/tests/nfs/billboard/src/bb_codata.c new file mode 100644 index 0000000000..f8a1390d6f --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/bb_codata.c @@ -0,0 +1,218 @@ +/* + ****************************************************************************** + * + * Module: bb_codata.c + * + * Description: + * + * Functions: + * bb_put_codata() - Place a company data entry in the structure. + * bb_get_codata() - Get a company data entry from the structure. + * bb_get_imp_cnt() - Return the number of implementations. + * bb_read_companies() - Read the company data file. + * bb_read_1_codata() - Read a single company data from the file. + * + * + ****************************************************************************** + */ + +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" +#include "server.h" + + +static int co_cnt; /* The number of company data entries. */ +static BB_co_data codata[BB_MAX_IMP];/* The company data records. */ + +void bb_get_ip_lines(); +char *strtok(); + + +int +bb_put_codata( p_codata) + BB_co_data *p_codata; /* The company data to put in the table */ +{ + if ( co_cnt + 1 >= BB_MAX_IMP ) + { + fprintf( stderr, "FAILURE can't install company data record: %s.\n", + p_codata->company); + return BB_FAILURE; + } + + memcpy( &codata[ co_cnt], p_codata, sizeof( *p_codata)); + return co_cnt++; +} + +int +bb_get_codata( index, p_codata) + int index; /* The index of the data to retrieve. */ + BB_co_data *p_codata; /* Space to put the data. */ +{ + if ( index >= co_cnt ) + { + return BB_FAILURE; + } + + memcpy( p_codata, &codata[ index], sizeof( *p_codata)); + return BB_SUCCESS; +} + +int +bb_get_imp_cnt() +{ + return co_cnt; +} + + +/************************************************************************* +** ** +** bb_read_companies() - Read the file containing the company data. ** +** For each entry create a company data record, and add an entry in the** +** hash table. The company data file also contains IP addresses, which** +** are stored in the ip_table. ** +** ** +*************************************************************************/ +int +bb_read_companies() +{ + int status; /* Status of function call returns. */ + int index; /* Index of the company data record. */ + BB_co_data cdata; /* Space for the readding of records. */ + + while( (status = bb_read_1_codata( &cdata)) != BB_END_OF_FILE ) + { + /* + ** If the read was not successful exit. + */ + if ( status != BB_SUCCESS ) + { + fprintf( stderr, "ABORTING: Can't read company data file.\n"); + return BB_FAILURE; + } + + /* + ** Put the company data record in the array. + */ + if ( (index = bb_put_codata( &cdata)) == BB_FAILURE ) + { + fprintf( stderr, "ABORTING: Not enough company data space.\n"); + return BB_FAILURE; + } + + /* + ** Fill in the hash record for the company data record. + */ + if ( bb_put_hash( codata[index].id, index) != BB_SUCCESS ) + { + fprintf( stderr, "ABORTING: Unable to hash company: %s.\n", + cdata.company); + return BB_FAILURE; + } + } + + /* + ** Read all of the company data with no problems. + */ + return BB_SUCCESS; +} + + +/************************************************************************* +** ** +** bb_read_1_codata() - Read one company data record from the co data ** +** file. If the file is not open then open it and start readding. The ** +** file is ordered in the same manner as the BB_co_data structure. IP ** +** means a set of internet addresses are on the same line. Each of ** +** these addresses belongs to the companies that follow up to the next ** +** IP specification. ** +** ** +*************************************************************************/ +static FILE *file = NULL; /* File pointer to company data file. */ + +int +bb_read_1_codata( p_codata) + BB_co_data *p_codata; /* Output a company data record. */ +{ + static int ip_count; /* Number of IP addresses for company. */ + static int ip_index; /* Place where IP addresses start. */ + bool_t done = FALSE; /* Done readding this codata record. */ + char line[BB_MAX_LINE_LEN]; /* Input line buffer. */ + + /* + ** If the file is not open then it neads to be. + */ + if ( file == NULL ) + { + if ( (file = fopen( BB_CODATA_FILE, "r")) == NULL ) + { + fprintf( stderr, "FAILED opening the company data file '%s'.\n", + BB_CODATA_FILE); + return BB_FAILURE; + } + + ip_count = ip_index = 0; + } + + while ( done != TRUE ) + { + do + { + if ( fgets( line, BB_MAX_LINE_LEN, file) == NULL ) + { + return BB_END_OF_FILE; + } + } + while ( line[0] == BB_COMMENT_DESIGNATOR ); + + switch ( line[BB_DES_CHAR] ) + { + case BB_IP_DESIGNATOR: + bb_get_ip_lines( &line[BB_DES_START], + &ip_count, &ip_index); + break; + case BB_CO_DESIGNATOR: + line[strlen(line)-1] = NUL; + strncpy( p_codata->company, &line[BB_DES_START], + BB_COMPANY_NAME_LEN); + break; + case BB_IMP_DESIGNATOR: + line[strlen(line)-1] = NUL; + strncpy( p_codata->imp, &line[BB_DES_START], + BB_IMP_NAME_LEN); + break; + case BB_ID_DESIGNATOR: + line[strlen(line)-1] = NUL; + strncpy( p_codata->id, &line[BB_DES_START], + BB_ID_NAME_LEN); + break; + case BB_BOOTH_DESIGNATOR: + p_codata->booth = atoi( &line[BB_DES_START]); + break; + case BB_FLAGS_DESIGNATOR: + p_codata->flags = atoi( &line[BB_DES_START]); + break; + case BB_END_DESIGNATOR: + done = TRUE; + break; + default : + if ( line[0] != '\n' ) + { + fprintf( stderr, "ERROR: Invalid field designator '%s'.\n", + line); + } + break; + } + } + p_codata->ip_cnt = ip_count; + p_codata->ip_idx = ip_index; + + return BB_SUCCESS; +} + diff --git a/usr/src/sys/tests/nfs/billboard/src/bb_grid.c b/usr/src/sys/tests/nfs/billboard/src/bb_grid.c new file mode 100644 index 0000000000..cda63627a3 --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/bb_grid.c @@ -0,0 +1,44 @@ +/* + ****************************************************************************** + * + * Module: bb_grid.c + * + * Functions: + * bb_grid_1() - Return the information on successful testing. + * + * + ****************************************************************************** + */ + +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" +#include "server.h" + + + +/************************************************************************* +** ** +** bb_grid_1() - Return a list of all of the test results. This is ** +** just an indication of how the tests are coming in general, no info ** +** on which companies have done what tests will be revield. ** +** ** +*************************************************************************/ +BB_grid * +bb_grid_1() +{ + static BB_grid grid; /* The output grid structure. */ + + /* + ** XXXX-This will be filled in later. + */ + grid.status == BB_SUCCESS; + + return &grid; +} diff --git a/usr/src/sys/tests/nfs/billboard/src/bb_hash.c b/usr/src/sys/tests/nfs/billboard/src/bb_hash.c new file mode 100644 index 0000000000..ebb62420d2 --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/bb_hash.c @@ -0,0 +1,118 @@ +/* + ****************************************************************************** + * + * Module: bb_hash.c + * + * Functions: + * bb_put_hash() - Place an entry in the hash table. + * bb_get_hash() - Return an index from the hash table. + * + * + ****************************************************************************** + */ + +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" +#include "server.h" + +static BB_hash bb_hash; /* The hash table of id, index. */ +static BB_co_data bb_co_d[BB_MAX_IMP]; /* The company data table. */ + +int +bb_put_hash( id, index) + BB_id id; /* The identifier to hash. */ + int index; /* Index of this record in co. data tbl.*/ +{ + int i; /* Nice loop variable name. */ + int hash_idx = 0; /* Index into hash table. */ + int term_idx; /* Termination index of circular search.*/ + + /* + ** Sum up all of the characters in the id and mod it by the + ** hash list size. This is the initial hash index. + */ + for( i = 0; (id[i] != NUL) && (i < BB_ID_NAME_LEN); i++) + { + hash_idx += id[i]; + } + hash_idx = term_idx = (hash_idx % BB_MAX_HASH); + + /* + ** Search the table for the first open hash bucket. If the hash + ** table does not contain one break at the termination index. + */ + while( bb_hash[hash_idx].id_ptr != NULL ) + { + hash_idx = ((hash_idx + 1) % BB_MAX_HASH); + if ( hash_idx == term_idx ) + break; + } + + /* + ** If the hash bucket is empty then install the info here. + ** Otherwise the table is full. + */ + if ( bb_hash[hash_idx].id_ptr == NULL ) + { + bb_hash[hash_idx].index = index; + bb_hash[hash_idx].id_ptr = id; + return BB_SUCCESS; + } + else + { + return BB_HASH_TABLE_FULL; + } +} + +int +bb_get_hash( id) + BB_id id; /* The identifier to hash. */ +{ + int i; /* Nice loop variable name. */ + int hash_idx = 0; /* Index into hash table. */ + int term_idx; /* Termination index of circular search.*/ + + /* + ** Sum up all of the characters in the id and mod it by the + ** hash list size. This is the initial hash index. + */ + for( i = 0; (id[i] != NUL) && (i < BB_ID_NAME_LEN); i++) + { + hash_idx += id[i]; + } + hash_idx = term_idx = (hash_idx % BB_MAX_HASH); + + /* + ** Search the hash table based upon the initial index. The search + ** ends when the index is found or one complete cycle of the hash + ** table has been done. This is linear resolution. + */ + while( ( bb_hash[hash_idx].id_ptr != NULL ) && + ( strncmp( bb_hash[hash_idx].id_ptr, id, BB_ID_NAME_LEN) != 0 ) ) + { + hash_idx = ((hash_idx + 1) % BB_MAX_HASH); + if ( hash_idx == term_idx ) + break; + } + + /* + ** If the id is equal to that of the hash bucket then a match is + ** found. Otherwise the table does not contain this id. + */ + if ( ( bb_hash[hash_idx].id_ptr != NUL ) && + ( strncmp( bb_hash[hash_idx].id_ptr, id, BB_ID_NAME_LEN) == 0 ) ) + { + return bb_hash[hash_idx].index; + } + else + { + return BB_HASH_ID_NOT_FOUND; + } +} diff --git a/usr/src/sys/tests/nfs/billboard/src/bb_ip.c b/usr/src/sys/tests/nfs/billboard/src/bb_ip.c new file mode 100644 index 0000000000..7839051aec --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/bb_ip.c @@ -0,0 +1,122 @@ +/* + ****************************************************************************** + * + * Module: bb_ip.c + * + * Functions: + * bb_get_ip_lines() - Interpret a string to contain IP addresses. + * - Place the addresses in the IP array and + * - return the number found and index of first. + * bb_check_ip() - Check if the IP address of the caller is + * - in the IP list of his specified id name. + * + * + ****************************************************************************** + */ + +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" +#include "server.h" + +char *strtok(); +void bb_get_ip(); + + + +/************************************************************************* +** ** +** get_ip_lines() - Interpret the input 'line' to be a list of internet** +** addresses. Place them in the internet table and return the starting** +** index of this block as well as the number of addresses in the block.** +** ** +*************************************************************************/ +BB_ip bb_ips[BB_MAX_IP]; /* IP Address array. */ +int bb_ip_count; /* The number of IP's in array. */ + +void +bb_get_ip_lines( line, p_count, p_index) + char *line; /* The input line of IP address tokens. */ + int *p_count; /* Output number of IP addresses in the block. */ + int *p_index; /* The starting index of the block of IP addrs. */ +{ + char *ip_addr; /* Points to ip address string. */ + + /* + ** The index of this block of ip addresses is equal to the count. + */ + *p_index = bb_ip_count; + *p_count = 0; + + + if ( (ip_addr = strtok( line, BB_IP_SEPARATOR)) == NULL ) + { + fprintf( stderr, "ERROR: Null IP address list in data file.\n"); + } + + do + { + strncpy( bb_ips[bb_ip_count++], ip_addr, BB_IP_ADDR_LEN); + (*p_count)++; + } + while ( (ip_addr = strtok( NULL, BB_IP_SEPARATOR)) != NULL ); + + /* + ** Strtok() leaves the \n on the last IP addres, take it off. + */ + bb_ips[bb_ip_count -1][strlen(bb_ips[bb_ip_count-1])-1] = NUL; +} + + +/************************************************************************* +** ** +** bb_check_ip() - This function checks to see if the client has an ** +** entry in the ip list which matches the ip address of this call. ** +** ** +*************************************************************************/ +int +bb_check_ip( client) + BB_id client; /* The clients identifier. */ +{ + int client_id; /* The index of the client. */ + BB_co_data codata; /* The company data of the client. */ + int i; /* Nice loop variable name. */ + BB_ip ip; /* The ip address of the caller. */ + + /* + ** Get the client's id. + */ + if ( (client_id = bb_get_hash( client)) == BB_HASH_ID_NOT_FOUND ) + { + return BB_BAD_CLIENT; + } + + /* + ** Get the company data of the client. + */ + if ( bb_get_codata( client_id, &codata) != BB_SUCCESS ) + { + return BB_BAD_CLIENT; + } + + /* + ** Get the ip address of the caller and check it agains the + ** clients list of ip addresses. + */ + bb_get_ip( ip); + for( i = codata.ip_idx; i < codata.ip_idx + codata.ip_cnt; i++ ) + { + if ( strncmp( bb_ips[i], ip, BB_IP_ADDR_LEN) == 0 ) + { + return BB_SUCCESS; + } + } + + return BB_FAILURE; +} diff --git a/usr/src/sys/tests/nfs/billboard/src/bb_list.c b/usr/src/sys/tests/nfs/billboard/src/bb_list.c new file mode 100644 index 0000000000..d9bbd91247 --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/bb_list.c @@ -0,0 +1,324 @@ +/* + ****************************************************************************** + * + * Module: bb_list.c + * + * Functions: + * bb_alist_1() - Return list of servers successfully tested against + * bb_blist_1() - Return list of servers unsuccessfully tested against + * bb_clist_1() - Return list of clients successfully tested against + * bb_dlist_1() - Return list of clients unsuccessfully tested against + * + * + ****************************************************************************** + */ + +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" +#include "server.h" + + + +/************************************************************************* +** ** +** bb_alist_1() - Given the identifier get the list of servers this ** +** client has successfully tested against. ** +** ** +*************************************************************************/ +BB_list_out * +bb_alist_1( p_in) + BB_list_in *p_in; /* The list input structure. */ +{ + static BB_list_out result; /* The result of the list operation. */ + int imp_cnt;/* The number of implementations. */ + int i; /* Nice loop variable name. */ + int j; /* The number of vendors found. */ + BB_row list; /* The list of tests in the database. */ + BB_co_data codata; /* The company data returned. */ + BB_vendor vendors[BB_MAX_IMP]; /* Place to store output*/ + + result.status = BB_SUCCESS; + result.data.data_len = 0; + + /* + ** If the machine being used to send this request is not one + ** of the ones owned by this client group then a password must + ** be specified. + */ + if ( bb_check_ip( p_in->id) != BB_SUCCESS ) + { + if ( (result.status=bb_check_passwd( p_in->id, p_in->passwd)) + != BB_SUCCESS ) + { + result.status = BB_BAD_PASSWD; + return &result; + } + } + + /* + ** Passed verification so get the data. + */ + imp_cnt = bb_get_imp_cnt(); + if ( bb_get_servers( p_in->id, list) != BB_SUCCESS ) + { + result.status = BB_FAILURE; + return &result; + } + + /* + ** For each implementation check to see if the tests have + ** been passed and if so get the company data for that index. + */ + j = 0; + for( i = 0; i < imp_cnt; i++ ) + { + if ( list[i] == BB_BOARD_SET ) + { + /* + ** If can't get the company data just skip it. + */ + if ( bb_get_codata( i, &codata) == BB_SUCCESS ) + { + vendors[j].booth = codata.booth; + strncpy( vendors[j].company, codata.company, + BB_COMPANY_NAME_LEN); + strncpy( vendors[j].imp, codata.imp, BB_IMP_NAME_LEN); + strncpy( vendors[j].id, codata.id, BB_ID_NAME_LEN); + j++; + } + } + } + result.data.data_len = j; + result.data.data_val = vendors; + return &result; +} + + +/************************************************************************* +** ** +** bb_blist_1() - Given the identifier get the list of servers this ** +** client has not successfully tested against. ** +** ** +*************************************************************************/ +BB_list_out * +bb_blist_1( p_in) + BB_list_in *p_in; /* The list input structure. */ +{ + static BB_list_out result; /* The result of the list operation. */ + int imp_cnt;/* The number of implementations. */ + int i; /* Nice loop variable name. */ + int j; /* The number of vendors found. */ + BB_row list; /* The list of tests in the database. */ + BB_co_data codata; /* The company data returned. */ + BB_vendor vendors[BB_MAX_IMP]; /* Place to store output*/ + + result.status = BB_SUCCESS; + result.data.data_len = 0; + + /* + ** If the machine being used to send this request is not one + ** of the ones owned by this client group then a password must + ** be specified. + */ + if ( bb_check_ip( p_in->id) != BB_SUCCESS ) + { + if ( (result.status=bb_check_passwd( p_in->id, p_in->passwd)) + != BB_SUCCESS ) + { + return &result; + } + } + + /* + ** Passed verification so get the data. + */ + imp_cnt = bb_get_imp_cnt(); + if ( bb_get_servers( p_in->id, list) != BB_SUCCESS ) + { + result.status = BB_FAILURE; + return &result; + } + + /* + ** For each implementation check to see if the tests have + ** been passed and if so get the company data for that index. + */ + j = 0; + for( i = 0; i < imp_cnt; i++ ) + { + if ( list[i] == BB_BOARD_UNSET ) + { + /* + ** If can't get the company data just skip it. + */ + if ( bb_get_codata( i, &codata) == BB_SUCCESS ) + { + vendors[j].booth = codata.booth; + strncpy( vendors[j].company, codata.company, + BB_COMPANY_NAME_LEN); + strncpy( vendors[j].imp, codata.imp, BB_IMP_NAME_LEN); + strncpy( vendors[j].id, codata.id, BB_ID_NAME_LEN); + j++; + } + } + } + result.data.data_len = j; + result.data.data_val = vendors; + return &result; +} + + +/************************************************************************* +** ** +** bb_clist_1() - Given the identifier get the list of clients this ** +** server has successfully tested against. ** +** ** +*************************************************************************/ +BB_list_out * +bb_clist_1( p_in) + BB_list_in *p_in; /* The list input structure. */ +{ + static BB_list_out result; /* The result of the list operation. */ + int imp_cnt;/* The number of implementations. */ + int i; /* Nice loop variable name. */ + int j; /* The number of vendors found. */ + BB_row list; /* The list of tests in the database. */ + BB_co_data codata; /* The company data returned. */ + BB_vendor vendors[BB_MAX_IMP]; /* Place to store output*/ + + result.status = BB_SUCCESS; + result.data.data_len = 0; + + /* + ** If the machine being used to send this request is not one + ** of the ones owned by this client group then a password must + ** be specified. + */ + if ( bb_check_ip( p_in->id) != BB_SUCCESS ) + { + if ( (result.status=bb_check_passwd( p_in->id, p_in->passwd)) + != BB_SUCCESS ) + { + return &result; + } + } + + /* + ** Passed verification so get the data. + */ + imp_cnt = bb_get_imp_cnt(); + if ( bb_get_clients( p_in->id, list) != BB_SUCCESS ) + { + result.status = BB_FAILURE; + return &result; + } + + /* + ** For each implementation check to see if the tests have + ** been passed and if so get the company data for that index. + */ + j = 0; + for( i = 0; i < imp_cnt; i++ ) + { + if ( list[i] == BB_BOARD_SET ) + { + /* + ** If can't get the company data just skip it. + */ + if ( bb_get_codata( i, &codata) == BB_SUCCESS ) + { + vendors[j].booth = codata.booth; + strncpy( vendors[j].company, codata.company, + BB_COMPANY_NAME_LEN); + strncpy( vendors[j].imp, codata.imp, BB_IMP_NAME_LEN); + strncpy( vendors[j].id, codata.id, BB_ID_NAME_LEN); + j++; + } + } + } + result.data.data_len = j; + result.data.data_val = vendors; + return &result; +} + + +/************************************************************************* +** ** +** bb_dlist_1() - Given the identifier get the list of clients this ** +** server has not successfully tested against. ** +** ** +*************************************************************************/ +BB_list_out * +bb_dlist_1( p_in) + BB_list_in *p_in; /* The list input structure. */ +{ + static BB_list_out result; /* The result of the list operation. */ + int imp_cnt;/* The number of implementations. */ + int i; /* Nice loop variable name. */ + int j; /* The number of vendors found. */ + BB_row list; /* The list of tests in the database. */ + BB_co_data codata; /* The company data returned. */ + BB_vendor vendors[BB_MAX_IMP]; /* Place to store output*/ + + result.status = BB_SUCCESS; + result.data.data_len = 0; + + /* + ** If the machine being used to send this request is not one + ** of the ones owned by this client group then a password must + ** be specified. + */ + if ( bb_check_ip( p_in->id) != BB_SUCCESS ) + { + if ( (result.status=bb_check_passwd( p_in->id, p_in->passwd)) + != BB_SUCCESS ) + { + return &result; + } + } + + /* + ** Passed verification so get the data. + */ + imp_cnt = bb_get_imp_cnt(); + if ( bb_get_clients( p_in->id, list) != BB_SUCCESS ) + { + result.status = BB_FAILURE; + return &result; + } + + /* + ** For each implementation check to see if the tests have + ** been passed and if so get the company data for that index. + */ + j = 0; + for( i = 0; i < imp_cnt; i++ ) + { + if ( list[i] == BB_BOARD_UNSET ) + { + /* + ** If can't get the company data just skip it. + */ + if ( bb_get_codata( i, &codata) == BB_SUCCESS ) + { + vendors[j].booth = codata.booth; + strncpy( vendors[j].company, codata.company, + BB_COMPANY_NAME_LEN); + strncpy( vendors[j].imp, codata.imp, BB_IMP_NAME_LEN); + strncpy( vendors[j].id, codata.id, BB_ID_NAME_LEN); + j++; + } + } + } + result.data.data_len = j; + result.data.data_val = vendors; + return &result; +} + diff --git a/usr/src/sys/tests/nfs/billboard/src/bb_passwd.c b/usr/src/sys/tests/nfs/billboard/src/bb_passwd.c new file mode 100644 index 0000000000..297e801627 --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/bb_passwd.c @@ -0,0 +1,225 @@ +/* + ****************************************************************************** + * + * Module: bb_passwd.c + * + * Functions: + * bb_read_passwords() - Read or create the password file. + * bb_check_passwd() - Check a password against the passwd list. + * bb_passwd_set_1() - Set a password in the passwd list. + * bb_passwd_update() - Update the password list on disk. + * + * + ****************************************************************************** + */ + +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" +#include "server.h" + + +/************************************************************************* +** ** +** bb_read_passwords() - If the password file exists read it and store ** +** each line in the password array. If it does not exist then create ** +** it and fill in a blank entry for each implementation. ** +** ** +*************************************************************************/ +BB_passwd passwds[BB_MAX_IMP]; /* The password array. */ + +int +bb_read_passwords() +{ + FILE *passwd_file; /* Pointer to the passwd file. */ + int i = 0; /* Index into passwd array. */ + int num_imps; /* The number of implementations*/ + BB_passwd empty_pass; /* An empty password record. */ + + num_imps = bb_get_imp_cnt(); + + /* + ** If the file exists read it into the password array. + */ + if ( (passwd_file = fopen( BB_PASSWD_FILE, "r")) != NULL ) + { + while ( fread( passwds[i], BB_PASSWD_LEN, 1, passwd_file) != 0 ) + { + passwds[i][BB_PASSWD_LEN-1] = NULL; + i++; + if ( i > num_imps ) + { + fprintf( stderr, "ERROR: Too many passwords in file.\n"); + fclose( passwd_file); + return BB_FAILURE; + } + } + + fclose( passwd_file); + return BB_SUCCESS; + } + + /* + ** The file did not exist so create it. + */ + if ( (passwd_file = fopen( BB_PASSWD_FILE, "w")) == NULL ) + { + fprintf( stderr, "FAILED opening the password data file '%s'.\n", + BB_PASSWD_FILE); + fclose( passwd_file); + return BB_FAILURE; + } + + /* + ** Fill the file with empty passwords. + */ + memset( empty_pass, NUL, BB_PASSWD_LEN); + for( i = 0; i < num_imps; i++ ) + { + if ( fwrite( empty_pass, BB_PASSWD_LEN, 1, passwd_file) != 1 ) + { + fprintf( stderr, "ERROR: Could not create password file.\n"); + fclose( passwd_file); + return BB_FAILURE; + } + memset( passwds[i], NUL, BB_PASSWD_LEN); + } + + fclose( passwd_file); + return BB_SUCCESS; +} + + + +/************************************************************************* +** ** +** bb_check_passwd() - Check to see if the password matches the id. ** +** ** +*************************************************************************/ +int +bb_check_passwd( id, passwd) + BB_id id; /* The identifier of the passwd owner. */ + BB_passwd passwd; /* The password to verify. */ +{ + int index; /* The index of the identifier. */ + + if ( (index = bb_get_hash( id)) == BB_HASH_ID_NOT_FOUND ) + { + return BB_BAD_CLIENT; + } + + /* + ** If no password exists return success. + */ + if ( passwds[index][0] == NUL ) + return BB_SUCCESS; + + if ( strncmp( passwd, passwds[index], BB_PASSWD_LEN) != 0 ) + { + return BB_BAD_PASSWD; + } + + return BB_SUCCESS; +} + + + +/************************************************************************* +** ** +** bb_passwd_set_1() - Set the password for the client in the database.** +** check to make sure the old password is correct first. ** +** ** +*************************************************************************/ +int * +bb_passwd_set_1( p_passwd) + BB_passwd_in *p_passwd; /* The passwd_in structure. */ +{ + static int result; /* The result of the set operation. */ + int index; /* The index of the identifier. */ + + /* + ** bb_check_passwd() returns the reason for failure, so use that + ** as the result of this function call. + */ + if ( (result = bb_check_passwd( p_passwd->client, p_passwd->old)) + != BB_SUCCESS ) + { + return &result; + } + + if ( (index = bb_get_hash( p_passwd->client)) == BB_HASH_ID_NOT_FOUND ) + { + result = BB_BAD_CLIENT; + return &result; + } + + /* + ** Copy the password to the data structure and update the data file. + */ + strncpy( passwds[index], p_passwd->new, BB_PASSWD_LEN); + result = bb_passwd_update( index); + return &result; +} + + + +/************************************************************************* +** ** +** bb_passwd_update() - Write the password which has changed out to ** +** password data file. ** +** ** +*************************************************************************/ +int +bb_passwd_update( index) + int index; /* The index of the changed password. */ +{ + int num_imps; /* The number of implementations. */ + FILE *passwd_file; /* Pointer to the passwd file. */ + long seek_to; /* The position to seek to in the file. */ + + num_imps = bb_get_imp_cnt(); + + if ( index >= num_imps ) + { + return BB_FAILURE; + } + + /* + ** The password that we want to write is at location index + ** passwords into the file. Multiply index by the size of + ** a password and that is the offset. + */ + seek_to = index * BB_PASSWD_LEN; + + /* + ** Open the password file. + */ + if ( (passwd_file = fopen( BB_PASSWD_FILE, "r+")) == NULL ) + { + fprintf( stderr, "ERROR: Could not open password file for update.\n"); + return BB_FAILURE; + } + + if ( fseek( passwd_file, seek_to, 0) != 0 ) + { + fprintf( stderr, "ERROR: Could not seek in password file.\n"); + fclose( passwd_file); + return BB_FAILURE; + } + + if ( fwrite( passwds[index], BB_PASSWD_LEN, 1, passwd_file) != 1 ) + { + fprintf( stderr, "ERROR: Could not update password file.\n"); + fclose( passwd_file); + return BB_FAILURE; + } + + fclose( passwd_file); + return BB_SUCCESS; +} diff --git a/usr/src/sys/tests/nfs/billboard/src/bb_phase.c b/usr/src/sys/tests/nfs/billboard/src/bb_phase.c new file mode 100644 index 0000000000..6d28d228ea --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/bb_phase.c @@ -0,0 +1,242 @@ +/* + ****************************************************************************** + * + * Module: bb_phase.c + * + * Functions: + * bb_read_phases() - Read or create the phases file. + * bb_phase_update() - Update the phases file on disk. + * bb_set_phase() - Add the specified flags to a phase. + * bb_unset_phase() - Remove the specified flags from a phase. + * bb_phase_ok() - Check if the phase is ok to make changes. + * + * + ****************************************************************************** + */ + +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" +#include "server.h" + + +/************************************************************************* +** ** +** bb_read_phases - If the phases file exists read the entries into ** +** the phases array. Otherwise create the file with 0'ed entries. ** +** ** +*************************************************************************/ +BB_phase phases[BB_MAX_IMP]; /* The phases array. */ + +int +bb_read_phases() +{ + FILE *phase_file; /* Pointer to the phase file. */ + int i = 0; /* Index into phase array. */ + int num_imps; /* The number of implementations*/ + char line[BB_MAX_LINE_LEN]; /* Space for the input line. */ + + num_imps = bb_get_imp_cnt(); + + /* + ** If the file exists read it into the phase array. + */ + if ( (phase_file = fopen( BB_PHASE_FILE, "r")) != NULL ) + { + for ( i = 0; i < num_imps; i++ ) + { + if ( (phases[i] = getw( phase_file)) == (u_char)EOF ) + { + fprintf( stderr, "ERROR: Phase data file incomplete.\n"); + return BB_FAILURE; + } + } + + fclose( phase_file); + return BB_SUCCESS; + } + + /* + ** The file did not exist so create it. + */ + if ( (phase_file = fopen( BB_PHASE_FILE, "w")) == NULL ) + { + fprintf( stderr, "FAILED opening the phase data file '%s'.\n", + BB_PHASE_FILE); + fclose( phase_file); + return BB_FAILURE; + } + + /* + ** Fill the file with zeroed phases. + */ + for( i = 0; i < num_imps; i++ ) + { + if ( putw( (int)BB_BOARD_UNSET, phase_file) == 1 ) + { + fprintf( stderr, "FAILED writting new phase file.\n"); + fclose( phase_file); + return BB_FAILURE; + } + } + + fclose( phase_file); + return BB_SUCCESS; +} + + + +/************************************************************************* +** ** +** bb_phase_update() - The phase of the client has changed and should ** +** be written to disk. ** +** ** +*************************************************************************/ +int +bb_phase_update( client) + int client; /* The client with the change of phase. */ +{ + int num_imps; /* The number of implementations. */ + FILE *phase_file; /* Pointer to the phase file. */ + long seek_to; /* The position to seek to in the file. */ + + num_imps = bb_get_imp_cnt(); + + if ( client >= num_imps ) + { + return BB_FAILURE; + } + + /* + ** The word that we want to write is at the location client + ** integers into the file. Take the client index and multiply + ** that by the size of the integer and that is the offset. + */ + seek_to = client * sizeof(int); + + /* + ** Open the phase file. + */ + if ( (phase_file = fopen( BB_PHASE_FILE, "r+")) == NULL ) + { + fprintf( stderr, "ERROR: Could not open phase file for update.\n"); + return BB_FAILURE; + } + + if ( fseek( phase_file, seek_to, 0) != 0 ) + { + fprintf( stderr, "ERROR: Could not seek in phase file.\n"); + fclose( phase_file); + return BB_FAILURE; + } + + if ( putw( (int)phases[client], phase_file) == 1 ) + { + fprintf( stderr, "ERROR: Could not update phase file.\n"); + fclose( phase_file); + return BB_FAILURE; + } + + fclose( phase_file); + return BB_SUCCESS; +} + + +/************************************************************************* +** ** +** bb_set_phase() - Change the phase of a client. This adds the ** +** flags specified to the phase in the phase list. ** +** ** +*************************************************************************/ +int +bb_set_phase( client, phase) + BB_id client; /* The name of the client to change. */ + int phase; /* The phase to add to the client. */ +{ + int client_id; /* The index of the client. */ + + /* + ** Get the client's id. + */ + if ( (client_id = bb_get_hash( client)) == BB_HASH_ID_NOT_FOUND ) + { + return BB_BAD_CLIENT; + } + + /* + ** Or the bits together to turn them on. The bits are saying OOO WEEE. + */ + phases[client_id] |= phase; + + /* + ** If the phase cannot be written to disk, return an error. + */ + return bb_phase_update( client_id); +} + + +/************************************************************************* +** ** +** bb_unset_phase() - Change the phase of a client. This deletes the ** +** flags specified from the phase in the phase list. ** +** ** +*************************************************************************/ +int +bb_unset_phase( client, phase) + BB_id client; /* The name of the client to change. */ + int phase; /* The phase to add to the client. */ +{ + int client_id; /* The index of the client. */ + + /* + ** Get the client's id. + */ + if ( (client_id = bb_get_hash( client)) == BB_HASH_ID_NOT_FOUND ) + { + return BB_BAD_CLIENT; + } + + /* + ** Or the bits together to turn them on. The bits are saying OOO WEEE. + */ + phases[client_id] &= ~phase; + + /* + ** If the phase cannot be written to disk, return an error. + */ + return bb_phase_update( client_id); +} + + + +/************************************************************************* +** ** +** bb_phase_ok() - Check to see if the phase is ok for the change to ** +** the board that will be made. ** +** ** +*************************************************************************/ +int +bb_phase_ok( client) + BB_id client; /* The client identifier. */ +{ + int client_id; /* The index of the client. */ + + /* + ** Get the client's id. + */ + if ( (client_id = bb_get_hash( client)) == BB_HASH_ID_NOT_FOUND ) + { + return BB_BAD_CLIENT; + } + + if ( phases[client_id] & BB_SUN_PHASE ) + return BB_SUCCESS; + else + return BB_FAILURE; +} diff --git a/usr/src/sys/tests/nfs/billboard/src/bb_set.c b/usr/src/sys/tests/nfs/billboard/src/bb_set.c new file mode 100644 index 0000000000..b769f6f866 --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/bb_set.c @@ -0,0 +1,134 @@ +/* + ****************************************************************************** + * + * Module: bb_set.c + * + * Functions: + * bb_set_1() - Set an entry in the billboard. + * bb_unset_1() - Unset an entry in the billboard. + * + * + ****************************************************************************** + */ + +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" +#include "server.h" + +void bb_board_tag(); + + +/************************************************************************* +** ** +** bb_set_1() - Set a location in the board. This means that the ** +** client has successfully tested his client against the specified ** +** server. A password is required. ** +** ** +*************************************************************************/ +BB_set_out * +bb_set_1( p_set) + BB_set_in *p_set; /* The set_in structure. */ +{ + static BB_set_out result; /* The result of the set operation. */ + + result.status = BB_SUCCESS; + + /* + ** If the machine being used to send this request is not one + ** of the ones owned by this client group then a password must + ** be specified. + */ + if ( bb_check_ip( p_set->client) != BB_SUCCESS ) + { + if ( (result.status=bb_check_passwd( p_set->client, p_set->passwd)) + != BB_SUCCESS ) + { + result.status = BB_BAD_PASSWD; + return &result; + } + } + + /* + ** If the server being verified against is the universal server, + ** then change the phase of the client. + */ + if ( strncmp( BB_SUN_SERVER, p_set->server, BB_ID_NAME_LEN) == 0 ) + { + if ( bb_set_phase( p_set->client, BB_SUN_PHASE) != BB_SUCCESS ) + { + result.status = BB_BAD_PHASE; + return &result; + } + } + + /* + ** If the phase is not correct don't let them change the board. + */ + if ( bb_phase_ok( p_set->client) != BB_SUCCESS ) + { + result.status = BB_BAD_PHASE; + return &result; + } + + /* + ** They are allowed to place a mark in the bill board, so lets do it. + */ + bb_board_tag( p_set, &result, BB_SET); + + return &result; +} + + + +/************************************************************************* +** ** +** bb_unset_1() - Unset a previously set spot in the bill board. ** +** ** +*************************************************************************/ +BB_set_out * +bb_unset_1( p_set) + BB_set_in *p_set; /* The set_in structure. */ +{ + static BB_set_out result; /* The result of the set operation. */ + + /* + ** If the machine being used to send this request is not one + ** of the ones owned by this client group then a password must + ** be specified. + */ + if ( bb_check_ip( p_set->client) != BB_SUCCESS ) + { + if ( bb_check_passwd( p_set->client, p_set->passwd) != SUCCESS ) + { + result.status = BB_BAD_PASSWD; + return &result; + } + } + + /* + ** If the server being unverified is the universal server, + ** then change the phase of the client. + */ + if ( strncmp( BB_SUN_SERVER, p_set->server, BB_ID_NAME_LEN) == 0 ) + { + if ( bb_unset_phase( p_set->client, BB_SUN_PHASE) != BB_SUCCESS ) + { + result.status = BB_BAD_PHASE; + return &result; + } + } + + /* + ** They are allowed to place a mark in the bill board, so lets do it. + */ + bb_board_tag( p_set, &result, BB_UNSET); + + return &result; +} diff --git a/usr/src/sys/tests/nfs/billboard/src/billboard.c b/usr/src/sys/tests/nfs/billboard/src/billboard.c new file mode 100644 index 0000000000..7052b3c3e1 --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/billboard.c @@ -0,0 +1,454 @@ +/* + ****************************************************************************** + * + * Module: billboard.c + * + * Description: billboard.c + * Billboard is an RPC program that handles information about + * testsuites completions. The module here is the user program + * that communicates with the billboard server. This program + * allows user to update and modify information maintained + * by the server. The features supported are (described below + * using the command line options): + * i) -s + * to set test between and + * as successfully tested + * ii) -u + * to set test between and + * as NOT successfully tested + * iii) -a + * to list server implementations that are successfully + * tested against client + * iv) -b + * to list server implementations that are NOT + * successfully tested against client + * v) -c + * to list client implementations that are successfully + * tested against server + * vi) -d + * to list client implementations that are NOT + * successfully tested against server + * vii) -p + * to change the password of the + * implementation + * + * where and is + * identifier of the client and server implementation + * respectively. + * + * This user program also supports interactive interface whereby + * the user is presented with a list of options (same as the + * features described above) to choose from. User will be prompted + * for any additional data. + * + * Functions: + * main(argc, argv) + * _cmd_line_option(argc, argv) + * _interactive_option() + * _bb_get_passwd(bb_passwd_in_p) + * + * + ****************************************************************************** + */ + +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include "common.h" +#include "protocol.h" + + +/* + ****************************************************************************** + * Manifest Constants + ****************************************************************************** + */ +#define _CONTROL_STR_SIZE 5 /* sscanf control string size */ + +/* + ****************************************************************************** + * Macro Definitions + ****************************************************************************** + */ +/* print error messages */ +#define PRINT_ERROR() { fprintf(stderr, _Usage, argv[0]);\ + return(1); \ + } + + +/* + ****************************************************************************** + * Module Local Definitions + ****************************************************************************** + */ +/* usage message */ +char *_Usage= +"Usage: %s [-s|-u client_idenitfier server_identifier]\n\ + [-a|-b client_idenitfier]\n\ + [-c|-d server_identifier]\n\ + [-p identifier]\n"; + +/* + *randomly picked salt key for password encryption + * This may be modified if other algorithm is preferred + */ +char *_bb_salt= "kR"; + +/* + ****************************************************************************** + * External Declarations + ****************************************************************************** + */ +extern char *optarg; +extern int optind; + + +/* + ****************************************************************************** + * Function Declarations + ****************************************************************************** + */ +int main(); +static int _cmd_line_option(); +static void _interactive_option(); +static int _bb_get_passwd(); + + +/* + ****************************************************************************** + * + * Function: main + * + * Description: + * Invokes modules to handle command line interface or + * interactive according to the user invocation. + * + * Input: + * argc + * argv + * + * Output: + * Output goes to stdout, error goes to stderr. + * + * Returns: + * 1 -- operation failed + * 0 -- operation succeeded. + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +int +main(argc, argv) +int argc; +char *argv[]; +{ + if (argc > 1) + return(_cmd_line_option(argc, argv)); + else + _interactive_option(); + + exit(0); +} + +/* + ****************************************************************************** + * + * Function: _cmd_line_option + * + * Description: + * Parses command line input and perform the requested + * operation accordingly. + * + * Input: + * argc + * argv + * + * Output: + * Output goes to stdout, error goes to stderr. + * + * Returns: + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +static int +_cmd_line_option(argc, argv) +int argc; +char *argv[]; +{ +int option; +BB_set_in bb_set_in; +BB_list_in bb_list_in; +BB_passwd_in bb_passwd_in; + + /* initialise termination of string buffers */ + bb_set_in.client[BB_ID_NAME_LEN-1]= bb_set_in.server[BB_ID_NAME_LEN-1] + = '\0'; + bb_list_in.id[BB_ID_NAME_LEN-1]= '\0'; + + /* + * parses the command line input, and make the remote procedure call + */ + if ((option= getopt(argc, argv, "s:u:a:b:c:d:p:")) != -1) { + switch (option) { + /* + * gets client and server identifier and + * calls bb_call_set_unset to handle the + * remote procedure call + */ + case 's': strncpy(bb_set_in.client, optarg, + BB_ID_NAME_LEN-1); + strncpy(bb_set_in.server, argv[optind], + BB_ID_NAME_LEN-1); + bb_call_set_unset(BB_SET, &bb_set_in); + break; + + case 'u': strncpy(bb_set_in.client, optarg, + BB_ID_NAME_LEN-1); + strncpy(bb_set_in.server, argv[optind], + BB_ID_NAME_LEN-1); + bb_call_set_unset(BB_UNSET, &bb_set_in); + break; + + /* + * gets client or server identifier and + * calls bb_list to handle the remote procedure + * call + */ + case 'a': strncpy(bb_list_in.id, optarg, + BB_ID_NAME_LEN-1); + bb_list(BB_ALIST, &bb_list_in); + break; + + case 'b': strncpy(bb_list_in.id, optarg, + BB_ID_NAME_LEN-1); + bb_list(BB_BLIST, &bb_list_in); + break; + + case 'c': strncpy(bb_list_in.id, optarg, + BB_ID_NAME_LEN-1); + bb_list(BB_CLIST, &bb_list_in); + break; + + case 'd': strncpy(bb_list_in.id, optarg, + BB_ID_NAME_LEN-1); + bb_list(BB_DLIST, &bb_list_in); + break; + + /* to change password */ + case 'p': + strncpy(bb_passwd_in.client, optarg, + BB_ID_NAME_LEN-1); + if (_bb_get_passwd(&bb_passwd_in) == TRUE) + bb_change_passwd(&bb_passwd_in); + break; + + case '?': PRINT_ERROR(); + } + + } else + PRINT_ERROR(); + + return(0); +} + +/* + ****************************************************************************** + * + * Function: _interactive_option + * + * Description: + * Handles the interactive interface. Promt user for inforamtion and + * performs the operation selected by the user. + * + * Input: + * + * Output: + * Output goes to stdout, error goes to stderr. + * + * Returns: + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +static void +_interactive_option() +{ +int option= 0; +BB_id client_id; +BB_id server_id; +char buffer[BB_MAX_LINE_LEN]; +char control_str[_CONTROL_STR_SIZE]; + +BB_set_in bb_set_in; +BB_list_in bb_list_in; +BB_passwd_in bb_passwd_in; + + /* terminate the string buffers */ + bb_set_in.client[BB_ID_NAME_LEN-1]= bb_set_in.server[BB_ID_NAME_LEN-1] + = '\0'; + bb_list_in.id[BB_ID_NAME_LEN-1]= '\0'; + + sprintf(control_str, "%%%ds", BB_ID_NAME_LEN-1); + + /* + * requests for user input, and call the remote procedure to + * handle the operation + */ + for (;;) { + /* print user interface options */ + printf("\n\ +Options:\n\ +-------:\n\ +1) set test passed\n\ +2) set test failed\n\ +3) list servers successfully tested against\n\ +4) list servers not tested against\n\ +5) list clients successfully tested against\n\ +6) list clients not tested against\n\ +7) set/change password\n\ +8) exit\n\n"); + + printf("Enter option: "); + gets(buffer); + sscanf(buffer, "%d", &option); + switch (option) { + /* + * gets client and server identifier and + * calls bb_call_set_unset to handle the + * remote procedure call + */ + case 1: + printf("Client Identifier: "); + gets(buffer); + sscanf(buffer, control_str, bb_set_in.client); + printf("Server Identifier: "); + gets(buffer); + sscanf(buffer, control_str, bb_set_in.server); + bb_call_set_unset(BB_SET, &bb_set_in); + break; + + case 2: + printf("Client Identifier: "); + gets(buffer); + sscanf(buffer, control_str, bb_set_in.client); + printf("Server Identifier: "); + gets(buffer); + sscanf(buffer, control_str, bb_set_in.server); + bb_call_set_unset(BB_UNSET, &bb_set_in); + break; + + /* + * gets client or server identifier and + * calls bb_list to handle the remote procedure + * call + */ + case 3: + printf("Client Identifier: "); + gets(buffer); + sscanf(buffer, control_str, bb_list_in.id); + bb_list(BB_ALIST, &bb_list_in); + break; + + case 4: + printf("Client Identifier: "); + gets(buffer); + sscanf(buffer, control_str, bb_list_in.id); + bb_list(BB_BLIST, &bb_list_in); + break; + + case 5: + printf("Server Identifier: "); + gets(buffer); + sscanf(buffer, control_str, bb_list_in.id); + bb_list(BB_CLIST, &bb_list_in); + break; + + case 6: + printf("Server Identifier: "); + gets(buffer); + sscanf(buffer, control_str, bb_list_in.id); + bb_list(BB_DLIST, &bb_list_in); + break; + + /* to change password */ + case 7: + printf("Identifier: "); + gets(buffer); + sscanf(buffer, control_str, bb_passwd_in.client); + if (_bb_get_passwd(&bb_passwd_in) == TRUE) + bb_change_passwd(&bb_passwd_in); + break; + + case 8: return; + + default: + printf("invalid option\n\n"); + break; + } + } +} + +/* + ****************************************************************************** + * + * Function: _bb_get_passwd + * + * Description: + * Prompt for old and new passwords, and verifies the new one. + * Both passwords are then encrypted. + * We use Unix DES with fixed salt key for the password + * encryption for simplicity, you are welcome to use + * your own algorithms. + * + * Input: + * bb_passwd_in_p -- input structure to RPC call + * + * Output: + * + * Returns: + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +static bool_t +_bb_get_passwd(bb_passwd_in_p) +BB_passwd_in *bb_passwd_in_p; +{ +char buffer[BB_MAX_LINE_LEN]; + + /* initialised password buffers */ + memset(bb_passwd_in_p->old, NUL, BB_PASSWD_LEN); + memset(bb_passwd_in_p->new, NUL, BB_PASSWD_LEN); + memset(buffer, NUL, BB_MAX_LINE_LEN); + + /* + * get old and new password, and verify the new password + */ + strncpy(bb_passwd_in_p->old, crypt(getpass("Old password:"), _bb_salt), + BB_PASSWD_LEN-1); + strcpy(buffer, getpass("New password:")); + if (strcmp(buffer, getpass("Retype new password: ")) != 0) { + printf("Mismatch - password unchanged.\n"); + return(FALSE); + } else + strncpy(bb_passwd_in_p->new, crypt(buffer, _bb_salt), + BB_PASSWD_LEN-1); + return(TRUE); +} + diff --git a/usr/src/sys/tests/nfs/billboard/src/billboard_rpc.c b/usr/src/sys/tests/nfs/billboard/src/billboard_rpc.c new file mode 100644 index 0000000000..312f617cbc --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/billboard_rpc.c @@ -0,0 +1,151 @@ +/* + ****************************************************************************** + * + * Module: billboard_rpc.c + * + * Description: billboard_rpc.c + * Conatins routines that handle RPC calls. + * + * Functions: + * bb_call_rpc(func_p, arg_p) + * _get_handle() + * + * Notes: + * + ****************************************************************************** + */ +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" + + +/* + ****************************************************************************** + * Manifest Constants + ****************************************************************************** + */ +#define _SERVER_NAME "BB_SERVER" /* environment variable to + set the billboard server + name */ +#define _SERVER_NAME_LEN 64 + +/* + ****************************************************************************** + * Global Declarations + ****************************************************************************** + */ +CLIENT *client_handle_p; /* request client handle */ +char server_name[_SERVER_NAME_LEN]; /* name of the billboard server */ + +/* + ****************************************************************************** + * Function Declarations + ****************************************************************************** + */ +static CLIENT *_get_handle(); +char *bb_call_rpc(); + +/* + ****************************************************************************** + * + * Function: bb_call_rpc + * + * Description: + * Gets client handle and does the remote procedure call. + * + * Input: + * func_p -- address of remote procedure + * arg_p -- input arguments to the remote procedure + * + * Output: + * + * Returns: + * result of the RPC call + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +char * +bb_call_rpc(func_p, arg_p) +char *(*func_p)(); +char *arg_p; +{ + + /* + * gets client handle + */ + if (client_handle_p == NULL) + client_handle_p= _get_handle(); + + /* + * do the RPC call + */ + return((char *)(*func_p)(arg_p, client_handle_p)); +} + + +/* + ****************************************************************************** + * + * Function: _get_handle + * + * Description: + * Gets client handle for the RPC call. + * The server name may be specified in the environment + * variable BB_SERVER, otherwise, the user will be prompted + * for one. + * + * Input: + * + * Output: + * + * Returns: + * client handle + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +static +CLIENT * +_get_handle() +{ +char *server_p; +char buffer[BB_MAX_LINE_LEN]; +char *getenv(); +CLIENT *cl_handle_p; + + /* + * gets the server name from the environment variable, if not specified + * the user will be prompted + */ + if ((server_p= getenv(_SERVER_NAME)) == NULL) { + printf("Server name: "); + gets(buffer); + sscanf(buffer, "%s", server_name); + } else + strcpy(server_name, server_p); + + /* + * gets a client handle + */ + if ((cl_handle_p= clnt_create(server_name, BILLBOARD_PROG, + BILLBOARD_VERS, "tcp")) == NULL) { + clnt_pcreateerror(server_name); + exit(1); + } + + return(cl_handle_p); +} + diff --git a/usr/src/sys/tests/nfs/billboard/src/billboard_util.c b/usr/src/sys/tests/nfs/billboard/src/billboard_util.c new file mode 100644 index 0000000000..b112309686 --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/billboard_util.c @@ -0,0 +1,529 @@ +/* + ****************************************************************************** + * + * Module: billboard_util.c + * + * Description: billboard_util.c + * Routines that handle the works for each feature. + * + * Functions: + * bb_call_set_unset(flag, bb_set_in_p) + * bb_set_unset_print_result(flag, bb_set_in_p, bb_set_out_p) + * bb_list(flag, bb_list_in_p) + * bb_list_print_result(flag, bb_list_in_p, bb_list_out_p) + * bb_change_passwd(bb_passwd_in_p) + * bb_print_vendor_info(bb_vendor_p) + * + * Notes: + * + ****************************************************************************** + */ +/* + ****************************************************************************** + * Include Files + ****************************************************************************** + */ +#include +#include +#include "common.h" +#include "protocol.h" + +/* + ****************************************************************************** + * Module Local Definitions + ****************************************************************************** + */ + +/* + * local copy of password, saved for interactive use of the tool + * i.e. the password entered when in interactive mode will be used for the + * rest of the interactive session + */ +static BB_passwd _pwbuff; + +/* + ****************************************************************************** + * External Declarations + ****************************************************************************** + */ +extern CLIENT *client_handle_p; +extern char server_name[]; +extern char *_bb_salt; + + +/* + ****************************************************************************** + * Function Declarations + ****************************************************************************** + */ +void bb_set_unset(); +void bb_lists(); +void bb_list_print_result(); +void bb_set_unset_print_result(); +void bb_change_passwd(); +void bb_print_vendor_info(); + + +/* + ****************************************************************************** + * + * Function: bb_call_set_unset + * + * Description: handles the operation to set test failed/passed + * The user request will be sent to the server via RPC, + * if password is needed, the user will be prompted for one and + * the request will be re-sent. + * + * Input: + * flag -- BB_SET or BB_UNSET + * bb_set_in_p -- input bb_set_in structure to RPC call + * + * Output: + * + * Returns: + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +void +bb_call_set_unset(flag, bb_set_in_p) +int flag; +BB_set_in *bb_set_in_p; +{ +BB_set_out *bb_set_out_p; + + /* + * initialise the passowrd buffer, and copy exisiting password if + * exists + */ + memset(bb_set_in_p->passwd, NUL, BB_PASSWD_LEN); + strncpy(bb_set_in_p->passwd, _pwbuff, BB_PASSWD_LEN-1); + + /* + * issue the RPC call + */ + if (flag == BB_SET) + bb_set_out_p= (BB_set_out *) bb_call_rpc(bb_set_1, bb_set_in_p); + else if (flag == BB_UNSET) + bb_set_out_p= (BB_set_out *) bb_call_rpc(bb_unset_1, + bb_set_in_p); + else + return; + + /* + * if NULL is returned, RPC call failed. + */ + if (bb_set_out_p == NULL) { + clnt_perror(client_handle_p, server_name); + return; + } + + /* + * If password is requested, the user is prompted for one and + * the request is re-sent + */ + if (bb_set_out_p->status == BB_BAD_PASSWD) { + /* + * gets password + */ + memset(bb_set_in_p->passwd, NUL, BB_PASSWD_LEN); + strncpy(bb_set_in_p->passwd, + crypt(getpass("Password:"), _bb_salt), BB_PASSWD_LEN-1); + /* + * save the password to be re-used if the tool is in + * interactive mode + */ + strncpy(_pwbuff, bb_set_in_p->passwd, BB_PASSWD_LEN); + if (flag == BB_SET) + bb_set_out_p= (BB_set_out *) bb_call_rpc(bb_set_1, + bb_set_in_p); + else + bb_set_out_p= (BB_set_out *) bb_call_rpc(bb_unset_1, + bb_set_in_p); + + if (bb_set_out_p == NULL) { + clnt_perror(client_handle_p, server_name); + return; + } + + bb_set_unset_print_result(flag, bb_set_in_p, bb_set_out_p); + } else + bb_set_unset_print_result(flag, bb_set_in_p, bb_set_out_p); + + return; +} + + +/* + ****************************************************************************** + * + * Function: bb_set_unset_print_result + * + * Description: print the result of RPC call for set unset of tests + * + * Input: + * flag: BB_SET or BB_UNSET + * bb_set_in_p: input bb_set_in structure to RPC call + * bb_set_out_p: RPC returned bb_set_out structure + * + * Output: + * Output goes to stdout, error goes to stderr. + * + * Returns: + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +void +bb_set_unset_print_result(flag, bb_set_in_p, bb_set_out_p) +int flag; +BB_set_in *bb_set_in_p; +BB_set_out *bb_set_out_p; +{ + + printf("\n"); + switch (bb_set_out_p->status) { + case BB_SUCCESS: + if (flag == BB_SET) + printf("The following client and server implementation is tested succesfully:\n"); + else + printf("The following client and server implementation is set as being untested:\n"); + printf("Client:\n"); + bb_print_vendor_info(&bb_set_out_p->client); + printf("Server:\n"); + bb_print_vendor_info(&bb_set_out_p->server); + break; + case BB_FAILURE: + fprintf(stderr, "Operation failed\.n"); + break; + case BB_BAD_CLIENT: + fprintf(stderr, "Bad client identifier: %s.\n", + bb_set_in_p->client); + break; + case BB_BAD_SERVER: + fprintf(stderr, "Bad server identifier: %s.\n", + bb_set_in_p->server); + break; + case BB_ALREADY_SET: + fprintf(stderr, + "Client %s against server %s has already been set as tested.\n", + bb_set_in_p->client, bb_set_in_p->server); + break; + case BB_ALREADY_UNSET: + fprintf(stderr, + "Client %s against server %s has already been set as untested.\n", + bb_set_in_p->client, bb_set_in_p->server); + break; + + case BB_BAD_PASSWD: + fprintf(stderr, "Bad password.\n"); + break; + + case BB_BAD_PHASE: + fprintf(stderr, "You have to complete testing against a Sun server before proceeding.\n"); + break; + + default: + fprintf(stderr, "Unexpected error code %d.\n", + bb_set_out_p->status); + break; + } + + return; +} + +/* + ****************************************************************************** + * + * Function: bb_list + * + * Description: calls the RPC procedure, and prompted for password if needed. + * + * Input: + * bb_list_in_p -- input bb_list_in structure to RPC call + * + * Output: + * + * Returns: + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +void +bb_list(flag, bb_list_in_p) +int flag; +BB_list_in *bb_list_in_p; +{ +BB_list_out *(*func)(); +BB_list_out *bb_list_out_p; + + /* + * set the RPC procedure + */ + switch (flag) { + case BB_ALIST: + func= bb_alist_1; + break; + case BB_BLIST: + func= bb_blist_1; + break; + case BB_CLIST: + func= bb_clist_1; + break; + case BB_DLIST: + func= bb_dlist_1; + break; + default: + return; + } + + /* + * initialise the password buffer, and copy existing one if exists + */ + memset(bb_list_in_p->passwd, NUL, BB_PASSWD_LEN); + strncpy(bb_list_in_p->passwd, _pwbuff, BB_PASSWD_LEN-1); + + bb_list_out_p= (BB_list_out *) bb_call_rpc(func, bb_list_in_p); + if (bb_list_out_p == NULL) { + clnt_perror(client_handle_p, server_name); + return; + } + + if (bb_list_out_p->status == BB_BAD_PASSWD) { + /* + * password is needed, so get one + */ + memset(bb_list_in_p->passwd, NUL, BB_PASSWD_LEN); + strncpy(bb_list_in_p->passwd, + crypt(getpass("Password:"), _bb_salt), BB_PASSWD_LEN-1); + /* + * save the password to be re-used if the tool is in + * interactive mode + */ + strncpy(_pwbuff, bb_list_in_p->passwd, BB_PASSWD_LEN); + + /* + * issue the RPC call + */ + bb_list_out_p= (BB_list_out *) bb_call_rpc(func, bb_list_in_p); + if (bb_list_out_p == NULL) { + clnt_perror(client_handle_p, server_name); + return; + } + bb_list_print_result(flag, bb_list_in_p, bb_list_out_p); + } else + bb_list_print_result(flag, bb_list_in_p, bb_list_out_p); + + return; +} + +/* + ****************************************************************************** + * + * Function: bb_list_print_result + * + * Description: print result of RPC call to get list of clients or servers. + * + * Input: + * flag -- BB_ALIST, BB_BLIST, BB_CLIST or BB_DLIST + * bb_list_in_p -- input bb_list_in structure to RPC call + * bb_list_out_p -- RPC returned bb_list_out structure + * + * Output: + * Output goes to stdout, error goes to stderr. + * + * Returns: + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +void +bb_list_print_result(flag, bb_list_in_p, bb_list_out_p) +int flag; +BB_list_in *bb_list_in_p; +BB_list_out *bb_list_out_p; +{ +int i; +int data_len; +register BB_vendor *vendor_p; + + printf("\n"); + switch (bb_list_out_p->status) { + case BB_SUCCESS: + + if ((data_len= bb_list_out_p->data.data_len) + > 0) { + switch (flag) { + case BB_ALIST: + printf("List of servers successfully tested against client %s:\n", + bb_list_in_p->id); + break; + case BB_BLIST: + printf("List of servers not tested against client %s:\n", + bb_list_in_p->id); + break; + case BB_CLIST: + printf("List of clients successfully tested against server %s:\n", + bb_list_in_p->id); + break; + case BB_DLIST: + printf("List of clients not tested against server %s:\n", + bb_list_in_p->id); + break; + } + vendor_p= bb_list_out_p->data.data_val; + + for (i= 0; i < data_len; i++) { + printf("%d)\n", i+1); + bb_print_vendor_info(&vendor_p[i]); + } + } else { + switch (flag) { + case BB_ALIST: + printf("No servers successfully tested against client %s.\n", + bb_list_in_p->id); + break; + case BB_BLIST: + printf("All servers are successfully tested against client %s.\n", + bb_list_in_p->id); + break; + case BB_CLIST: + printf("No clients successfully tested against server %s.\n", + bb_list_in_p->id); + break; + case BB_DLIST: + printf("All clients are successfully tested against server %s.\n", + bb_list_in_p->id); + break; + } + } + break; + case BB_FAILURE: + fprintf(stderr, "Operation failed.\n"); + break; + case BB_BAD_CLIENT: + fprintf(stderr, "Bad client identifier: %s.\n", + bb_list_in_p->id); + break; + case BB_BAD_SERVER: + fprintf(stderr, "Bad server identifier: %s.\n", + bb_list_in_p->id); + break; + case BB_BAD_PASSWD: + fprintf(stderr, "Bad password.\n"); + break; + + default: + fprintf(stderr, "Unknown error code %d.\n", + bb_list_out_p->status); + break; + } + + return; +} + + +/* + ****************************************************************************** + * + * Function: bb_change_passwd + * + * Description: handles RPC call to change the password. Make the RPC call + * and prints the status. + * + * Input: + * bb_passwd_in_p -- input bb_passwd_in structure to RPC call + * + * Output: + * Output goes to stdout, error goes to stderr. + * + * Returns: + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +void +bb_change_passwd(bb_passwd_in_p) +BB_passwd_in *bb_passwd_in_p; +{ +int *status_p; + + /* + * issue the RPC call + */ + if ((status_p= (int *)bb_call_rpc(bb_passwd_set_1, bb_passwd_in_p)) + != NULL) { + printf("\n"); + switch (*status_p) { + case BB_SUCCESS: + printf("Password changed\n"); + break; + case BB_FAILURE: + fprintf(stderr, "Operation failed.\n"); + break; + case BB_BAD_CLIENT: + fprintf(stderr, "Bad client identifier: %s.\n", + bb_passwd_in_p->client); + break; + case BB_BAD_PASSWD: + fprintf(stderr, "Bad password.\n"); + break; + default: + fprintf(stderr, "Unexpected error code %d.\n", + *status_p); + break; + } + } else + clnt_perror(client_handle_p, server_name); + + return; +} + +/* + ****************************************************************************** + * + * Function: bb_print_vendor_info + * + * Description: print vendor information from returned RPC call + * + * Input: + * bb_vendor_p -- vendor info + * + * Output: + * prints vendor info on stdout + * + * Returns: + * + * Side Effects: + * + * Notes: + * + ****************************************************************************** + */ +void +bb_print_vendor_info(bb_vendor_p) +BB_vendor *bb_vendor_p; +{ + printf("\tBooth: %d\n", bb_vendor_p->booth); + printf("\tCompany: %s\n", bb_vendor_p->company); + printf("\tImplementation: %s\n", bb_vendor_p->imp); + printf("\tIdentifier: %s\n\n", bb_vendor_p->id); + + return; +} + diff --git a/usr/src/sys/tests/nfs/billboard/src/common.h b/usr/src/sys/tests/nfs/billboard/src/common.h new file mode 100644 index 0000000000..32b93041f1 --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/common.h @@ -0,0 +1,33 @@ +typedef unsigned char uchar; + +/* +** We use the name bool_t to maintain consistency with the RPC headers. +#ifdef bool_t +#undef bool_t +#endif +typedef enum { FALSE = 0, TRUE = 1 } bool_t; +*/ + + +/* +** These are the return code defenitions for the rpc interface calls. +*/ +#define BB_SUCCESS 0 +#define BB_FAILURE (-1) +#define BB_BAD_CLIENT (-2) +#define BB_BAD_SERVER (-3) +#define BB_ALREADY_SET (-4) +#define BB_ALREADY_UNSET (-5) +#define BB_BAD_PASSWD (-6) +#define BB_BAD_PHASE (-7) + +#define NUL '\0' /* The null character. */ + +#define BB_END_OF_FILE (-2) + +#define BB_MAX_LINE_LEN 200 + +#define BB_SYSLOG_UDP_CREATE "Unable to create UDP transport." +#define BB_SYSLOG_SVC_REGISTER "Unable to register the rpc service." +#define BB_SYSLOG_SVC_RUN "The service run routine failed." + diff --git a/usr/src/sys/tests/nfs/billboard/src/protocol.x b/usr/src/sys/tests/nfs/billboard/src/protocol.x new file mode 100644 index 0000000000..3c9cfcd453 --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/protocol.x @@ -0,0 +1,126 @@ + +#ifdef RPC_HDR +%/* +% * WARNING - DO NOT EDIT THIS FILE +% * IT IS GENERATED BY RPCGEN - LOOK AT THE MAKEFILE +% */ +#endif + +#ifdef RPC_XDR +%/* +% * WARNING - DO NOT EDIT THIS FILE +% * IT IS GENERATED BY RPCGEN - LOOK AT THE MAKEFILE +% */ +#endif + +#ifdef RPC_SVC +%/* +% * WARNING - DO NOT EDIT THIS FILE +% * IT IS GENERATED BY RPCGEN - LOOK AT THE MAKEFILE +% */ +#endif + +#ifdef RPC_CLNT +%/* +% * WARNING - DO NOT EDIT THIS FILE +% * IT IS GENERATED BY RPCGEN - LOOK AT THE MAKEFILE +% */ +#endif + + + +/* +** The sizes of data items. +*/ +const BB_MAX_IMP = 200; +const BB_ID_NAME_LEN = 8; +const BB_COMPANY_NAME_LEN = 32; +const BB_IMP_NAME_LEN = 16; +const BB_PASSWD_LEN = 16; + + +/* +** Structure which corresponds to a row of the cthon board. The phase +** variables indicate completion of each of the first two phases. The +** clients variable is an array indicating that this implementation has +** completed the client side testing of the NFS test suite against it's +** "indexed" implementation. +*/ +typedef u_char BB_row[ BB_MAX_IMP]; + +/* +** The connectathon board consists of N X N testing. Each implementation +** of NFS is tested against all others. This implies creation of an +** array of the CTHON_row structures, one for each implementation. +*/ +typedef BB_row BB_board[ BB_MAX_IMP]; + +typedef char BB_id[BB_ID_NAME_LEN]; /* combo of co and implementation */ + +typedef char BB_passwd[BB_PASSWD_LEN]; + +struct BB_vendor +{ + int booth; + char company[BB_COMPANY_NAME_LEN]; + char imp[BB_IMP_NAME_LEN]; + BB_id id; /* combo of co and implementation */ +}; + +struct BB_set_in +{ + BB_id client; + BB_id server; + BB_passwd passwd; +}; + +struct BB_set_out +{ + int status; + BB_vendor client; + BB_vendor server; +}; + +struct BB_passwd_in +{ + BB_id client; + BB_passwd old; + BB_passwd new; +}; + +struct BB_list_in +{ + BB_id id; + BB_passwd passwd; +}; + +struct BB_list_out +{ + int status; + BB_vendor data; +}; + +struct BB_grid +{ + int status; + int row; + int column; + BB_board grid; +}; + +/* +** Prograzm definitions +** The program number PROGNUM is defined during compilation, see the Makefile +**/ +program BILLBOARD_PROG { + version BILLBOARD_VERS { + BB_set_out BB_SET(BB_set_in) = 1; + BB_set_out BB_UNSET(BB_set_in) = 2; + BB_list_out BB_ALIST(BB_list_in) = 3; + BB_list_out BB_BLIST(BB_list_in) = 4; + BB_list_out BB_CLIST(BB_list_in) = 5; + BB_list_out BB_DLIST(BB_list_in) = 6; + int BB_PASSWD_SET(BB_passwd_in) = 7; + BB_grid BB_GRID(void) = 8; + } = 1; +} = PROGNUM; diff --git a/usr/src/sys/tests/nfs/billboard/src/server.h b/usr/src/sys/tests/nfs/billboard/src/server.h new file mode 100644 index 0000000000..268966235a --- /dev/null +++ b/usr/src/sys/tests/nfs/billboard/src/server.h @@ -0,0 +1,69 @@ +/* +** Number of hash buckets, best performance if 2*number entries. +*/ +#define BB_MAX_HASH (2 * BB_MAX_IMP) +#define BB_HASH_TABLE_FULL (-1) +#define BB_HASH_ID_NOT_FOUND (-2) + +/* +** Defines for the names of the data files. +*/ +#define BB_CODATA_FILE "bb_data.company" +#define BB_PASSWD_FILE "bb_data.passwd" +#define BB_PHASE_FILE "bb_data.phases" +#define BB_BOARD_FILE "bb_data.board" + +/* +** Defines for the company data file. +*/ +#define BB_COMMENT_DESIGNATOR '#' +#define BB_IP_DESIGNATOR 'P' +#define BB_CO_DESIGNATOR 'C' +#define BB_IMP_DESIGNATOR 'I' +#define BB_ID_DESIGNATOR 'D' +#define BB_BOOTH_DESIGNATOR 'B' +#define BB_FLAGS_DESIGNATOR 'F' +#define BB_END_DESIGNATOR 'E' +#define BB_DES_CHAR 1 /* Unique of all DESIGN.*/ +#define BB_DES_START 3 /* Start of data in line*/ + +#define BB_IP_SEPARATOR " " +#define BB_IP_ADDR_LEN 16 +#define BB_MAX_IP (2*BB_MAX_IMP) + +#define BB_BOARD_UNSET 0 +#define BB_BOARD_SET 1 + +#define BB_SUN_SERVER "SUN" +#define BB_SUN_PHASE 1 + +/* +** This is a bucket of the hash table used to hash the implementation +** name to an index. +*/ +typedef struct +{ + char *id_ptr; /* ptr to co_data.identifier */ + short index; /* The index assigned this implementation*/ +} BB_bucket; + +/* +** The hash table structure is an array of buckets. We are not worried +** about the space limitations for this project. +*/ +typedef BB_bucket BB_hash[ BB_MAX_HASH]; + +typedef struct +{ + char company[BB_COMPANY_NAME_LEN]; + char imp[BB_IMP_NAME_LEN]; + BB_id id; /* Assigned reference name. */ + int booth; + short flags; /* BB_SERVER, BB_CLIENT, BB_NONE*/ + short ip_cnt; /* # of internet addresses */ + short ip_idx; /* index to ip table. */ +} BB_co_data; + +typedef char BB_ip[BB_IP_ADDR_LEN]; +typedef uchar BB_phase; /* BB_PHASE1, BB_PHASE2 */ + -- 2.20.1