VxWorks API Reference : OS Libraries
remLib - remote command library
rcmd( ) - execute a shell command on a remote machine
rresvport( ) - open a socket with a privileged port bound to it
remCurIdGet( ) - get the current user name and password
remCurIdSet( ) - set the remote user name and password
iam( ) - set the remote user name and password
whoami( ) - display the current remote identity
bindresvport( ) - bind a socket to a privileged IP port
This library provides routines that support remote command functions. The rcmd( ) and rresvport( ) routines use protocols implemented in BSD 4.3; they support remote command execution, and the opening of a socket with a bound privileged port, respectively. For more information, see Unix Network Programming by W. Richard Stevens. This library also includes routines that authorize network file access via netDrv.
To include remLib in a VxWorks image, include the NETWRS_REMLIB configuration component. This component contains one parameter, RSH_STDERR_SETUP_TIMEOUT. Use this parameter to specify how long an rcmd( ) call should wait for a return from its internal call to select( ). Valid values for RSH_STDERR_SETUP_TIMEOUT are 0 (NO_WAIT), -1 (WAIT_FOREVER), or a positive integer from 1 to 2147483647 inclusive. This positive integer specifies the wait in seconds. The default value for RSH_STDERR_SETUP_TIMEOUT is -1 (WAIT_FOREVER).
remLib.h
rcmd( ) - execute a shell command on a remote machine
int rcmd ( char * host, /* host name or inet address */ int remotePort, /* remote port to connect to (rshd) */ char * localUser, /* local user name */ char * remoteUser, /* remote user name */ char * cmd, /* command */ int * fd2p /* if this pointer is non-zero, stderr */ /* socket is opened and socket descriptor is */ /* filled in */ )
This routine uses a remote shell daemon, rshd, to execute a command on a remote system. It is analogous to the BSD rcmd( ) routine.
Internally, this rcmd( ) implementation uses a select( ) call to wait for a response from the rshd daemon. If rcmd( ) receives a response within its timeout, rcmd( ) calls accept( ) and completes by returning a socket descriptor for the data generated on the remote machine.
The default timeout lets the rcmd( ) call wait forever. However, you can change the timeout value using the RSH_STDERR_SETUP_TIMEOUT parameter associated with the NETWRS_REMLIB configuration component.
A socket descriptor if the remote shell daemon accepts, or ERROR if the remote command fails.
S_remLib_RSH_ERROR, S_remLib_RSH_STDERR_SETUP_FAILED
remLib, BSD reference entry for rcmd( )
rresvport( ) - open a socket with a privileged port bound to it
int rresvport ( int * alport /* port number to initially try */ )
This routine opens a socket with a privileged port bound to it. It is analogous to the UNIX routine rresvport( ).
A socket descriptor, or ERROR if either the socket cannot be opened or all ports are in use.
remLib, UNIX BSD 4.3 manual entry for rresvport( )
remCurIdGet( ) - get the current user name and password
void remCurIdGet ( char * user, /* where to return current user name */ char * passwd /* where to return current password */ )
This routine gets the user name and password currently used for remote host access privileges and copies them to user and passwd. Either parameter can be initialized to NULL, and the corresponding item will not be passed.
N/A
remCurIdSet( ) - set the remote user name and password
STATUS remCurIdSet ( char * newUser, /* user name to use on remote */ char * newPasswd /* password to use on remote (NULL = none) */ )
This routine specifies the user name that will have access privileges on the remote machine. The user name must exist in the remote machine's /etc/passwd, and if it has been assigned a password, the password must be specified in newPasswd.
Either parameter can be NULL, and the corresponding item will not be set.
The maximum length of the user name and the password is MAX_IDENTITY_LEN (defined in remLib.h).
A more convenient version of this routine is iam( ), which is intended to be used from the shell.
OK, or ERROR if the name or password is too long.
iam( ) - set the remote user name and password
STATUS iam ( char * newUser, /* user name to use on remote */ char * newPasswd /* password to use on remote (NULL = none) */ )
This routine specifies the user name that will have access privileges on the remote machine. The user name must exist in the remote machine's /etc/passwd, and if it has been assigned a password, the password must be specified in newPasswd.
Either parameter can be NULL, and the corresponding item will not be set.
The maximum length of the user name and the password is MAX_IDENTITY_LEN (defined in remLib.h).
This routine is a more convenient version of remCurIdSet( ) and is intended to be used from the shell.
OK, or ERROR if the call fails.
remLib, whoami( ), remCurIdGet( ), remCurIdSet( )
whoami( ) - display the current remote identity
void whoami (void)
This routine displays the user name currently used for remote machine access. The user name is set with iam( ) or remCurIdSet( ).
N/A
remLib, iam( ), remCurIdGet( ), remCurIdSet( )
bindresvport( ) - bind a socket to a privileged IP port
STATUS bindresvport ( int sd, /* socket to be bound */ struct sockaddr_in * sin /* socket address -- value/result */ )
This routine picks a port number between 600 and 1023 that is not being used by any other programs and binds the socket passed as sd to that port. Privileged IP ports (numbers between and including 0 and 1023) are reserved for privileged programs.
OK, or ERROR if the address family specified in sin is not supported or the call fails.