/* WS2OSI.H -- Winsock 2 Extensions for OSI protocols
*
* This file contains OSI specific information for use by
* Winsock 2 compabable applications. Include this file below
* WINSOCK.H to enable OSI features in your application.
*
* Rev 0.2, July 28, 1995
*/
#ifndef _WS2OSI_
#define _WS2OSI_
/*
* Protocol values for ISO transport protocols.
*/
#define ISOPROTO_TP_CONS 25 // Transport over CONS
#define ISOPROTO_CLTP_CONS tba // Connectionless Transport
// over CONS
#define ISOPROTO_TP4_CLNS 29 // Transport class 4 over CLNS
#define ISOPROTO_CLTP_CLNS 30 // Connectionless Transport
// over CLNS
#define ISOPROTO_X25 32 // X.25
#define ISOPROTO_X25PVC tba // Permanent Virtual Circuit
#define ISOPROTO_X25SVC ISOPROTO_X25 // Switched Virtual Circuit
#define ISOPROTO_TP ISOPROTO_TP4_CLNS
#define ISOPROTO_CLTP ISOPROTO_CLTP_CLNS
#define ISOPROTO_TP0_TCP tba // Transport class 0 over TCP
// (RFC1006)
/*
* The maximum size of the transport address (tp_addr field of a
* sockaddr_tp structure) is 64. The maximum size of the transport
* address (tp_addr field of a sockaddr_ositp structure) is 126.
*/
#define ISO_MAX_ADDR_LENGTH 64
#define ISO_MAX_EXT_ADDR_LENGTH 126
/*
* There are three types of ISO addresses, hierarchical,
* extended-hierarchical and non-hierarchical. For hierarchical and
* extended-hierarchical, the tp_addr field contains both the
* transport selector and the NSAP. Extended-hierarchical addresses
* also contain a Sub Network address, extended addressing for X.25,
* and an option profile name.
* For non-hierarchical addresses, tp_addr contains only the transport
* address, which must be translated by the ISO TP4 transport provider
* into the transport selector and network address.
*/
#define ISO_HIERARCHICAL 0
#define ISO_NON_HIERARCHICAL 1
#define ISO_EXTENDED_HIERARCHICAL 2
/*
* The format of the address structure (sockaddr) to pass to Windows
* Sockets APIs.
*
*/
typedef struct sockaddr_tp {
u_short tp_family; // Always AF_ISO
u_short tp_addr_type; // ISO_HIERARCHICAL or
// ISO_NON_HIERARCHICAL
u_short tp_taddr_len; // Length of transport address, <= 52
u_short tp_tsel_len; // Length of transport selector, <= 32
// 0 if ISO_NON_HIERARCHICAL
u_char tp_addr[ISO_MAX_ADDR_LENGTH];
} SOCKADDR_TP, *PSOCKADDR_TP, *LPSOCKADDR_TP;
#define ISO_SET_TP_ADDR(sa_tp, port, portlen, node, nodelen) \
(sa_tp)->tp_family = AF_ISO; \
(sa_tp)->tp_addr_type = ISO_HIERARCHICAL; \
(sa_tp)->tp_tsel_len = (portlen); \
(sa_tp)->tp_taddr_len = (portlen) + (nodelen); \
memcpy(&(sa_tp)->tp_addr, (port), (portlen)); \
memcpy(&(sa_tp)->tp_addr[portlen], (node), (nodelen));
typedef struct sockaddr_ositp {
u_short tp_family; // Always AF_ISO
u_short tp_addr_type; // ISO_EXTENDED_HIERARCHICAL
u_short tp_tsel_len; // Length of transport selector, <= 32
u_short tp_nsap_len; // Length of transport address, <= 20
u_short tp_snet_len; // Sub Network address length, <= 18
u_short tp_ext_addr_len; // Extended address length, <= 40
u_short tp_optname_len; // Option profile name length, <= 16
u_char tp_addr[ISO_MAX_EXT_ADDR_LENGTH];
} SOCKADDR_OSITP, *PSOCKADDR_OSITP, *LPSOCKADDR_OSITP;
#define ISO_SET_OSITP_ADDR(sa_tp, tsel, tsellen, nsap, nsaplen, \
snpa, snpalen, extaddr, extaddrlen, \
optname, optnamelen) { \
u_char * paddr; \
(sa_tp)->tp_family = AF_ISO; \
(sa_tp)->tp_addr_type = ISO_EXTENDED_HIERARCHICAL; \
(sa_tp)->tp_tsel_len = (tsellen); \
(sa_tp)->tp_nsap_len = (nsaplen); \
(sa_tp)->tp_snet_len = (snpalen); \
(sa_tp)->tp_ext_addr_len = (extaddrlen); \
(sa_tp)->tp_optname_len = (optnamelen); \
memcpy(&(sa_tp)->tp_addr, (tsel), (tsellen)); \
paddr = &(sa_tp)->tp_addr[tsellen]; \
memcpy(paddr, (nsap), (nsaplen)); \
paddr += (nsaplen); \
memcpy(paddr, (snpa), (snpalen)); \
paddr += (snpalen); \
memcpy(paddr, (extaddr), (extaddrlen)); \
paddr += (extaddrlen); \
memcpy(paddr, (optname), (optnamelen)); \
}
#define ISO_OSITP_ADDR_LEN(sa_tp) \
(sa_tp)->tp_tsel_len + \
(sa_tp)->tp_nsap_len + \
(sa_tp)->tp_snet_len + \
(sa_tp)->tp_ext_addr_len + \
(sa_tp)->tp_optname_len
#endif // _WS2OSI_