Home

HP B2355-90138 User's Manual

image

Contents

1. open the device file if fd open dev dlpi O RDWR 1 printf error open failed rrno dWMn errno exit 1 find a PPA to attach to we assume that the first PPA on the remote is on the same media as the first local PPA x send a PPA REO and wait for the PPA ACK ppa reg gt dl primitive DL HP PPA REO put ctrl fd sizeof dl hp ppa reg t 0 get msg fd check ctrl DL HP PPA ACK make sure we found at least one PPA if ppa ack gt dl length 0 printf error no PPAs available n exit 1 examine the first PPA ppa info dl hp ppa info t u char ctrl area ppa ack gt dl offset ppa ppa info gt dl ppa switch ppa info gt dl mac type case DL CSMACD case DL ETHER mac name break case DL TPR mac name break case DL FDDI mac name FDDI break 3 Ethernet Token Ring default printf error unknown MAC type in ppa_info n exit 1 printf attaching to s media on PPA dWMn mac name ppa fill in ATTACH REQ with the PPA we found send the ATTACH REQ and wait for the OK ACK x attach req dl primitive DL ATTACH REO Chapter 2 25 LLA and DLPI Example P rograms DLPI Example Program attach reg gt dl ppa ppa put ctrl fd sizeof dl attach reg t 0 get msg fd check ctrl DL OK ACK return the file descriptor for the stream
2. 2 37 LLA and DLPI Example P rograms LLA Example Program Set the destination MAC and SAP address to the local address This will allow us to send loopback packets f 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 for i 0 i lt 5 i send i 1 10 data bytes with the first byte i data area 0 i Initialize data area for j 1 j lt i 1 10 j data area j a print dest addr sending data to local addr 7 send data send fd i 1 10 receive the data packet recv len recv data recv fd printf received d bytes first word dWMn recv len u int data area 0 We re finished with PART 1 Now call cleanup to close the device fil X cleanup send fd cleanup recv fa 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 El send_fd attach recv fd attach Bind the send and recv SNAP protocols When binding SNAP over LLA
3. ck ck KA AKA ck ck ck KA AA Ck ck ck KA AA ko Sk ke Sk kv Mk ko ko kokok A int attach Chapter 2 33 LLA and DLPI Example P rograms LLA Example Program intfd file descriptor char mac name open the device file if fd open dev lan0 O RDWR 1 printf error open failed rrno dWn errno exit 1 return the file descriptor for the LLA device to the caller return fd KK kk kk kk kk kk kk kk kk kk kk kk kk k k k A k ck ck ck k kk He Bind to a sap LLA does not automatically return the local MAC address and local sap information when binding a protocol value You must explicitly request the local MAC address via the LOCAL ADDRESS control request KCKCKCKCKCKCKCKCKCKCKCKCkCKCkCKCkCK kk kk k kk kk kk kk kk k K kk kk kA KAZ KA KA KA KA KA KA k Ck k ck k ck KA KA KA kk ke d kk void bind fd sap int fd file descriptor int sap 802 2 SAP to bind on ctrl buf reqtype LOG SSAP ctrl buf vtype INTEGERTYPE ctrl buf value i sap send the LOG SSAP request LLA will return success or failure when the ioctl completes so there is no need to wait for an acknowledgement put ctrl fd NETCTRL kk k k k kk kk kk kk kk kk kk kk k k k k K k K k K K AA AKA K KX KA KA KA KA KA KA KA KA KA k k ck k ck k k k ke kx Get the local MAC address OXCKCKCKCKCKCKCKCKCKCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK
4. int recv data fd int fd file descriptor int length length get_pkt fd if length 0 printf error did not receive any data part Wn exit 1 return length kk kk kk kk kk kk kk kk kk kk kk k k A kk send a data packet assumes data area has already been filled in and a destination address has already been logged KOKCKCKCKCKCKCKCkCKCKCKCkCKCkCKCKCKCKCKCKCK KCKCKCKCKCKCKCKCKCK K KK kA KA AKA KX KA KA KA KA KA KA k Ck k ck k ck KA KA KA k k ke X x void send data fd len int fd file descriptor int len length of the packet to send put data fd len KK kk kk kk kk kk kk kk kk kk kk kk kk kk A k ck k k kkk print a string followed by a destination MAC and SAP address KOKCKCKCKCKCKCKCKCKCkCKCkCKCkCKCKCKCkCKCkCKCKCKCKCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCkCkCKCkCKCkCk KA KA KA kc k k ck k ck KA KA KA k k kk void print dest addr string dest addr dest addr len char string label u char dest addr the destination address 36 Chapter 2 LLA and DLPI Example P rograms LLA Example Program int dest addr len length of dest addr int is printf s string for i 0 i lt dest addr len i printf 02x dest addr i printf Nn KKK KK k kk kk kk kk kk k kk KCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCkCkCkCKCKCKCkCkCk Ck k Ck k ck k ck ck ck k kk main KOKCKCKCKCKCKCKCkCKCkCKCkCKCKCKCKCK KCKC
5. j a print dlsap sending data to local addr 11 send data send fd i 1 10 receive the data packet Since we are sending to the SNAP address we enabled on the send fd we must also receive on this file descriptor recv len recv data send fd printf received d bytes first word dWMn recv len data area 0 We re finished Now call cleanup to then close the device fil x cleanup send fd cleanup recv_fd Chapter 2 39 LLA and DLPI Example P rograms LLA Example Program 40 Chapter 2 Index D DL PI 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
6. the SNAP address will be used as both the sending and receiving protocol address Therefore there is no need to issue a seperate request to log the destination SNAP protocol However we still need to set the destination MAC address El bind_snap send_fd SEND SNAP SAP 38 Chapter 2 LLA and DLPI Example P rograms 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 xf 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 As mention above the SNAP address does not need to be logged it is used here only to distinguish SAPs and SNAP values uu set dst address send fd local addr RECV SNAP SAP 6 print the MAC and SAP addresses we are sending and receiving on memcpy caddr t amp local addr 6 SEND SNAP SAP 5 print dlsap sending too local addr 11 print dlsap receiving on local addr 11 Time to send some data We ll send 5 data packets in sequence for i 0 i lt 5 i send i 1 10 data bytes with the first byte i data area 0 i Initialize data area for j 1 j lt i 1 10 j data area
7. to the caller return fd BRK KK kk k k kk kk kk k kk kk kk kk A ck ck ck ck kk Ok bind to a sap with a specified service mode and max conind returns the local DLSAP and its length KCOKCKCKCKCKCKkCKCKCKCkCKCkCKCkCKCkCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK KCK KCK kCKCkCk k Ck k Ck k ck k ck KA KA KA KA A k ke X k void bind fd sap max conind service mode dlsap dlsap len intfd file descriptor intsap 802 2 SAP to bind on intmax conind max connect indications to accept intservice mode either DL CODLS or DL CLDLS u char dlsap return DLSAP int dlsap len return length of dlsap dl bind reg t bind reg dl bind req t ctrl area al bind ack t bind ack dl bind ack t ctrl area u char dlsap addr fill in the BIND REO bind req dl primitive DL BIND REO bind reg gt dl sap sap bind reg gt dl max conind max conind bind reg gt dl service mode service mode bind reg gt dl conn mgmt 0 conn mgmt is NOT supported bind reg gt dl xidtest flg 0 user handles TEST XID pkts send the BIND REO and wait for the OK ACK put ctrl fd sizeof dl bind req t 0 get msg fd check ctrl DL BIND ACK return the DLSAP to the caller dlsap len bind ack dl addr length dlsap addr u char ctrl area bind ack gt dl addr offset memcpy dlsap dlsap addr dlsap len ROR ICICI III II II III I IKI I II I
8. ve EE Exo Eee ERE Eas 13 VOCE Requests instet Secs Wits ROA ote td ER WENE Ege edat 14 Transmitting Data zes ad Rx ERE eR ER He ee e s 16 Receiving Data dier mii ean plod Ao WR GOD ES DR Sae ng 17 LLA and DLPI Example Programs DLPI Example Program coococcccco ns 21 LLA Example Program nn 32 Contents 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 See your HP sales representative for details First Edition February 1991 Second Edition J ul y 1992 Third Edition J anuary 1995 Fourth Edition April 1997 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 I nterface DLPI is an industry standard which defines a STREAM S based interface to the Logical Link Control LL C 802 3 services TheLLA toDLPI Migration Guideprovides information about migrating LLA programs to DLPI programs This manual is organized as follows Chapter 1 LLA t
9. A for comparison 20 Chapter 2 LLA and DLPI Example P rograms DLPI Example Program DLPI Example Program kk k kk k kk kk k kk kk kk kk KCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCKCkCkCkCKCkCkCKCKCkCkCk Ck k KA k ck k ck ck ck ck ko kk C COPYRIGHT HEWLETT PACKARD COMPANY 1992 ALL RIGHTS RESERVED NO PART OF THIS PROGRAM MAY BE PHOTOCOPIED REPRODUCED OR TRANSLATED TO ANOTHER PROGRAM LANGUAGE WITHOUT THE PRIOR WRITTEN CONSENT OF HEWLETT PACKARD COMPANY KCKCKCKCKCKCKCKCKCKCkCKCkCKCkCKCKCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK KC kCkCkCkCkCkCk Ck k ck k ck k ck KA KA KA A ke e ke X e x Kk k kk kk kk kk kk k kk kk kk KCKCKCKCKCK KCKCKCKCKCKCKCKCKCkCkCKCkCKCkCKCKCKCkCkCkCkCk A kk The main part of this program is composed of two parts The first part demonstrates data transfer over a connectionless stream with LLC SAP headers The second part of this program demonstrates data transfer over a connectionless stream with LLC SNAP headers OKCKCKCKCKCKCKCKCKCkCKCkCKCKCKCkCK XX kk kk kk kk Kk kk K K kk k KC k Ck KA KA KA k ck k ck k ck KA KA ok Kok ke k k e x x include lt stdio h gt include lt fcntl h gt include lt memory h gt include lt sys types h gt include lt sys stream h gt include lt sys stropts h gt include lt sys dlpi h gt include lt sys dlpi ext h gt define SEND SAP 0x80 sending SAP define RECV SAP 0
10. A k kk Send a packet over LLA OXCKCKCKCKCKCKCKCKCkCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCK KCKCKCKCKCKCkCKCkCKCkCkCKCKCkCk KA KA k ck k ck k RARA ck sk sk k k e x x f void put data fd length int ta file descriptor int length length of data message call putmsg and check for an error if write fd data area length lt 0 printf error put data putmsg failed errno d n errno exit 1 KKK kk kk kk kk kk kk kk kk kk Kk kk kk kk k kk kk kk k KA KA KA KA KA KA KA KA KA KA KA KA KA KA k ck Ck ck ck ck kk kk Send a control reguest to the driver KOKCKCKCKCKCKCKCkCKCkCKCkCKCkCKCKCK KCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK KC kCKCkCkCKCKCkCKCkCKCKCKCkCKCk Ck k Ck k ck k ck KA KA KA k k e x x void put ctrl fd cmd int fd file descriptor int cmd NETCTRL or NETSTAT Send control request to driver if ioctl fd cmd amp ctrl buf lt 0 printf error put ctrl putmsg failed errno dWn errno exit 1 OK kk kk kk kk kk kk kk kk kk KCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCkCkCkCKCkCk Ck k ck k ck ck ck k k kk Open an LLA device The device file specifies which device you attaching to There is no need to issue a seperate attach control request to designate which device you are using In this example we will default to dev lan0 ck ck Ck ck ck 0k ck Ck ck ck Ck ck kk KKK ck kA X AA KA X AA AXA ck KA ZA ck ck AA KA ck
11. CKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK KCKCKCkCkCKCKCKCkCkCKCKCkCkCkCkCk ck k ck k ck ck ckck ckok ck k ke x e x u char SEND SNAP SAP 5 0x50 0x00 0x00 0x00 0x00 u char RECV SNAP SAP 5 0x60 0x00 0x00 0x00 0x00 KK kk kk kk kk k kk k kk kk kk kk KCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK A Ck ck Ck ck k k ko global areas for sending and receiving messages KOKCKCKCKCKCKCKCkCKCKCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK KCKCKCKCKCKCKCKCKCKCKCKCKCkCKCKCkCkCkCKCkCkCkCk KA k ck k ck KA KA KA k k ke X x define MAX PKT SIZE 1500 Maximum packet size for Ethernet u long data area MAX PKT SIZE for data messages struct firs ctrl burs BORK kk k kk kk kk kk kk kk kk kk k kk k kk kk k K k K k KCKCKCKCKCKCKCkCKCKCkCKCKCKCkCKCkCKCkCkCkCkCkCkCk Ck k ck k ck k k kk Read a packet on LLA file descriptor fd KOKCKCKCKCKCKCKCkCKCkCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK K KKK KA KA KA KA KA KA k Ck KA k ck k ck k ckck ck ok Kok e sk A e x int get pkt fd int fd file descriptor int recv cnt 32 Chapter 2 LLA and DLPI Example P rograms LLA Example Program Read a packet from the device call read and check for an error if recv cnt read fd data area MAX_PKT_SIZE lt 0 printf error read failed errno dNn errno exit 1 return recv cnt Kk k k kk k kk kk kk kk kk kk kk k kk kk kk
12. CKCKCKCKCKCKCKCKCkCKCKCkCKCKCkCKCKCkCkCk Ck k Ck kc k k ck KA KA KA k k ke x e x void get local address fd ret addr int fd file descriptor caddr tret addr return local address here ctrl buf reqtype LOCAL ADDRESS send the LOCAL ADDRESS request LLA will return success or failure when the ioctl completes so there is no need to wait for an acknowledgement xf put ctrl fd NETSTAT 34 Chapter 2 LLA and DLPI Example P rograms LLA Example Program Copy the address to ret addr memcpy ret addr caddr t ctrl buf value s 6 kk kk k kk k kk kk kk kk kCKCKCKCKCKCKCKCKCK KCKCKCK KCKCKCKCKCKCKCKCKCKCkCKCKCKCKCKCKCKCkCKCKCKCkCkCkCKCkCKCkCkCk Ck k Ck k ck k ck ck ck k kk Set the destination MAC and SAP address KOKCKCKCKCKCKCKCkCKCkCKCkCKCKCKCKCKCkCKCkCK kk kk kk k kk k kk kk k k kA KA KA KA KA KA KA KA KA k Ck kc k k ck KA KA KA k ke e ke X e x void set dst address fd dest addr dsap length int fd file descriptor caddr t dest addr return local address here int dsap destination sap int length destination sap length ctrl buf regtype LOG DEST ADDR ctrl buf vtype 6 memcpy caddr t ctrl buf value s dest addr 6 send the LOG DEST ADDR request LLA will return success or failure when the ioctl completes so there is no need to wait for an acknowledgement s put ctrl fd NETCTRL Only log sap add
13. CKCKCKCKCKCKCKCKCkCk k Ck k Ck k ck k ck k ck KA KA ok Kok ke ke d ke X e x void check ctrl ex prim int ex prim the expected primitive dl error ack t err ack dl error ack t ctrl area did we get th xpected primitive if err ack dl primitive ex prim 22 Chapter 2 did we get a control part if ctrl buf len LLA and DLPI Example Programs DLPI Example Program yup is it an ERROR ACK if err ack gt dl primitive yup format DL ERROR ACK the ERROR ACK info printf error printf got DL xpected primitive 0x 02x ex prim ERROR ACK n printf dl error primitive 0x 02xMn err ack gt dl error primitive printf dl errno 0x 02x n err ack dl errno printf dl unix errno din exit 1 else err ack dl unix errno didn t get an ERROR ACK either print whatever primitive we did get printf error expected primitive 0x 02x ex prim printf got primitive 0x 02x n exit 1 else err ack dl primitive no control did we get data if data buf len tell user we printf error exit 1 else no message only got data check ctrl found only datan well it was probably an interrupted system call k printf error exit 1 BRK RK kk kk kk k k k k K K K A AKA AAA AAA AXA KC
14. Example P rograms LLA Example Program LLA Example Program KK kk kk kk kk kk kk k kk kk kk k kk A Ck ck Ck ck ck ck kk kk C COPYRIGHT HEWLETT PACKARD COMPANY 1992 ALL RIGHTS RESERVED NO PART OF THIS PROGRAM MAY BE PHOTOCOPIED REPRODUCED OR TRANSLATED TO ANOTHER PROGRAM LANGUAGE WITHOUT THE PRIOR WRITTEN CONSENT OF HEWLETT PACKARD COMPANY OXCKCKCKCKCKCKCKCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK KCKCKCKCKCkCkCkCkCkCk Ck KA KA k ck k ck KA KA KA KA sk ok e k e x x kk k k kk kk kk kk k kk kk kk kk kk k kk k k k k K A k kk The main part of this program is composed of two parts The first part demonstrates data transfer over LLA with LLC SAP headers The second part of this program demonstrates data transfer over LLA with LLC SNAP headers KOKCKCKCKCKCKCKCkCKCkCKCkCKCkCKCKCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCkCkCKCkCKCkCkCkCkCkCkCk Ck k ck k ck KA KA KA k sk k kk include lt stdio h gt include fcntl h include lt memory h gt include lt errno h gt include lt sys types h gt include lt sys netio h gt define SEND SAP 0x80 sending SAP define RECV SAP 0x82 receiving SAP define SNAP SAP OxAA SNAP SAP Ok kk k kk k kk kk kk kk kk kk kk kk kk kk k k k KCKCKCKCKCK KCKCKCKCKCkCKCkCkCkCkCkCkCKCkCKCkCkCkCkCk Ck k ck k ck k ck k k kk SNAP protocol values KOXCK
15. II II RR I IR I IO A IA I ok bind to a SNAP sap via the DL PEER BIND or DL HIERARCHICAL BIND subsequent bind class returns the local DLSAP and its length KOKCKCKCKCKCKCKCkCKCkCKCkCKCkCKCkCKCKCKCkCKCKCKCKCKCKCKCKCKCkCKCKCKCKCKCkCKCkCK kCKCkCk k Ck k Ck k ck k ck KA KA KA KA K ke ke e ke X e x x void subs bind fd snapsap snapsap len subs bind class dlsap dlsap len int fd u char snapsap int subs bind class u char dlsap int dlsap len 26 Chapter 2 LLA and DLPI Example P rograms 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 otrl area u char dlsap_addr Fill in Subsequent bind req subs bind req dl primitive DL SUBS BIND REO subs bind req dl subs sap offset DL SUBS BIND REO SIZE subs bind reg gt dl subs sap length snapsap len subs bind reg gt dl subs bind class subs bind class memcpy caddr t amp subs bind req 1 snapsap snapsap len send the SUBS BIND REO and wait for the OK ACK put ctrl fd sizeof dl subs bind req t snapsap len 0 get msg fd check ctrl DL SUBS BIND ACK return the DLSAP to the caller dlsap len subs bind ack dl subs sap length dlsap addr u char ctrl area subs bind ack dl subs sap offset memcpy dlsap dlsap addr dlsap len BRK kk k k kk kk kk kk k kk kk kk kk kk A KA
16. KA Ck ck ck ck k kk kk unbind detach and close KOKCKCKCKCKCKCKCKCKCkCKCKCKCkCKCkCKCkCKCkCK kCKCKCKCKCKCKCKCKCKCKCKCkCKCkCKCk Ck k Ck KA KA k Ck k ck k ck KA KA KA KA k ke e e X e x void cleanup fd int fd file descriptor dl unbind req t unbind req dl unbind req t ctrl area dl detach req t detach reg dl detach req t ctrl area unbind unbind req dl primitive DL UNBIND REO put ctrl fd sizeof dl unbind req t 0 get msg fd check ctrl DL OK ACK detach detach req dl primitive DL DETACH REO put ctrl fd sizeof dl detach reg t 0 get msg fd check ctrl DL OK ACK close close fd KKK KK k kk kk kk kk kk kk kk KK kk k k A ck ck k kk receive a data packet FER RR RAR XX XX XX XX Kk kk Kk Kk k k kk K ARA RARA RARA Ck k ck k ck k ck k RARA Kok sk sk e ke X e x int recv data fd int fd file descriptor dl unitdata ind t data ind dl unitdata ind t ctrl area Chapter 2 27 LLA and DLPI Example P rograms DLPI Example Program char rdlsap int 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 len Kk k k k kk k kk kk kk kk k kk kk kk KCKCKCKCKCKCKCKCKCKCKCKCKCK A Ck ck k k kk kk send a data packet assumes data area has already been filled in KOKCKCKCKCKCKCKCKCKCkCKCKC
17. KCKCKCKCKCKCKCK KCKCKCKCKCK kk Kk k KA KA KA KA KA KA KA KA kk k ck k ck KA KA KA k k ke X A x main int send_fd recv_fd file descriptors u char local_addr 20 local MAC address int i j recv len PART 1 of program Demonstrate connectionless data transfer with LLC SAP header y First we must open the LLA device file dev lan0 LLA does not require a seperate control request to specify which device you want to use it is explicit in the open request via the device file minor number send fd attach recv fd attach Now we have to bind to a IEEESAP Since LLA only supports connectionless services there is no need to specify a specific service mode LLA also does not return the local MAC address automatically when binding so we need to issue a seperate control request LOCAL_ADDRESS to get this information see below bind send fd SEND SAP bind recv fd RECV SAP The following calls to get_local_address and set_dst_address are required for LLA because of one primary difference in sending data over LLA and DLPI The difference is that DLPI requires you to specify the destination address as part of the data request and LLA requires the destination address to be logged prior to the data request Get the local MAC address so that we can send loopback packets su get local address send fd local addr Chapter
18. KCkCKCk Ck k Ck Ck k Ck ck ck Kk kk kk check ctrl found no messageNn Ckckckckckckckckckckck ck k ck ck kk ck put a message consisting of only a data part on a stream KKK KKK ck kk ck kk Ck Sk A Ck Sk AX X AX ck kk ck kk KK KKK KKK ck kk ck kk KKK KKK KKK KKK put data fd length int fd file descriptor int length length of data mes set the len field in the strbuf structu Chapter 2 XCOXck ko ke ke ke eoe eoe eee e x x f sage re 23 LLA and DLPI Example P rograms DLPI Example Program data buf len length call putmsg and check for an error if putmsg fd 0 amp data buf 0 lt 0 printf error put data putmsg failed errno dWMn errno exit 1 KK KK kk k kk kk kk kk kk kk k kk A kk put a message consisting of only a control part on a stream KOXCKCKCKCKCKCKCKCKCkCKCkCKCkCKCkCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCkCk Ck k Ck k Ck k ck k ck ck ckckckok ckok sk k ke X e void put ctrl fd length pri int fd file descriptor int length length of control message int pri priority of message either 0 or RS HIPRI set the len field in the strbuf structure ctrl buf len length call putmsg and check for an error if putmsg fd amp ctrl buf 0 pri lt 0 printf error put ctrl putmsg failed errno dWn errno exit 1 BRK k k k k kk kk kk kk kk kk kk kk k k k k k k K K A ck ko kk put a mess
19. KCkCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCk kCk k Ck k ck k ck KA ck RARA RARA RARA void send data fd rdlsap rdlsap len len int fd file descriptor u char rdlsap remote dlsap int rdlsap len length of rdlsap int len length of the packet to send dl unitdata req t data reg dl unitdata reg t ctrl area u char out dlsap fill in data req data req dl primitive DL UNITDATA REO data reg gt dl dest addr length rdlsap len data reg gt dl dest addr offset sizeof dl unitdata req t copy dlsap out dlsap u char ctrl area sizeof dl unitdata req t memcpy out dlsap rdlsap rdlsap len put both fd sizeof dl unitdata req t rdlsap len len 0 KR kk k kk kk k kk k kk k kk kk k k k K k k A ck ck k ck kk print a string followed by a DLSAP OKCKCKCKCKCKCKCKCKCkCKCkCKCkCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCKCkCKCkCkCkCkCk Ck kc k k ck k ck KA KA KA k k k kk void print dlsap string dlsap dlsap len char string label u char dlsap the DLSAP int dlsap len length of dlsap int i printf s string for i 0 i lt dlsap len i printf 02x dlsap il printf Nn 28 Chapter 2 LLA and DLPI Example P rograms DLPI Example Program BORK kk k k kk kk kk kk kk kk kk kk kk k k K k k k k K K KA KA KA KA KA KA KA KA KA k Ck k Ck k ck Ck ck ck Kk kk kk main CKCKCKCKCKCKCKCkCKC
20. LLA to DLPI Migration Guide Edition 4 LA Sion B2355 90138 HP 9000 Networking E0497 Printed in United States Copyright 1997 Hewlett Packard Company Legal Notices Theinformation in this document is subject to change without notice Hewlett Packard makes no warranty of any kind with regard to this manual induding but not limited to theimplied warranties of merchantability and fitness for a particular purpose Hewlett Packard shall not be held liable for errors contained herein or direct indirect spedial incidental or consequential damages in connection with the furnishing performance or use of this material Warranty A copy of the specific warranty terms applicable to your Hewlett Packard product and replacement parts can be obtained from your local Sales and Service Office Restricted Rights Legend Use duplication or disdosure by the U S Government is subject to restrictions as set forth in subparagraph c 1 ii of the Rights in Technical Data and Computer Software dause at DFARS 252 227 7013 for DOD agencies and subparagraphs c 1 and c 2 of the Commercial Computer Software Restricted Rights dause at FAR 52 227 19 for other agencies HEWLETT PACKARD COMPANY 3000 Hanover Street Palo Alto California 94304 U S A Use of this manual and flexible disk s or tape cartridge s supplied for this pack is restricted to this product only Additional copies of the programs may be made for security and back up
21. age consisting of both a control part and a control part on a stream KOKCKCKCKCKCKCKCKCKCKCKCKCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK KCKCKCK kCKCk Ck kCk k Ck k ck k ck k ck KA KA KA k k k kk void put both fd ctrl length data length pri int fd file descriptor int ctrl length length of control part int data length length of data part int pri priority of message either O0 or RS HIPRI fields in the strbuf structures ctrl length data length set the 1 ctrl buf len data buf len 5 call putmsg and check for an error if putmsg fd amp ctrl_buf amp data_buf pri lt 0 printf error put both putmsg failed errno dWn errno exit 1 Ok Kk k kk kk kk kk kk kk kk k k k k k K k A ck ck k kk open the DLPI cloneable device file get a list of available PPAs and attach to the first PPA returns a file descriptor for the stream KOKCKCKCKCKCKCKCkCKCkCKCKCKCKCK KCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCk KA Ck Ck k ck k ck KA KA KA ok Kok ke ke e k e x x 24 Chapter 2 int attach LLA and DLPI Example P rograms DLPI Example Program 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
22. being the SNAP SAP OxAA followed by 5 bytes of SNAP information B bind send fd SNAP SAP 0 D bind recv fd SNAP SAP 0 D DLS sdlsap amp sdlsap len DLS rdlsap amp rdlsap len Now we must complete the binding of the SNAP protocol value with the subsequent bind request and a subsequent bind class of DL HIERARCHICAL BIND E subs bind send fd SEND SNAP SAP 5 DL HIERARCHICAL BIND sdlsap amp sdlsap len subs bind recv fd RECV SNAP SAP 5 DL HIERARCHICAL BIND rdlsap amp rdlsap len print the DLSAPs we got back from the binds print dlsap sending DLSAP Sdlsap sdlsap len print dlsap receiving DLSAP rdlsap rdlsap len Time to send some data We ll send 5 data packets in sequence A for i 0 i lt 5 i send i 1 10 data bytes with the first byte i 30 Chapter2 LLA and DLPI Example P rograms DLPI Example Program data area 0 i Initialize data area for J 17 Gt Fy 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 dWMn recv len data area 0 We re finished Now call cleanup to unbind then detach then close the device fil A cleanup send fd cleanup recv_fd Chapter 2 31 LLA and DLPI
23. ck ck ck kk get the next message from a stream get msg returns one of the following defines KOXCKCKCKCKCKCKCKCKCkCKCKCKCKCKCkCKCKCKCkCK KCKCKCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCkCk Ck k Ck k ck k ck k ck ck ckckckok Kok sk ke e k e x x define GOT CTRL 1 message has only a control part define GOT DATA 2 message has only a data part define GOT BOTH 3 message has control and data parts int get msg fd int fd file descriptor int flags 0 0 gt get any available message int result 0 return value zero first byte of control area so the caller can call check_ctrl without checking the get_msg return value if only data was in the message and the user was expecting control or control data then when he calls check_ctrl it will compare the expected primitive zero and print information about the primitive that it got x ctrl area 0 0 call getmsg and check for an error if getmsg fd amp ctrl buf amp data buf amp flags lt 0 printf error getmsg failed errno din errno exit 1 if ctrl_buf len gt 0 result GOT_CTRL if data_buf len gt 0 result GOT_DATA return result BRK RK kk kk kk kk kk kk kk kk KCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK A KA k ck Ck ck k ck k k ko kk check that control message is th xpected messag KOKCKCKCKCKCKCKCKCKCkCKCkCKCKCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK
24. he control portion of the message LOCAL ADDRESS DEVICE STATUS MULTICAST ADDRESSES DL PHYS ADDR REQ DL HP HW STATUS REQ DL HP MULTICAST LIST REQ MULTICAST ADDR LIST RESET STATISTICS READ STATISTICS DL HP MULTICAST LIST REQ DL HP RESET STATS REQ DL GET STATISTICS REQ This primitive returns mib and extended mib statistics for the device in one request LOG CONTROL RESET INTERFACE ENABLE BROADCAST Not required with DLPI The control value if any is determined from the primitive DL HP HW RESET REQ Not defined DISABLE BROADCAST ADD MULTICAST DELETE MULTICAST Not defined DL ENABMULTI REQ DL DISABMULTI REQ Chapter 1 15 LLA to DLPI Migration Transmitting Data Transmitting Data LLA requires the user tolog 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 The DLSAP address format is basically the destination MAC address followed by the LLC protocol value A complete description of the DLSAP address format is described in the DLPI Programmer s Guide LLA supports the write system call for sending data requests DLPI only supports the putmsg system call for sending da
25. kCKCkCK kCKCkCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCk Ck kCKkCk Ck k Ck k ck k ck KA KA KA KA k k k e x x 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 Ay First we must open the DLPI device file dev dlpi and attach to a PPA attach will open dev dlpi find the first PPA with the DL_HP_PPA_INFO primitive and attach to that PPA attach returns the file descriptor for the stream Here w do an attach for each file descriptor send fd attach recv fd attach Now we have to bind to a IEEESAP We will ask for connectionless data link service with the DL CLDLS service mode Since we are connectionless we will not have any incoming connections so we set max conind to 0 bind will return our local DLSAP and its length in the last two arguments we pass to it El bind send fd SEND SAP 0 DL CLDLS sdlsap amp sdlsap len bind recv fd RECV SAP 0 DL CLDLS rdlsap amp rdlsap len print the DLSAPs we got back from the binds print dlsap sending DLSAP Sdlsap sdlsap len print dlsap receiving DLSAP rdlsap rdlsap len Time to send some data We ll send 5 data packets in
26. o DLPI Migration provides information about migrating programs from the HP proprietary LLA to theindustry standard DLPI Chapter 2 LLA and DLPI Example Programs includes example programs that compare LLA and DLPI 10 1 LLA to DLPI Migration 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 useLLA tothe industry standard Data Link Provider Interface DLPI HP provides DLPI with the LAN 9000 produc Before you begin the process of migrating your application you may need toreview the DLPI Programmer s Guide The following information explains the basic differences between LLA and DLPI This information is the basis for performing migration 12 Chapter 1 LLA to DLPI Migration Device Files Device Files Device files are used to identify the LAN driver Ethernet I EEE 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 fileis 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 By convention device files are kept in a directory called dev When the LAN 9000 p
27. purposes only Resale of the programs in their present form or with alterations is expressly prohibited Copyright Notices copyright 1983 96 Hewlett Packard Company all rights reserved Reproduction adaptation or translation of this document without prior written permission is prohibited except as allowed under the copyright laws copyright 1979 1980 1983 1985 93 Regents of the University of California This software is based in part on the Fourth Berkeley Software Distribution under license from the Regents of the University of California copyright 1980 1984 1986 Novell Inc copyright 1986 1992 Sun Microsystems Inc copyright 1985 86 1988 M assachusetts Institute of Technology copyright 1989 93 The Open Software Foundation Inc copyright 1986 Digital Equipment Corporation copyright 1990 Motorola Inc copyright 1990 1991 1992 Cornell University copyright 1989 1991 The University of Maryland copyright 1988 Carnegie Mellon University Trademark Notices UNIX is a registered trademark in the United States and other countries licensed exdusively through X Open Company Limited X Window System is a trademark of the M assachusetts I nstitute of Technology MS DOS and Microsoft are U S registered trademarks of Microsoft Corporation OSF Motif is a trademark of the Open Software Foundation Inc in the U S and other countries Contents LLAtoDLPI Migration Device Files cui rb
28. resses SNAP addresses do not need to be logged twic x if length INTEGERTYPE ctrl buf reqtype LOG DSAP ctrl buf vtype INTEGERTYPE ctrl buf value i dsap put ctrl fd NETCTRL BRK kk k kk kk kk kk kk kk k kk k k k k k KCKCKCK KCKCKCKCKCK KC kCKCkCkCKCKCkCKCKCKCKCKCKCKCkCkCKCKCkCkCk Ck k Ck k ck k ck ck ckck ck k kk bind to a SNAP sap KOKCKCKCKCKCKCKCkCKCkCKCkCKCkCKCkCK kCKCKCK KCKCkCKCKCKCKCKCKCKCkCKCKCKCKCKCKCKCKCKCkCKCkCKCkCKCkCKCkCKCk Ck k Ck k Ck k ck k ck KA KA KA k k ke X e x void bind snap fd snapsap int fd u char snapsap Fill in SNAP req ctrl_buf reqtype LOG_SNAP_TYPE ctrl_buf vtype 5 memcpy caddr t ctrl buf value s snapsap 5 send the SNAP request put ctrl fd NETCTRL Chapter 2 35 LLA and DLPI Example P rograms LLA Example Program OK kk k kk k kk kk kk kk kk kk kk k k k k K K A ke kx Close the file descriptor This will automatically unbind the protocol KCKCKCKCKCKCKCKCKCKCkCKCkCKCKCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK KCKCKCKCKCKCKCKCKCKCKCkCKCKCkCkCkCKCKCKkCkCkCk Ck k Ck k ck k ck k ck KA KA kk ke e e X x f void cleanup fd int fd file descriptor close close fd KK KK kk kk kk kk kk kk kk kk kk kk k kk A k ke kx receive a data packet KCKCKCKCKCKCKCKCKCKCkCKCkCKCKCKCkCK kk kk Kk kk Kk k k k k K K K kA AK K AA KA KA KA KA KA KA kc k k ck k ck ck ckckckok ck k ke e kk
29. roduct is installed several special device files are created A mong these files are the network device files associated with the LAN interface If default names are used during installation these files are called dev 1an0 and dev ether0 for IEEE 802 3 and Ethernet respectively LLA requires a separate device file for every LAN interface in the system This device file is used by LLA touniquely identify a specific device e g dev lan0 DLPI only requires one device file dev dlpi to access all supported LAN interfaces In addition there are other device files dev dlpiX where x is 0 100 used by DLPI to access all supported LAN interfaces The difference between dev dlpi and dev dlpiX is done vs non doneable devices Basically cloneable devices give you a separate stream for each open request Non doneable devices only give you one stream no matter how many times you open the device All of the LAN interfaces supported by HP DLPI support both doneable and non doneable access Chapter 1 13 Table 1 1 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 oct 1 system call The HP UX ioct1 call is used to construct inspect and control the network environment in which an LLA application will operate All LLA applications must usethe ioct1 call to configure source and destination addresse
30. s before data can be sent or received using the HP UX read and write calls ioctl requests are used in DLPI only for device specific control requests These ioct1 requests are not interpreted by DLPI but passed directly to the driver for processing All general control requests in DLPI are defined with a standard DLPI 2 0 primitive or extension These primitives are passed to DLPI via the putmsg system call only All of the standard DLPI primitives are defined in sys dlpi h The DLPI Programmer s Guide provides detailed descriptions of all the primitives All HP DLPI extensions denoted in the following table with an are defined in lt sys dlpi_ext h gt Table 1 1 lists LLA ioctl request types and their corresponding DLPI primitives LLA ioctls and Corresponding DLPI Primitives LLA ioctl req type DLPI Primitive LOG TYPE FIELD DL BIND REOor DL SUBS BIND REO LOG SSAP DL BIND REOor DL SUBS BIND REO LOG DSAP Not required with DLPI The destination address is specified with each data request see Transmitting data LOG DEST ADDR Not required with DLPI The destination address is specified with each data request see Transmitting data LOG READ CACHE Not defined 14 Chapter 1 LLA to DLPI Migration ioctl Requests LLA ioctl req type DLPI Primitive LOG READ TIMEOUT LLA SIGNAL MASK FRAME HEADER Not defined Not defined Frame headers are delivered with each individual packet via t
31. sequence iene for i 0 i lt 5 i send i 1 10 data bytes with the first byte i data area 0 i Initialize data area for j 1 j lt 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 dWMn recv len u int data area 0 Chapter 2 29 LLA and DLPI Example P rograms DLPI Example Program We re finished with PART 1 Now call cleanup to unbind then detach then close the device fil X cleanup send fd cleanup recv_fd PART 2 of program Demonstrate connectionless data transfer with LLC SNAP SAP header A As demonstrated in the first part of this program we must first open the DLPI device file dev dlpi and attach to a PPA x send fd attach recv fd attach The first method for binding a SNAP protocol value which is demonstrated below requires the user to first bind the SNAP SAP OxAA then issue a subsequent bind with class DL HIERARCHICAL BIND with the 5 bytes of SNAP information The second method which is not demonstrated in this program is to bind any supported protocol value see section 5 and then issue a subsequent bind with class DL PEER BIND The data area area of the subsequent bind should include 6 bytes of data the first byte
32. ta over RAW see the DLPI Programmer s Guide and connectionless mode streams The write system call is only supported over connection oriented streams in the DATA XFER state i e a connection must be established 16 Chapter 1 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 LL C header information in the control portion of each individually received packet i e DL UNITDATA IND DL XID IND DL TEST IND etc The user is not required to issue a separate control request to get LLC header information LLA only allows a maximum of 16 packets for normal users and 64 for super users to be queued before it starts dropping data DLPI will read as many packets as possible until both the stream head read queue default is about 10k bytes and DLPI read queue default is about 60K bytes fill When both these queues are full DLPI will begin dropping data until the queues start draining Chapter 1 17 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 P rograms Thefirst example shows a data transfer program using DLPI The second example shows the same type of program using LL
33. x82 receiving SAP define SNAP SAP OxAA SNAP SAP Kk k kk kk kk kk kk kk kk kk kk kk kk kk A k ck k ck kk SNAP protocol values KOKCKCKCKCKCKCKCkCKCkCKCkCKCKCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCkCKCKCKCKCk KA KA kCkCk Ck k ck k ck KA KA KA KA A k ke X se x u char SEND SNAP SAP 5 0x50 0x00 0x00 0x00 0x00 u char RECV SNAP SAP 5 0x60 0x00 0x00 0x00 0x00 BRK RK KK KK RR RR KCKCKCK KCKCKCKCKCKCKCK KCKCKCkCKCKCkCkCKCKCkCkCKCKCkCkCkCkCkCkCk Ck k ck k ck ck ck ck ck kk global areas for sending and receiving messages KOKCKCKCKCKCKCKCKCKCkCKCkCKCKCKCkCKCkCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCKCK KC k Ck KA KA KA k ck k ck k ck KA KA KA kk ke e ke X e x x define AREA SIZE 5000 bytes big enough for largest possible msg define LONG AREA SIZE AREA SIZE sizeof u long AREA SIZE 4 u long ctrl area LONG AREA SIZE for control messages u long data area LONG AREA SIZE for data messages struct strbuf ctrl buf AREA SIZE maxlen AREA SIZE 0 len gets filled in for each message ctrl area buf control area Chapter 2 21 LLA and DLPI Example P rograms 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 l OK kk k kk kk k kk kk k kk kk kk kk kk A ck

Download Pdf Manuals

image

Related Search

Related Contents

GRID GENERATION AND ANALYSIS USING CATIA V5 - MBI-Wiki  Tanaka ECS-356 User's Manual  Hobby Zone Super Cub S  ASUS M70AD CT8654 User's Manual  

Copyright © All rights reserved.
Failed to retrieve file