Add Book to My BookshelfPurchase This Book Online

Chapter 15 - Networking with TLI

UNIX Systems Programming for SVR4
David A. Curry
 Copyright © 1996 O'Reilly & Associates, Inc.

The netbuf Structure
Because TLI is protocol-independent, the data structures used by its functions are the same, regardless of the network protocol being used. However, at the transport provider interface, there is no standard for data formats, and indeed, different transport providers use different formats. For example, there is no standard for how a host address is to be represented—TCP/IP uses a 32-bit value, but ISO/OSI uses a 160-bit value.
At some point, TLI functions must deal with these different data formats. However, it must be done in such a manner that the functions are not troubled by the differences. In the socket interface described in the last two chapters, this was handled by using a generic struct sockaddr data type, and typecasting the protocol-dependent data structures (struct sockaddr_un, struct sockaddr_in, etc.) to this generic type. In the TLI, it is handled with a struct netbuf structure, defined in the include file tiuser.h:
    struct netbuf {
        unsigned int     maxlen;
        unsigned int     len;
        char            *buf;
    }
The buf element of the structure contains the data (network address, etc.), and the len element indicates the length, in bytes, of buf. For the cases in which a TLI function fills in a buf provided by the user, the maxlen element indicates the size of the buffer, so that the function does not overflow it.
The struct netbuf structure is used throughout the SVR4 TLI library. It is not available in HP-UX 10.x.

Previous SectionNext Section
Books24x7.com, Inc © 2000 –  Feedback