NeXTSTEP source code.
NeXTSTEP source code dump.
Classes | Macros | Functions | Variables
nmtest.c File Reference
#include "debug.h"
#include "trace.h"
#include "nm_defs.h"
#include <stdio.h>
#include <mach.h>
#include <cthreads.h>
#include <servers/netname.h>
#include <sys/message.h>
#include <msg_type.h>
#include <sys/notify.h>

Classes

struct  ports
 
struct  my_msg
 

Macros

#define readln(p)   while (((getc(p))!='\n') && (!feof(p)))
 
#define NETNAME_NAME   "NEW_NETWORK_NAME_SERVER"
 
#define MAXPORTS   40
 
#define RIGHT_SEND   0x1
 
#define RIGHT_RECEIVE   0x2
 
#define RIGHT_OWNER   0x4
 
#define CHECK_PORT(index, stmt)
 

Functions

void input (char *prompt, char *format, char *var)
 
 fscanf (stdin, format, var)
 
END void nmconnect () kern_return_t kr
 
 if (kr==NETNAME_SUCCESS)
 
END void printmenu () fprintf(stdout
 
 fprintf (stdout, "This programs allows to perform tests on a network server.\n")
 
 fprintf (stdout, "\n")
 
 fprintf (stdout, "Available commands:\n")
 
 fprintf (stdout, " H,?.......Print this message\n")
 
 fprintf (stdout, " C.........(Re)connect to network server\n")
 
 fprintf (stdout, " Ports:\n")
 
 fprintf (stdout, " PA.........Allocate\n")
 
 fprintf (stdout, " PC,PI......Check in <port> <name>\n")
 
 fprintf (stdout, " PO.........Check out <port>\n")
 
 fprintf (stdout, " PL.........Look up <host> <name>\n")
 
 fprintf (stdout, " PD.........Deallocate <port>\n")
 
 fprintf (stdout, " PS.........Print status of all known ports\n")
 
 fprintf (stdout, " Messages:\n")
 
 fprintf (stdout, " MI.........Send IPC <remote-port> <local-port>\n")
 
 fprintf (stdout, " MR.........Send RPC <remote-port> <local-port>\n")
 
 fprintf (stdout, " Rights:\n")
 
 fprintf (stdout, " RS.........Transfer send rights <port> <destination>\n")
 
MSG_TYPE_PORT_RECEIVE MSG_TYPE_PORT_OWNERSHIP fprintf (stdout, " RA.........Transfer all rights <port> <destination>\n")
 
 fprintf (stdout, " Q.........Quit\n")
 
END void printport (char *str, int index)
 
 if (port_index==-1)
 
 RETURN (port_index)
 
END void genericports () char subcmd[2]
 
 input ("Enter Port sub-command: ", "%1s", subcmd)
 
 switch (subcmd[0])
 
 fflush (stdout)
 
END void genericmsg () char subcmd[2]
 
 input ("Enter Message sub-command: ", "%1s", subcmd)
 
 input ("Remote Port: ", "%d",(char *)&remote_port)
 
 input ("Local Port: ", "%d",(char *)&local_port)
 
 CHECK_PORT (remote_port, return)
 
 CHECK_PORT (local_port, return)
 
END void genericrights () char subcmd[2]
 
 input ("Enter Rights sub-command: ", "%1s", subcmd)
 
 input ("Object Port: ", "%d",(char *)&object_port)
 
 input ("Destination Port: ", "%d",(char *)&destination_port)
 
 CHECK_PORT (object_port, return)
 
 CHECK_PORT (destination_port, return)
 
END main (int argc, char **argv)
 
 while (!quit)
 
 fprintf (stdout, "Terminated.\n")
 
 exit (0)
 
END void receive_main () msg_return_t msg_ret
 
 for (;;)
 
END int initialize () int i
 
 init_netname (PORT_NULL)
 
 for (i=0;i< MAXPORTS;i++) ports[i].rights=0
 
 strcpy (ports[0].name,"NULLPORT")
 
 cthread_init ()
 
 cthread_set_name (receive_thread, "receive_main")
 
 cthread_detach (receive_thread)
 
void port_enable (task_self(), task_notify())
 
 RETURN (1)
 

Variables

int last_port = 0
 
struct my_msg send_buff
 
long current_seqnum = 1
 
char rcv_msg [100]
 
int trace_recursion_level = 0
 
int tracing_on = 0
 
 RET
 
 kr = netname_look_up(name_server_port, "", NETNAME_NAME, &network_server_port)
 
 else
 
END void n
 
int port_index
 
char host [100] = '\0'
 
char name [100]
 
port_t new_port
 
int msg_type = msg_type
 
int remote_port
 
int local_port
 
send_buff header msg_simple = TRUE
 
send_buff header msg_size = sizeof(struct my_msg)
 
send_buff header msg_local_port = ports[local_port].port
 
send_buff header msg_remote_port = ports[remote_port].port
 
send_buff header msg_id = current_seqnum
 
send_buff desc msg_type_long_name = MSG_TYPE_INTEGER_32
 
send_buff desc msg_type_long_size = 32
 
send_buff desc msg_type_long_number = 1
 
send_buff desc msg_type_header msg_type_inline = TRUE
 
send_buff desc msg_type_header msg_type_longform = TRUE
 
send_buff desc msg_type_header msg_type_deallocate = FALSE
 
send_buff data = current_seqnum
 
int rights = RIGHT_SEND
 
int rightmask
 
int destination_port
 
int object_port
 
int index
 
struct my_msgrcv_buff
 
notification_tnotify_buff
 
cthread_t receive_thread = cthread_fork(receive_main, 0)
 
ports[0] port = PORT_NULL
 

Macro Definition Documentation

◆ CHECK_PORT

#define CHECK_PORT (   index,
  stmt 
)
Value:
{ \
if ((index < 0) || (index > last_port) || (ports[index].rights == 0)) { \
fprintf(stdout,"Invalid port number: %d\n", index); \
stmt; \
} \
}
int last_port
Definition: nmtest.c:60
int index
Definition: nmtest.c:592
int rights
Definition: nmtest.c:448
#define stdout
Definition: stdio.h:49

◆ MAXPORTS

#define MAXPORTS   40

◆ NETNAME_NAME

#define NETNAME_NAME   "NEW_NETWORK_NAME_SERVER"

◆ readln

#define readln (   p)    while (((getc(p))!='\n') && (!feof(p)))

◆ RIGHT_OWNER

#define RIGHT_OWNER   0x4

◆ RIGHT_RECEIVE

#define RIGHT_RECEIVE   0x2

◆ RIGHT_SEND

#define RIGHT_SEND   0x1

Function Documentation

◆ CHECK_PORT() [1/4]

CHECK_PORT ( destination_port  ,
return   
)

◆ CHECK_PORT() [2/4]

CHECK_PORT ( local_port  ,
return   
)

◆ CHECK_PORT() [3/4]

CHECK_PORT ( object_port  ,
return   
)

◆ CHECK_PORT() [4/4]

CHECK_PORT ( remote_port  ,
return   
)

◆ cthread_detach()

cthread_detach ( receive_thread  )

◆ cthread_init()

cthread_init ( )

◆ cthread_set_name()

cthread_set_name ( receive_thread  ,
"receive_main"   
)

◆ exit()

exit ( )

◆ fflush()

fflush ( stdout  )

◆ for() [1/2]

for ( ;;  )

◆ for() [2/2]

for ( )
pure virtual

◆ fprintf() [1/20]

fprintf ( stdout  ,
" MI.........Send IPC <remote-port> <local-port>\n  
)

◆ fprintf() [2/20]

fprintf ( stdout  ,
" MR.........Send RPC <remote-port> <local-port>\n  
)

◆ fprintf() [3/20]

fprintf ( stdout  ,
" PA.........Allocate\n"   
)

◆ fprintf() [4/20]

fprintf ( stdout  ,
PC,
PI......Check in< port >< name >\n  
)

◆ fprintf() [5/20]

fprintf ( stdout  ,
" PD.........Deallocate <port>\n  
)

◆ fprintf() [6/20]

fprintf ( stdout  ,
" PL.........Look up <host> <name>\n  
)

◆ fprintf() [7/20]

fprintf ( stdout  ,
" PO.........Check out <port>\n  
)

◆ fprintf() [8/20]

fprintf ( stdout  ,
" PS.........Print status of all known ports\n  
)

◆ fprintf() [9/20]

MSG_TYPE_PORT_RECEIVE MSG_TYPE_PORT_OWNERSHIP fprintf ( stdout  ,
" RA.........Transfer all rights <port> <destination>\n  
)

◆ fprintf() [10/20]

fprintf ( stdout  ,
" RS.........Transfer send rights <port> <destination>\n  
)

◆ fprintf() [11/20]

fprintf ( stdout  ,
" C.........(Re)connect to network server\n  
)

◆ fprintf() [12/20]

fprintf ( stdout  ,
H,
?.......Print this message\n  
)

◆ fprintf() [13/20]

fprintf ( stdout  ,
" Q.........Quit\n"   
)

◆ fprintf() [14/20]

fprintf ( stdout  ,
" Messages:\n"   
)

◆ fprintf() [15/20]

fprintf ( stdout  ,
" Ports:\n"   
)

◆ fprintf() [16/20]

fprintf ( stdout  ,
" Rights:\n"   
)

◆ fprintf() [17/20]

fprintf ( stdout  ,
"\n"   
)

◆ fprintf() [18/20]

fprintf ( stdout  ,
"Available commands:\n  
)

◆ fprintf() [19/20]

fprintf ( stdout  ,
"Terminated.\n"   
)

◆ fprintf() [20/20]

fprintf ( stdout  ,
"This programs allows to perform tests on a network server.\n  
)

◆ fscanf()

fscanf ( stdin  ,
format  ,
var   
)

◆ genericmsg()

END void genericmsg ( )

◆ genericports()

END void genericports ( )

◆ genericrights()

END void genericrights ( )

◆ if() [1/2]

if ( kr   = NETNAME_SUCCESS)

◆ if() [2/2]

if ( port_index   = = -1)

◆ init_netname()

init_netname ( PORT_NULL  )

◆ initialize()

END int initialize ( )

◆ input() [1/8]

input ( "Destination Port: "  ,
"%d"  ,
(char *)&  destination_port 
)

◆ input() [2/8]

input ( "Enter Message sub-command: "  ,
"%1s"  ,
subcmd   
)

◆ input() [3/8]

input ( "Enter Port sub-command: "  ,
"%1s"  ,
subcmd   
)

◆ input() [4/8]

input ( "Enter Rights sub-command: "  ,
"%1s"  ,
subcmd   
)

◆ input() [5/8]

input ( "Local Port: "  ,
"%d"  ,
(char *)&  local_port 
)

◆ input() [6/8]

input ( "Object Port: "  ,
"%d"  ,
(char *)&  object_port 
)

◆ input() [7/8]

input ( "Remote Port: "  ,
"%d"  ,
(char *)&  remote_port 
)

◆ input() [8/8]

void input ( char *  prompt,
char *  format,
char *  var 
)

◆ main()

END main ( int  argc,
char **  argv 
)

◆ nmconnect()

nmconnect ( )

◆ port_enable()

void port_enable ( task_self()  ,
task_notify()   
)

◆ printmenu()

END void printmenu ( )

◆ printport()

END void printport ( char *  str,
int  index 
)

◆ receive_main()

END void receive_main ( )

◆ RETURN() [1/2]

RETURN ( )

◆ RETURN() [2/2]

RETURN ( port_index  )

◆ strcpy()

strcpy ( ports.  name[0],
"NULLPORT"   
)

◆ switch()

switch ( subcmd  [0])

◆ while()

while ( quit)

Variable Documentation

◆ current_seqnum

current_seqnum = 1

◆ data

◆ destination_port

int destination_port

◆ else

else
Initial value:
{
"Look up of new network server fails, using old network server, port = %x.\n",
SHLIB port_t name_server_port
Definition: mach_data.c:14
fprintf(stdout, "This programs allows to perform tests on a network server.\n")

◆ host

ports [0] host[0] ( void  ) = '\0'

◆ index

int index

◆ kr

kr = netname_look_up(name_server_port, "", NETNAME_NAME, &network_server_port)

◆ last_port

last_port = 0

◆ local_port

int local_port

◆ msg_id

◆ msg_local_port

send_buff header msg_local_port = ports[local_port].port

◆ msg_remote_port

send_buff header msg_remote_port = ports[remote_port].port

◆ msg_simple

send_buff header msg_simple = TRUE

◆ msg_size

send_buff header msg_size = sizeof(struct my_msg)

◆ msg_type

◆ msg_type_deallocate

send_buff desc msg_type_header msg_type_deallocate = FALSE

◆ msg_type_inline

send_buff desc msg_type_header msg_type_inline = TRUE

◆ msg_type_long_name

msg_buff desc msg_type_long_name = MSG_TYPE_INTEGER_32

◆ msg_type_long_number

send_buff desc msg_type_long_number = 1

◆ msg_type_long_size

msg_buff desc msg_type_long_size = 32

◆ msg_type_longform

send_buff desc msg_type_header msg_type_longform = TRUE

◆ n

END void n

◆ name

char name[100]

◆ new_port

port_t new_port

◆ notify_buff

notification_t* notify_buff

◆ object_port

int object_port

◆ port

ports [0] port = PORT_NULL

◆ port_index

int port_index

◆ rcv_buff

struct my_msg* rcv_buff

◆ rcv_msg

char rcv_msg[100]

◆ receive_thread

receive_thread = cthread_fork(receive_main, 0)

◆ remote_port

int remote_port

◆ RET

RET

◆ rightmask

int rightmask

◆ rights

ports [0] rights = RIGHT_SEND

◆ send_buff

struct my_msg send_buff

◆ trace_recursion_level

int trace_recursion_level = 0

◆ tracing_on

int tracing_on = 0