[ Previous | Next | Contents | Home | Search ]
AIX Versions 3.2 and 4 Asynchronous Communications Guide

AIX Programming Interface to the Network Terminal Accelerator

The API allows a host application program access to the user's environment information. The st.ioctl.h file includes the TCGETCINFO and TCGETUENV ioctl operations for the tty driver:

#define BIOC       (`B'<<8) 
#define TCGETCINFO (BIOC|20) /* get network connection info    */
#define TCGETUENV  (BIOC|21) /* get network user environment info */

The information is available from the adapter at any time, so there is no wait to obtain it.

You can use the ci_family field to verify the underlying protocol family. Currently, it is always CIF_INET. If the ci_family field is CIF_INET, the ci_locaddr and ci_remaddr fields are cinaddr structures. Other families would use different address structures.

The ci_service field identifies the service assigned to the connection. A host application can use this field to determine how to handle the session.

The ci_flags field provides some details of the status of the session. The only bit with a defined meaning (although others may be set) is CIF_RECONNECT. This identifies a session that held its network connection across a close-and-open sequence. This allows a host application to handle a reconnect differently than a first-time connect. For example, the host might not allow auto-login for an rlogin protocol reconnect.

The ci_locaddr and ci_remaddr fields provide the local and remote Internet address information for the session. This includes the IP address in the in_addr field and the TCP protocol port in the in_port field.

The following structures show these fields in detail:

/* 
*  Structure for TCGETCINFO. 
*/ 
  
struct cinaddr 
    
  { 
 
  unsigned    long     in_addr;    /*  Internet address        */
  unsigned    short    in_port;    /*  Internet port           */
  unsigned    short    in_res[5];
  };
struct cinfo 
        { 
      unsigned        short   ci_family; /* protocol family */ 
      unsigned        short   ci_service; /* type of service */
      unsigned        short   ci_flags; /* various flags */ 
      unsigned        short   ci_res0[5]; 
      struct          cinaddr ci_locaddr; /*local address info */
      struct  cinaddr ci_remaddr; /* remote address info */ 
      unsigned long   ci_res1[4]; 
      };
/* 
 *  Values for ci_family. 
 */ 
#define CIF_INET         1        /* Internet family */
/* 
 * Values for ci_service. 
 */ 
  
 #define CIS_TELNET      1       /* telnet service ID */ 
 #define CIS_RLOGIN      2       /* rlogin service ID */ 
 #define CIS_NOP         3       /* no-op service ID */
/* 
*  Fields for ci_flags. 
*/ 
 
#define CIF_RECONNECT 0x0080 /* Connection held from previous open  */

The TCGETUENV ioctl information is available from the adapter a short time after the connection is established. The driver delays completion of the operation until that time. The information returned by this operation is used for administration, authentication, and setting the user's initial environment on the local host.

The definition of the operation is as follows:

/* 
* Structure for TCGETUENV operation.
* This operation uses a 512-byte buffer that is structured
* as follows:
* +------+--------+------+-----+------+--------+------+-----+-----+
* | type | length | data | ... | type | length | data | ... | ... |
* +------+--------+------+-----+------+--------+------+-----+-----+
* The length field is the number of bytes in the data field.
* The actual size of the entry might be less than this length.
* For example, the UET_TTYPE entry might have a data length of
* 40 bytes with the data set to "ansi" and the remaining 36 bytes
* set to zero. A type of value zero is used to terminate the list.
*/
 
struct uenv
{
         unsigned        char    ue_type;
         unsigned        char    ue_length;
          char           ue_data[512-2*sizeof(unsigned char)];
};
/*
* Values for ue_type.
*/
 
 define       UET_WINSZ         1 /* winsize structure         */
 #define      UET_TTYPE         2 /* Terminal type             */
 #define      UET_STDERR        3 /* Standard error port ID    */
 #define      UET_REMUSR        4 /* Remote user name          */
 #define      UET_LOCUSR        5 /* Local user name           */
 #define      UET_ISPEED        6 /* Input terminal baud       */
 #define      UET_OSPEED        7 /* Output terminal baud      */
 #define      UET_XDISPLOC      8 /* X display location        */

The host uses the TCGETUENV operation to retrieve the environment information for a channel. This operation returns all of the environment information. Each entry has a two-byte header that specifies the environment type in the first byte and the length of the entry in the second byte. This operation allows a host application access to the remote user's environment. The nop service never has any environment information. The following are the defined environment types:

UET_WINSIZE Contains the binary A_WINSIZE structure in network endian order. This entry is somewhat redundant, since the application gets the window information with the host's TIOCGWINSZ ioctl operation to the tty driver. But this is where the adapter holds the information, so it shows up here.
UET_TTYPE Specifies the ASCII terminal type. For the telnet command, it is the type negotiated using the terminal-type database. For the rlogin command, it is the type received in the initial environment information.
UET_STDERR Specifies the ASCII port number to use for standard error. This is part of the rlogin protocol and is received in the initial environment information, but the rlogin command does not use a separate connection for standard error. If this entry exists, an application would typically reject the rlogin protocol connection.
UET_REMUSR Specifies the ASCII name of the remote user. This entry only exists for rlogin protocol and is the name of the remote user making the request.
UET_LOCUSR Specifies the ASCII name of the local user. This entry only exists for the rlogin command and is the local user name by which the remote user wants to be known.
UET_ISPEED Specifies the ASCII value of the input baud rate.
UET_OSPEED Specifies the ASCII value of the output baud rate.
UET_XDISPLOC Specifies the ASCII name of the X display location for the remote user's X window system. This entry only exists for the telnet command.

[ Previous | Next | Contents | Home | Search ]