LLA to DLPI Migration Guide Edition 4 B2355-90138 HP 9000 Networking E0497 Printed in: United States © Copyright 1997 Hewlett-Packard Company.
Legal Notices The information in this document is subject to change without notice. Hewlett-Packard makes no warranty of any kind with regard to this manual, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. Hewlett-Packard shall not be held liable for errors contained herein or direct, indirect, special, incidental or consequential damages in connection with the furnishing, performance, or use of this material. Warranty.
©copyright 1980, 1984, 1986 Novell, Inc. ©copyright 1986-1992 Sun Microsystems, Inc. ©copyright 1985-86, 1988 Massachusetts Institute of Technology. ©copyright 1989-93 The Open Software Foundation, Inc. ©copyright 1986 Digital Equipment Corporation. ©copyright 1990 Motorola, Inc.
Contents 1. LLA to DLPI Migration Device Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 ioctl Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 Transmitting Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16 Receiving Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 2.
Contents 6
Printing History The manual printing date and part number indicate its current edition. The printing date will change when a new edition is printed. Minor changes may be made at reprint without changing the printing date. the manual part number will change when extensive changes are made. Manual updates may be issued between editions to correct errors or document product changes. To ensure that you receive the updated or new editions, you should subscribe to the appropriate product support service.
Preface Link Level Access for the HP 9000 (LLA/9000) is a Hewlett-Packard data communications and data management product supported on earlier HP-UX releases. The Data Link Provider Interface (DLPI) is an industry standard which defines a STREAMS-based interface to the Logical Link Control (LLC) 802.3 services. The LLA to DLPI Migration Guide provides information about migrating LLA programs to DLPI programs.
1 LLA to DLPI Migration 11
LLA to DLPI Migration As part of Hewlett-Packard’s movement toward industry standard networking, HP has discontinued the LLA/9000 product with the HP-UX 10.30 release. HP recommends that you migrate all existing applications that use LLA to the industry standard Data Link Provider Interface (DLPI). HP provides DLPI with the LAN/9000 product. Before you begin the process of migrating your application, you may need to review the DLPI Programmer’s Guide.
LLA to DLPI Migration Device Files Device Files Device files are used to identify the LAN driver, Ethernet/IEEE 802.3 interface card, and protocol to be used. Each LAN driver/interface card and protocol combination (Ethernet or IEEE 802.3) is associated with a device file. A network device file is like any other HP-UX device file. When you write to a network device file after opening it, the data goes out on the network, just as when you write to a disk drive device file, the data goes out onto the disk.
LLA to DLPI Migration ioctl Requests ioctl Requests All general control requests (i.e. protocol logging, destination addresses, multicast addresses, etc.) for LLA are issued via the ioctl system call. The HP-UX ioctl call is used to construct, inspect, and control the network environment in which an LLA application will operate. All LLA applications must use the ioctl call to configure source and destination addresses before data can be sent or received using the HP-UX read and write calls.
LLA to DLPI Migration ioctl Requests LLA ioctl (req type) DLPI Primitive LOG_READ_TIMEOUT Not defined LLA_SIGNAL_MASK Not defined FRAME_HEADER Frame headers are delivered with each individual packet via the control portion of the message. LOCAL_ADDRESS DL_PHYS_ADDR_REQ DEVICE_STATUS DL_HP_HW_STATUS_REQ* MULTICAST_ADDRESSES DL_HP_MULTICAST_LIST_REQ* MULTICAST_ADDR_LIST DL_HP_MULTICAST_LIST_REQ* RESET_STATISTICS DL_HP_RESET_STATS_REQ* READ_STATISTICS DL_GET_STATISTICS_REQ.
LLA to DLPI Migration Transmitting Data Transmitting Data LLA requires the user to log a destination address (LOG_DEST_ADDR) and a destination service access point (LOG_DSAP) prior to sending any data. DLPI requires the user to specify the destination address and destination service access point (dsap) as part of the data transfer request. The combination of destination MAC address and dsap is referred to as the DLSAP address.
LLA to DLPI Migration Receiving Data Receiving Data LLA does not automatically return LLC header information when packets are read by the user. The user is required to issue a separate control request (FRAME_HEADER) to get the LLC header information for the last packet received. DLPI returns the LLC header information in the control portion of each individually received packet (i.e. DL_UNITDATA_IND, DL_XID_IND, DL_TEST_IND, etc).
LLA to DLPI Migration Receiving Data 18 Chapter 1
2 LLA and DLPI Example Programs This chapter contains two example programs.
LLA and DLPI Example Programs The first example shows a data transfer program using DLPI. The second example shows the same type of program using LLA for comparison.
LLA and DLPI Example Programs DLPI Example Program DLPI Example Program /********************************************************************* (C) COPYRIGHT HEWLETT-PACKARD COMPANY 1992. ALL RIGHTS RESERVED.
LLA and DLPI Example Programs DLPI Example Program struct strbuf data_buf = { AREA_SIZE, /* maxlen = AREA_SIZE */ 0, /* len gets filled in for each message */ data_area /* buf = data area */ }; /********************************************************************* get the next message from a stream; get_msg() returns one of the following defines *********************************************************************/ #define GOT_CTRL 1 /* message has only a control part */ #define GOT_DATA 2 /* message has on
LLA and DLPI Example Programs DLPI Example Program /* did we get a control part */ if(ctrl_buf.
LLA and DLPI Example Programs DLPI Example Program data_buf.
LLA and DLPI Example Programs DLPI Example Program int attach() { int fd; /* file descriptor */ int ppa; /* PPA to attach to */ dl_hp_ppa_req_t *ppa_req = (dl_attach_req_t *)ctrl_area; dl_hp_ppa_ack_t *ppa_ack = (dl_hp_ppa_ack_t *)ctrl_area; dl_hp_ppa_info_t *ppa_info; dl_attach_req_t *attach_req = (dl_attach_req_t *)ctrl_area; char *mac_name; /* open the device file */ if((fd = open(”/dev/dlpi”, O_RDWR)) == -1) { printf(”error: open failed, errno = %d\n”, errno); exit(1); } /* find a PPA to attach to; we a
LLA and DLPI Example Programs DLPI Example Program attach_req->dl_ppa = ppa; put_ctrl(fd, sizeof(dl_attach_req_t), 0); get_msg(fd); check_ctrl(DL_OK_ACK); /* return the file descriptor for the stream to the caller */ return(fd); } /********************************************************************* bind to a sap with a specified service mode and max_conind; returns the local DLSAP and its length *********************************************************************/ void bind(fd, sap, max_conind, service_m
LLA and DLPI Example Programs DLPI Example Program dl_subs_bind_req_t *subs_bind_req = (dl_subs_bind_req_t*)ctrl_area; dl_subs_bind_ack_t *subs_bind_ack = (dl_subs_bind_ack_t*)ctrl_area; u_char *dlsap_addr; /* Fill in Subsequent bind req */ subs_bind_req->dl_primitive = DL_SUBS_BIND_REQ; subs_bind_req->dl_subs_sap_offset = DL_SUBS_BIND_REQ_SIZE; subs_bind_req->dl_subs_sap_length = snapsap_len; subs_bind_req->dl_subs_bind_class = subs_bind_class; memcpy((caddr_t)&subs_bind_req[1], snapsap, snapsap_len); /* s
LLA and DLPI Example Programs DLPI Example Program char int *rdlsap; msg_res; msg_res = get_msg(fd); check_ctrl(DL_UNITDATA_IND); if(msg_res != GOT_BOTH) { printf(”error: did not receive data part of message\n”); exit(1); } return(data_buf.
LLA and DLPI Example Programs DLPI Example Program /********************************************************************* main *********************************************************************/ main() { int send_fd, recv_fd; /* file descriptors */ u_char sdlsap[20]; /* sending DLSAP */ u_char rdlsap[20]; /* receiving DLSAP */ int sdlsap_len, rdlsap_len; /* DLSAP lengths */ int i, j, recv_len; /* PART 1 of program. Demonstrate connectionless data transfer with LLC SAP header.
LLA and DLPI Example Programs DLPI Example Program } /* We're finished with PART 1. Now call cleanup to unbind, then detach, then close the device file. */ cleanup(send_fd); cleanup(recv_fd); /* PART 2 of program. Demonstrate connectionless data transfer with LLC SNAP SAP header. */ /* As demonstrated in the first part of this program we must first open the DLPI device file, /dev/dlpi, and attach to a PPA.
LLA and DLPI Example Programs DLPI Example Program data_area[0] = i; /* Initialize data area */ for (j = 1; j < (i+1)*10; j++) data_area[j] = ”a”; print_dlsap(”sending data to ”,rdlsap, rdlsap_len); send_data(send_fd, rdlsap, rdlsap_len, (i + 1) * 10); /* receive the data packet */ recv_len = recv_data(recv_fd); printf(”received %d bytes, first word = %d\n”, recv_len, data_area[0]); } /* We're finished. Now call cleanup to unbind, then detach, then close the device file.
LLA and DLPI Example Programs LLA Example Program LLA Example Program /*************************************************************************** (C) COPYRIGHT HEWLETT-PACKARD COMPANY 1992. ALL RIGHTS RESERVED.
LLA and DLPI Example Programs LLA Example Program /* * Read a packet from the device.
LLA and DLPI Example Programs LLA Example Program intfd; char *mac_name; /* file descriptor */ /* open the device file */ if((fd = open(”/dev/lan0”, O_RDWR)) == -1) { printf(”error: open failed, errno = %d\n”, errno); exit(1); } /* return the file descriptor for the LLA device to the caller */ return(fd); } /**************************************************************************** Bind to a sap.
LLA and DLPI Example Programs LLA Example Program /* Copy the address to ret_addr */ memcpy(ret_addr, (caddr_t)ctrl_buf.value.s, 6); } /**************************************************************************** Set the destination MAC and SAP address.
LLA and DLPI Example Programs LLA Example Program /**************************************************************************** Close the file descriptor. This will automatically unbind the protocol.
LLA and DLPI Example Programs LLA Example Program int dest_addr_len; int i; /* length of dest_addr */ { printf(”%s”, string); for(i = 0; i < dest_addr_len; i++) { printf(”%02x”, dest_addr[i]); } printf(”\n”); } /**************************************************************************** main ****************************************************************************/ main() { int send_fd, recv_fd; /* file descriptors */ u_char local_addr[20]; /* local MAC address */ int i, j, recv_len; /* PART 1 of p
LLA and DLPI Example Programs LLA Example Program /* Set the destination MAC and SAP address to the local address. This will allow us to send loopback packets. */ set_dst_address(send_fd, local_addr, RECV_SAP, INTEGERTYPE); /* print the MAC and SAP addresses we are sending and receiving on */ local_addr[6] = SEND_SAP; print_dest_addr(”sending too = ”, local_addr, 7); local_addr[6] = RECV_SAP; print_dest_addr(”receiving on = ”, local_addr, 7); /* Time to send some data. We'll send 5 data packets in sequence.
LLA and DLPI Example Programs LLA Example Program /* The following bind is not needed because we are running in loopback mode with only one LAN interface. Since the sending LLA device will use the same SNAP address for sending and receiving we'll just loopback on the same LLA file descriptor. bind_snap(recv_fd, RECV_SNAP_SAP); */ get_local_address(send_fd, local_addr); /* Set the destination MAC and SAP address to the local address. This will allow us to send loopback packets.
LLA and DLPI Example Programs LLA Example Program 40 Chapter 2
Index D DLPI example program, 20 E example programs, 20 L LLA example program, 20 LLA ioctls vs DLPI primitives, 14 LLA migration, 12 M migrating to DLPI, 12 41