Porting From TS-RPC to TI-RPC
The transport-independent RPC (TI-RPC) routines provide the developer with stratified levels of access to the transport layer. The highest-level routines provide complete abstraction from the transport and provide true transport-independence. Lower levels provide access levels similar to the TI-RPC of previous releases.
This section is an informal guide to porting transport-specific RPC (TS-RPC) applications to TI-RPC. Table 6-1 shows the differences between selected routines and their counterparts. For information on porting issues concerning sockets and transport layer interface (TLI), see the Programming Interfaces Guide.
Porting an Application
An application based on either TCP or UDP can run in binary-compatibility mode. For some applications you only recompile and relink all source files. Such applications might use simple RPC calls and use no socket or TCP or UDP specifics.
You might need to edit code and write new code if an application depends on socket semantics or features specific to TCP or UDP. For example, the code might use the format of host addresses or rely on the Berkeley UNIX concept of privileged ports.
Applications that are dependent on the internals of the library or the socket implementation, or applications that depend on specific transport addressing, probably require more effort to port and might require substantial modification.
Benefits of Porting
Some of the benefits of porting are:
Application transport independence means applications operate over more transports than before.
Use of new interfaces makes your application more efficient.
Binary compatibility is less efficient than native mode.
IPv6 Considerations for RPC
IPv6 is the successor of IPv4, the most commonly used layer 2 protocol. IPv6 is also known as IP next generation (IPng). For more information, see System Administration Guide: IP Services.
Both IPv4 and IPv6 are available to users. Applications choose which stack to use when using COTS (connection-oriented transport service). They can choose TCP or CLTS (connectionless transport service).
The following figure illustrates a typical RPC application running over an IPv4 or IPv6 protocol stack.
Figure 6-1 RPC Applications
IPv6 is supported only for TI-RPC applications. TS-RPC does not currently support IPv6. Transport selection in TI-RPC is governed either by the NETPATH environment variable or in /etc/netconfig.
The selection of TCP or UDP instead of IPv4 or IPv6 is dependent on the order in which the corresponding entries appear in /etc/netconfig. Two new entries are associated with IPv6 in /etc/netconfig, and by default they are the first two entries of the file. TI-RPC first tries IPv6. Failing that, it falls back to IPv4. Doing so requires no change in the RPC application itself provided that it doesn't have any knowledge of the transport and is written using the top-level interface.
Porting Issues
libnsl library -- libc no longer includes networking functions. libnsl must be explicitly specified at compile time to link the network services routines.
Old interfaces -- Many old interfaces are supported in the libnsl library, but they work only with TCP or UDP transports. To make full use of new transports, you must use the new interfaces.
Name-to-address mapping -- Transport independence requires opaque addressing. This requirement has implications for applications that interpret addresses.
Differences Between TI-RPC and TS-RPC
The major differences between transport-independent RPC and transport-specific RPC are illustrated in the following table. Also see "Comparison Examples" for code examples comparing TS-RPC with TI-RPC.
Table 6-1 Differences Between TI-RPC and TS-RPC
Function Compatibility Lists
This section lists the RPC library functions and groups them into functional areas. Each section includes lists of functions that are unchanged, have added functionality, and are new to this release.
Note - Functions marked with an asterisk are retained for ease of porting.
Creating and Destroying Services
The following functions are unchanged from the previous releases and are available in the current SunOS release:1
svc_destroy svcfd_create *svc_raw_create *svc_tp_create *svcudp_create *svc_udp_bufcreate svc_create svc_dg_create svc_fd_create svc_raw_create svc_tli_create svc_tp_create svc_vc_create |
Registering and Unregistering Services
The following functions are unchanged from the previous releases and are available in the current SunOS release:
*registerrpc *svc_register *svc_unregister xprt_register xprt_unregister rpc_reg svc_reg svc_unreg |
SunOS Compatibility Calls
The following functions are unchanged from previous releases and are available in the current SunOS release:
*callrpc clnt_call *svc_getcaller - works only with IP-based transports rpc_call svc_getrpccaller |
Broadcasting
The clnt_broadcast call has the same functionality as in previous releases, although it is supported for backward compatibility only.
clnt_broadcast() can broadcast only to the portmap service. It does not support rpcbind.
The rpc_broadcast function broadcasts to both portmap and rpcbind and is also available in the current SunOS release.