4 * Common (shared) DLPI test routines.
5 * Mostly pretty boring boilerplate sorta stuff.
6 * These can be split into individual library routines later
7 * but it's just convenient to keep them in a single file
8 * while they're being developed.
11 * Connection Oriented stuff
16 typedef unsigned long ulong;
20 #include <sys/types.h>
21 #include <sys/stream.h>
22 #include <sys/stropts.h>
24 # include <sys/dlpihdr.h>
26 # include <sys/dlpi.h>
28 #include <sys/signal.h>
33 #define CASERET(s) case s: return ("s")
38 char *dlpromisclevel();
39 char *dlservicemode();
48 dl_info_req_t info_req
;
52 info_req
.dl_primitive
= DL_INFO_REQ
;
55 ctl
.len
= sizeof (info_req
);
56 ctl
.buf
= (char *) &info_req
;
60 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
61 syserr("dlinforeq: putmsg");
69 union DL_primitives
*dlp
;
73 ctl
.maxlen
= MAXDLBUF
;
77 strgetmsg(fd
, &ctl
, (struct strbuf
*)NULL
, &flags
, "dlinfoack");
79 dlp
= (union DL_primitives
*) ctl
.buf
;
81 expecting(DL_INFO_ACK
, dlp
);
83 if (ctl
.len
< sizeof (dl_info_ack_t
))
84 err("dlinfoack: response ctl.len too short: %d", ctl
.len
);
86 if (flags
!= RS_HIPRI
)
87 err("dlinfoack: DL_INFO_ACK was not M_PCPROTO");
89 if (ctl
.len
< sizeof (dl_info_ack_t
))
90 err("dlinfoack: short response ctl.len: %d", ctl
.len
);
98 dl_attach_req_t attach_req
;
102 attach_req
.dl_primitive
= DL_ATTACH_REQ
;
103 attach_req
.dl_ppa
= ppa
;
106 ctl
.len
= sizeof (attach_req
);
107 ctl
.buf
= (char *) &attach_req
;
111 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
112 syserr("dlattachreq: putmsg");
116 dlenabmultireq(fd
, addr
, length
)
122 union DL_primitives
*dlp
;
126 dlp
= (union DL_primitives
*) buf
;
128 dlp
->enabmulti_req
.dl_primitive
= DL_ENABMULTI_REQ
;
129 dlp
->enabmulti_req
.dl_addr_length
= length
;
130 dlp
->enabmulti_req
.dl_addr_offset
= sizeof (dl_enabmulti_req_t
);
132 (void) memcpy((char*)OFFADDR(buf
, sizeof (dl_enabmulti_req_t
)), addr
, length
);
135 ctl
.len
= sizeof (dl_enabmulti_req_t
) + length
;
136 ctl
.buf
= (char*) buf
;
140 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
141 syserr("dlenabmultireq: putmsg");
145 dldisabmultireq(fd
, addr
, length
)
151 union DL_primitives
*dlp
;
155 dlp
= (union DL_primitives
*) buf
;
157 dlp
->disabmulti_req
.dl_primitive
= DL_ENABMULTI_REQ
;
158 dlp
->disabmulti_req
.dl_addr_length
= length
;
159 dlp
->disabmulti_req
.dl_addr_offset
= sizeof (dl_disabmulti_req_t
);
161 (void) memcpy((char*)OFFADDR(buf
, sizeof (dl_disabmulti_req_t
)), addr
, length
);
164 ctl
.len
= sizeof (dl_disabmulti_req_t
) + length
;
165 ctl
.buf
= (char*) buf
;
169 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
170 syserr("dldisabmultireq: putmsg");
174 dlpromisconreq(fd
, level
)
178 dl_promiscon_req_t promiscon_req
;
182 promiscon_req
.dl_primitive
= DL_PROMISCON_REQ
;
183 promiscon_req
.dl_level
= level
;
186 ctl
.len
= sizeof (promiscon_req
);
187 ctl
.buf
= (char *) &promiscon_req
;
191 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
192 syserr("dlpromiscon: putmsg");
197 dlpromiscoff(fd
, level
)
201 dl_promiscoff_req_t promiscoff_req
;
205 promiscoff_req
.dl_primitive
= DL_PROMISCOFF_REQ
;
206 promiscoff_req
.dl_level
= level
;
209 ctl
.len
= sizeof (promiscoff_req
);
210 ctl
.buf
= (char *) &promiscoff_req
;
214 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
215 syserr("dlpromiscoff: putmsg");
219 dlphysaddrreq(fd
, addrtype
)
223 dl_phys_addr_req_t phys_addr_req
;
227 phys_addr_req
.dl_primitive
= DL_PHYS_ADDR_REQ
;
228 phys_addr_req
.dl_addr_type
= addrtype
;
231 ctl
.len
= sizeof (phys_addr_req
);
232 ctl
.buf
= (char *) &phys_addr_req
;
236 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
237 syserr("dlphysaddrreq: putmsg");
241 dlsetphysaddrreq(fd
, addr
, length
)
247 union DL_primitives
*dlp
;
251 dlp
= (union DL_primitives
*) buf
;
253 dlp
->set_physaddr_req
.dl_primitive
= DL_ENABMULTI_REQ
;
254 dlp
->set_physaddr_req
.dl_addr_length
= length
;
255 dlp
->set_physaddr_req
.dl_addr_offset
= sizeof (dl_set_phys_addr_req_t
);
257 (void) memcpy((char*)OFFADDR(buf
, sizeof (dl_set_phys_addr_req_t
)), addr
, length
);
260 ctl
.len
= sizeof (dl_set_phys_addr_req_t
) + length
;
261 ctl
.buf
= (char*) buf
;
265 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
266 syserr("dlsetphysaddrreq: putmsg");
273 dl_detach_req_t detach_req
;
277 detach_req
.dl_primitive
= DL_DETACH_REQ
;
280 ctl
.len
= sizeof (detach_req
);
281 ctl
.buf
= (char *) &detach_req
;
285 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
286 syserr("dldetachreq: putmsg");
290 dlbindreq(fd
, sap
, max_conind
, service_mode
, conn_mgmt
, xidtest
)
298 dl_bind_req_t bind_req
;
302 bind_req
.dl_primitive
= DL_BIND_REQ
;
303 bind_req
.dl_sap
= sap
;
304 bind_req
.dl_max_conind
= max_conind
;
305 bind_req
.dl_service_mode
= service_mode
;
306 bind_req
.dl_conn_mgmt
= conn_mgmt
;
307 bind_req
.dl_xidtest_flg
= xidtest
;
310 ctl
.len
= sizeof (bind_req
);
311 ctl
.buf
= (char *) &bind_req
;
315 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
316 syserr("dlbindreq: putmsg");
320 dlunitdatareq(fd
, addrp
, addrlen
, minpri
, maxpri
, datap
, datalen
)
324 u_long minpri
, maxpri
;
329 union DL_primitives
*dlp
;
330 struct strbuf data
, ctl
;
332 dlp
= (union DL_primitives
*) buf
;
334 dlp
->unitdata_req
.dl_primitive
= DL_UNITDATA_REQ
;
335 dlp
->unitdata_req
.dl_dest_addr_length
= addrlen
;
336 dlp
->unitdata_req
.dl_dest_addr_offset
= sizeof (dl_unitdata_req_t
);
337 dlp
->unitdata_req
.dl_priority
.dl_min
= minpri
;
338 dlp
->unitdata_req
.dl_priority
.dl_max
= maxpri
;
340 (void) memcpy(OFFADDR(dlp
, sizeof (dl_unitdata_req_t
)), addrp
, addrlen
);
343 ctl
.len
= sizeof (dl_unitdata_req_t
) + addrlen
;
344 ctl
.buf
= (char *) buf
;
348 data
.buf
= (char *) datap
;
350 if (putmsg(fd
, &ctl
, &data
, 0) < 0)
351 syserr("dlunitdatareq: putmsg");
358 dl_unbind_req_t unbind_req
;
362 unbind_req
.dl_primitive
= DL_UNBIND_REQ
;
365 ctl
.len
= sizeof (unbind_req
);
366 ctl
.buf
= (char *) &unbind_req
;
370 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0)
371 syserr("dlunbindreq: putmsg");
379 union DL_primitives
*dlp
;
383 ctl
.maxlen
= MAXDLBUF
;
387 strgetmsg(fd
, &ctl
, (struct strbuf
*)NULL
, &flags
, "dlokack");
389 dlp
= (union DL_primitives
*) ctl
.buf
;
391 expecting(DL_OK_ACK
, dlp
);
393 if (ctl
.len
< sizeof (dl_ok_ack_t
))
394 err("dlokack: response ctl.len too short: %d", ctl
.len
);
396 if (flags
!= RS_HIPRI
)
397 err("dlokack: DL_OK_ACK was not M_PCPROTO");
399 if (ctl
.len
< sizeof (dl_ok_ack_t
))
400 err("dlokack: short response ctl.len: %d", ctl
.len
);
408 union DL_primitives
*dlp
;
412 ctl
.maxlen
= MAXDLBUF
;
416 strgetmsg(fd
, &ctl
, (struct strbuf
*)NULL
, &flags
, "dlerrorack");
418 dlp
= (union DL_primitives
*) ctl
.buf
;
420 expecting(DL_ERROR_ACK
, dlp
);
422 if (ctl
.len
< sizeof (dl_error_ack_t
))
423 err("dlerrorack: response ctl.len too short: %d", ctl
.len
);
425 if (flags
!= RS_HIPRI
)
426 err("dlerrorack: DL_OK_ACK was not M_PCPROTO");
428 if (ctl
.len
< sizeof (dl_error_ack_t
))
429 err("dlerrorack: short response ctl.len: %d", ctl
.len
);
437 union DL_primitives
*dlp
;
441 ctl
.maxlen
= MAXDLBUF
;
445 strgetmsg(fd
, &ctl
, (struct strbuf
*)NULL
, &flags
, "dlbindack");
447 dlp
= (union DL_primitives
*) ctl
.buf
;
449 expecting(DL_BIND_ACK
, dlp
);
451 if (flags
!= RS_HIPRI
)
452 err("dlbindack: DL_OK_ACK was not M_PCPROTO");
454 if (ctl
.len
< sizeof (dl_bind_ack_t
))
455 err("dlbindack: short response ctl.len: %d", ctl
.len
);
459 dlphysaddrack(fd
, bufp
)
463 union DL_primitives
*dlp
;
467 ctl
.maxlen
= MAXDLBUF
;
471 strgetmsg(fd
, &ctl
, (struct strbuf
*)NULL
, &flags
, "dlphysaddrack");
473 dlp
= (union DL_primitives
*) ctl
.buf
;
475 expecting(DL_PHYS_ADDR_ACK
, dlp
);
477 if (flags
!= RS_HIPRI
)
478 err("dlbindack: DL_OK_ACK was not M_PCPROTO");
480 if (ctl
.len
< sizeof (dl_phys_addr_ack_t
))
481 err("dlphysaddrack: short response ctl.len: %d", ctl
.len
);
487 (void) err("sigalrm: TIMEOUT");
490 strgetmsg(fd
, ctlp
, datap
, flagsp
, caller
)
492 struct strbuf
*ctlp
, *datap
;
497 static char errmsg
[80];
502 (void) signal(SIGALRM
, sigalrm
);
503 if (alarm(MAXWAIT
) < 0) {
504 (void) sprintf(errmsg
, "%s: alarm", caller
);
509 * Set flags argument and issue getmsg().
512 if ((rc
= getmsg(fd
, ctlp
, datap
, flagsp
)) < 0) {
513 (void) sprintf(errmsg
, "%s: getmsg", caller
);
521 (void) sprintf(errmsg
, "%s: alarm", caller
);
526 * Check for MOREDATA and/or MORECTL.
528 if ((rc
& (MORECTL
| MOREDATA
)) == (MORECTL
| MOREDATA
))
529 err("%s: MORECTL|MOREDATA", caller
);
531 err("%s: MORECTL", caller
);
533 err("%s: MOREDATA", caller
);
536 * Check for at least sizeof (long) control data portion.
538 if (ctlp
->len
< sizeof (long))
539 err("getmsg: control portion length < sizeof (long): %d", ctlp
->len
);
544 union DL_primitives
*dlp
;
546 if (dlp
->dl_primitive
!= (u_long
)prim
) {
548 err("expected %s got %s", dlprim(prim
),
549 dlprim(dlp
->dl_primitive
));
555 * Print any DLPI msg in human readable format.
558 union DL_primitives
*dlp
;
560 switch (dlp
->dl_primitive
) {
570 printdlattachreq(dlp
);
578 printdlerrorack(dlp
);
582 printdldetachreq(dlp
);
594 printdlunbindreq(dlp
);
597 case DL_SUBS_BIND_REQ
:
598 printdlsubsbindreq(dlp
);
601 case DL_SUBS_BIND_ACK
:
602 printdlsubsbindack(dlp
);
605 case DL_SUBS_UNBIND_REQ
:
606 printdlsubsunbindreq(dlp
);
609 case DL_ENABMULTI_REQ
:
610 printdlenabmultireq(dlp
);
613 case DL_DISABMULTI_REQ
:
614 printdldisabmultireq(dlp
);
617 case DL_PROMISCON_REQ
:
618 printdlpromisconreq(dlp
);
621 case DL_PROMISCOFF_REQ
:
622 printdlpromiscoffreq(dlp
);
625 case DL_UNITDATA_REQ
:
626 printdlunitdatareq(dlp
);
629 case DL_UNITDATA_IND
:
630 printdlunitdataind(dlp
);
634 printdluderrorind(dlp
);
638 printdludqosreq(dlp
);
641 case DL_PHYS_ADDR_REQ
:
642 printdlphysaddrreq(dlp
);
645 case DL_PHYS_ADDR_ACK
:
646 printdlphysaddrack(dlp
);
649 case DL_SET_PHYS_ADDR_REQ
:
650 printdlsetphysaddrreq(dlp
);
654 err("printdlprim: unknown primitive type 0x%x",
662 union DL_primitives
*dlp
;
664 (void) printf("DL_INFO_REQ\n");
668 union DL_primitives
*dlp
;
670 u_char addr
[MAXDLADDR
];
671 u_char brdcst
[MAXDLADDR
];
673 addrtostring(OFFADDR(dlp
, dlp
->info_ack
.dl_addr_offset
),
674 dlp
->info_ack
.dl_addr_length
, addr
);
675 addrtostring(OFFADDR(dlp
, dlp
->info_ack
.dl_brdcst_addr_offset
),
676 dlp
->info_ack
.dl_brdcst_addr_length
, brdcst
);
678 (void) printf("DL_INFO_ACK: max_sdu %d min_sdu %d\n",
679 dlp
->info_ack
.dl_max_sdu
,
680 dlp
->info_ack
.dl_min_sdu
);
681 (void) printf("addr_length %d mac_type %s current_state %s\n",
682 dlp
->info_ack
.dl_addr_length
,
683 dlmactype(dlp
->info_ack
.dl_mac_type
),
684 dlstate(dlp
->info_ack
.dl_current_state
));
685 (void) printf("sap_length %d service_mode %s qos_length %d\n",
686 dlp
->info_ack
.dl_sap_length
,
687 dlservicemode(dlp
->info_ack
.dl_service_mode
),
688 dlp
->info_ack
.dl_qos_length
);
689 (void) printf("qos_offset %d qos_range_length %d qos_range_offset %d\n",
690 dlp
->info_ack
.dl_qos_offset
,
691 dlp
->info_ack
.dl_qos_range_length
,
692 dlp
->info_ack
.dl_qos_range_offset
);
693 (void) printf("provider_style %s addr_offset %d version %d\n",
694 dlstyle(dlp
->info_ack
.dl_provider_style
),
695 dlp
->info_ack
.dl_addr_offset
,
696 dlp
->info_ack
.dl_version
);
697 (void) printf("brdcst_addr_length %d brdcst_addr_offset %d\n",
698 dlp
->info_ack
.dl_brdcst_addr_length
,
699 dlp
->info_ack
.dl_brdcst_addr_offset
);
700 (void) printf("addr %s\n", addr
);
701 (void) printf("brdcst_addr %s\n", brdcst
);
704 printdlattachreq(dlp
)
705 union DL_primitives
*dlp
;
707 (void) printf("DL_ATTACH_REQ: ppa %d\n",
708 dlp
->attach_req
.dl_ppa
);
712 union DL_primitives
*dlp
;
714 (void) printf("DL_OK_ACK: correct_primitive %s\n",
715 dlprim(dlp
->ok_ack
.dl_correct_primitive
));
719 union DL_primitives
*dlp
;
721 (void) printf("DL_ERROR_ACK: error_primitive %s errno %s unix_errno %d: %s\n",
722 dlprim(dlp
->error_ack
.dl_error_primitive
),
723 dlerrno(dlp
->error_ack
.dl_errno
),
724 dlp
->error_ack
.dl_unix_errno
,
725 strerror(dlp
->error_ack
.dl_unix_errno
));
728 printdlenabmultireq(dlp
)
729 union DL_primitives
*dlp
;
731 u_char addr
[MAXDLADDR
];
733 addrtostring(OFFADDR(dlp
, dlp
->enabmulti_req
.dl_addr_offset
),
734 dlp
->enabmulti_req
.dl_addr_length
, addr
);
736 (void) printf("DL_ENABMULTI_REQ: addr_length %d addr_offset %d\n",
737 dlp
->enabmulti_req
.dl_addr_length
,
738 dlp
->enabmulti_req
.dl_addr_offset
);
739 (void) printf("addr %s\n", addr
);
742 printdldisabmultireq(dlp
)
743 union DL_primitives
*dlp
;
745 u_char addr
[MAXDLADDR
];
747 addrtostring(OFFADDR(dlp
, dlp
->disabmulti_req
.dl_addr_offset
),
748 dlp
->disabmulti_req
.dl_addr_length
, addr
);
750 (void) printf("DL_DISABMULTI_REQ: addr_length %d addr_offset %d\n",
751 dlp
->disabmulti_req
.dl_addr_length
,
752 dlp
->disabmulti_req
.dl_addr_offset
);
753 (void) printf("addr %s\n", addr
);
756 printdlpromisconreq(dlp
)
757 union DL_primitives
*dlp
;
759 (void) printf("DL_PROMISCON_REQ: level %s\n",
760 dlpromisclevel(dlp
->promiscon_req
.dl_level
));
763 printdlpromiscoffreq(dlp
)
764 union DL_primitives
*dlp
;
766 (void) printf("DL_PROMISCOFF_REQ: level %s\n",
767 dlpromisclevel(dlp
->promiscoff_req
.dl_level
));
770 printdlphysaddrreq(dlp
)
771 union DL_primitives
*dlp
;
773 (void) printf("DL_PHYS_ADDR_REQ: addr_type 0x%x\n",
774 dlp
->physaddr_req
.dl_addr_type
);
777 printdlphysaddrack(dlp
)
778 union DL_primitives
*dlp
;
780 u_char addr
[MAXDLADDR
];
782 addrtostring(OFFADDR(dlp
, dlp
->physaddr_ack
.dl_addr_offset
),
783 dlp
->physaddr_ack
.dl_addr_length
, addr
);
785 (void) printf("DL_PHYS_ADDR_ACK: addr_length %d addr_offset %d\n",
786 dlp
->physaddr_ack
.dl_addr_length
,
787 dlp
->physaddr_ack
.dl_addr_offset
);
788 (void) printf("addr %s\n", addr
);
791 printdlsetphysaddrreq(dlp
)
792 union DL_primitives
*dlp
;
794 u_char addr
[MAXDLADDR
];
796 addrtostring(OFFADDR(dlp
, dlp
->set_physaddr_req
.dl_addr_offset
),
797 dlp
->set_physaddr_req
.dl_addr_length
, addr
);
799 (void) printf("DL_SET_PHYS_ADDR_REQ: addr_length %d addr_offset %d\n",
800 dlp
->set_physaddr_req
.dl_addr_length
,
801 dlp
->set_physaddr_req
.dl_addr_offset
);
802 (void) printf("addr %s\n", addr
);
806 printdldetachreq(dlp
)
807 union DL_primitives
*dlp
;
809 (void) printf("DL_DETACH_REQ\n");
813 union DL_primitives
*dlp
;
815 (void) printf("DL_BIND_REQ: sap %d max_conind %d\n",
816 dlp
->bind_req
.dl_sap
,
817 dlp
->bind_req
.dl_max_conind
);
818 (void) printf("service_mode %s conn_mgmt %d xidtest_flg 0x%x\n",
819 dlservicemode(dlp
->bind_req
.dl_service_mode
),
820 dlp
->bind_req
.dl_conn_mgmt
,
821 dlp
->bind_req
.dl_xidtest_flg
);
825 union DL_primitives
*dlp
;
827 u_char addr
[MAXDLADDR
];
829 addrtostring(OFFADDR(dlp
, dlp
->bind_ack
.dl_addr_offset
),
830 dlp
->bind_ack
.dl_addr_length
, addr
);
832 (void) printf("DL_BIND_ACK: sap %d addr_length %d addr_offset %d\n",
833 dlp
->bind_ack
.dl_sap
,
834 dlp
->bind_ack
.dl_addr_length
,
835 dlp
->bind_ack
.dl_addr_offset
);
836 (void) printf("max_conind %d xidtest_flg 0x%x\n",
837 dlp
->bind_ack
.dl_max_conind
,
838 dlp
->bind_ack
.dl_xidtest_flg
);
839 (void) printf("addr %s\n", addr
);
843 printdlunbindreq(dlp
)
844 union DL_primitives
*dlp
;
846 (void) printf("DL_UNBIND_REQ\n");
849 printdlsubsbindreq(dlp
)
850 union DL_primitives
*dlp
;
852 u_char sap
[MAXDLADDR
];
854 addrtostring(OFFADDR(dlp
, dlp
->subs_bind_req
.dl_subs_sap_offset
),
855 dlp
->subs_bind_req
.dl_subs_sap_length
, sap
);
857 (void) printf("DL_SUBS_BIND_REQ: subs_sap_offset %d sub_sap_len %d\n",
858 dlp
->subs_bind_req
.dl_subs_sap_offset
,
859 dlp
->subs_bind_req
.dl_subs_sap_length
);
860 (void) printf("sap %s\n", sap
);
863 printdlsubsbindack(dlp
)
864 union DL_primitives
*dlp
;
866 u_char sap
[MAXDLADDR
];
868 addrtostring(OFFADDR(dlp
, dlp
->subs_bind_ack
.dl_subs_sap_offset
),
869 dlp
->subs_bind_ack
.dl_subs_sap_length
, sap
);
871 (void) printf("DL_SUBS_BIND_ACK: subs_sap_offset %d sub_sap_length %d\n",
872 dlp
->subs_bind_ack
.dl_subs_sap_offset
,
873 dlp
->subs_bind_ack
.dl_subs_sap_length
);
874 (void) printf("sap %s\n", sap
);
877 printdlsubsunbindreq(dlp
)
878 union DL_primitives
*dlp
;
880 u_char sap
[MAXDLADDR
];
882 addrtostring(OFFADDR(dlp
, dlp
->subs_unbind_req
.dl_subs_sap_offset
),
883 dlp
->subs_unbind_req
.dl_subs_sap_length
, sap
);
885 (void) printf("DL_SUBS_UNBIND_REQ: subs_sap_offset %d sub_sap_length %d\n",
886 dlp
->subs_unbind_req
.dl_subs_sap_offset
,
887 dlp
->subs_unbind_req
.dl_subs_sap_length
);
888 (void) printf("sap %s\n", sap
);
891 printdlunitdatareq(dlp
)
892 union DL_primitives
*dlp
;
894 u_char addr
[MAXDLADDR
];
896 addrtostring(OFFADDR(dlp
, dlp
->unitdata_req
.dl_dest_addr_offset
),
897 dlp
->unitdata_req
.dl_dest_addr_length
, addr
);
899 (void) printf("DL_UNITDATA_REQ: dest_addr_length %d dest_addr_offset %d\n",
900 dlp
->unitdata_req
.dl_dest_addr_length
,
901 dlp
->unitdata_req
.dl_dest_addr_offset
);
902 (void) printf("dl_priority.min %d dl_priority.max %d\n",
903 dlp
->unitdata_req
.dl_priority
.dl_min
,
904 dlp
->unitdata_req
.dl_priority
.dl_max
);
905 (void) printf("addr %s\n", addr
);
908 printdlunitdataind(dlp
)
909 union DL_primitives
*dlp
;
911 u_char dest
[MAXDLADDR
];
912 u_char src
[MAXDLADDR
];
914 addrtostring(OFFADDR(dlp
, dlp
->unitdata_ind
.dl_dest_addr_offset
),
915 dlp
->unitdata_ind
.dl_dest_addr_length
, dest
);
916 addrtostring(OFFADDR(dlp
, dlp
->unitdata_ind
.dl_src_addr_offset
),
917 dlp
->unitdata_ind
.dl_src_addr_length
, src
);
919 (void) printf("DL_UNITDATA_IND: dest_addr_length %d dest_addr_offset %d\n",
920 dlp
->unitdata_ind
.dl_dest_addr_length
,
921 dlp
->unitdata_ind
.dl_dest_addr_offset
);
922 (void) printf("src_addr_length %d src_addr_offset %d\n",
923 dlp
->unitdata_ind
.dl_src_addr_length
,
924 dlp
->unitdata_ind
.dl_src_addr_offset
);
925 (void) printf("group_address 0x%x\n",
926 dlp
->unitdata_ind
.dl_group_address
);
927 (void) printf("dest %s\n", dest
);
928 (void) printf("src %s\n", src
);
931 printdluderrorind(dlp
)
932 union DL_primitives
*dlp
;
934 u_char addr
[MAXDLADDR
];
936 addrtostring(OFFADDR(dlp
, dlp
->uderror_ind
.dl_dest_addr_offset
),
937 dlp
->uderror_ind
.dl_dest_addr_length
, addr
);
939 (void) printf("DL_UDERROR_IND: dest_addr_length %d dest_addr_offset %d\n",
940 dlp
->uderror_ind
.dl_dest_addr_length
,
941 dlp
->uderror_ind
.dl_dest_addr_offset
);
942 (void) printf("unix_errno %d errno %s\n",
943 dlp
->uderror_ind
.dl_unix_errno
,
944 dlerrno(dlp
->uderror_ind
.dl_errno
));
945 (void) printf("addr %s\n", addr
);
949 union DL_primitives
*dlp
;
951 u_char addr
[MAXDLADDR
];
953 addrtostring(OFFADDR(dlp
, dlp
->test_req
.dl_dest_addr_offset
),
954 dlp
->test_req
.dl_dest_addr_length
, addr
);
956 (void) printf("DL_TEST_REQ: flag 0x%x dest_addr_length %d dest_addr_offset %d\n",
957 dlp
->test_req
.dl_flag
,
958 dlp
->test_req
.dl_dest_addr_length
,
959 dlp
->test_req
.dl_dest_addr_offset
);
960 (void) printf("dest_addr %s\n", addr
);
964 union DL_primitives
*dlp
;
966 u_char dest
[MAXDLADDR
];
967 u_char src
[MAXDLADDR
];
969 addrtostring(OFFADDR(dlp
, dlp
->test_ind
.dl_dest_addr_offset
),
970 dlp
->test_ind
.dl_dest_addr_length
, dest
);
971 addrtostring(OFFADDR(dlp
, dlp
->test_ind
.dl_src_addr_offset
),
972 dlp
->test_ind
.dl_src_addr_length
, src
);
974 (void) printf("DL_TEST_IND: flag 0x%x dest_addr_length %d dest_addr_offset %d\n",
975 dlp
->test_ind
.dl_flag
,
976 dlp
->test_ind
.dl_dest_addr_length
,
977 dlp
->test_ind
.dl_dest_addr_offset
);
978 (void) printf("src_addr_length %d src_addr_offset %d\n",
979 dlp
->test_ind
.dl_src_addr_length
,
980 dlp
->test_ind
.dl_src_addr_offset
);
981 (void) printf("dest_addr %s\n", dest
);
982 (void) printf("src_addr %s\n", src
);
986 union DL_primitives
*dlp
;
988 u_char dest
[MAXDLADDR
];
990 addrtostring(OFFADDR(dlp
, dlp
->test_res
.dl_dest_addr_offset
),
991 dlp
->test_res
.dl_dest_addr_length
, dest
);
993 (void) printf("DL_TEST_RES: flag 0x%x dest_addr_length %d dest_addr_offset %d\n",
994 dlp
->test_res
.dl_flag
,
995 dlp
->test_res
.dl_dest_addr_length
,
996 dlp
->test_res
.dl_dest_addr_offset
);
997 (void) printf("dest_addr %s\n", dest
);
1001 union DL_primitives
*dlp
;
1003 u_char dest
[MAXDLADDR
];
1004 u_char src
[MAXDLADDR
];
1006 addrtostring(OFFADDR(dlp
, dlp
->test_con
.dl_dest_addr_offset
),
1007 dlp
->test_con
.dl_dest_addr_length
, dest
);
1008 addrtostring(OFFADDR(dlp
, dlp
->test_con
.dl_src_addr_offset
),
1009 dlp
->test_con
.dl_src_addr_length
, src
);
1011 (void) printf("DL_TEST_CON: flag 0x%x dest_addr_length %d dest_addr_offset %d\n",
1012 dlp
->test_con
.dl_flag
,
1013 dlp
->test_con
.dl_dest_addr_length
,
1014 dlp
->test_con
.dl_dest_addr_offset
);
1015 (void) printf("src_addr_length %d src_addr_offset %d\n",
1016 dlp
->test_con
.dl_src_addr_length
,
1017 dlp
->test_con
.dl_src_addr_offset
);
1018 (void) printf("dest_addr %s\n", dest
);
1019 (void) printf("src_addr %s\n", src
);
1023 union DL_primitives
*dlp
;
1025 u_char dest
[MAXDLADDR
];
1027 addrtostring(OFFADDR(dlp
, dlp
->xid_req
.dl_dest_addr_offset
),
1028 dlp
->xid_req
.dl_dest_addr_length
, dest
);
1030 (void) printf("DL_XID_REQ: flag 0x%x dest_addr_length %d dest_addr_offset %d\n",
1031 dlp
->xid_req
.dl_flag
,
1032 dlp
->xid_req
.dl_dest_addr_length
,
1033 dlp
->xid_req
.dl_dest_addr_offset
);
1034 (void) printf("dest_addr %s\n", dest
);
1038 union DL_primitives
*dlp
;
1040 u_char dest
[MAXDLADDR
];
1041 u_char src
[MAXDLADDR
];
1043 addrtostring(OFFADDR(dlp
, dlp
->xid_ind
.dl_dest_addr_offset
),
1044 dlp
->xid_ind
.dl_dest_addr_length
, dest
);
1045 addrtostring(OFFADDR(dlp
, dlp
->xid_ind
.dl_src_addr_offset
),
1046 dlp
->xid_ind
.dl_src_addr_length
, src
);
1048 (void) printf("DL_XID_IND: flag 0x%x dest_addr_length %d dest_addr_offset %d\n",
1049 dlp
->xid_ind
.dl_flag
,
1050 dlp
->xid_ind
.dl_dest_addr_length
,
1051 dlp
->xid_ind
.dl_dest_addr_offset
);
1052 (void) printf("src_addr_length %d src_addr_offset %d\n",
1053 dlp
->xid_ind
.dl_src_addr_length
,
1054 dlp
->xid_ind
.dl_src_addr_offset
);
1055 (void) printf("dest_addr %s\n", dest
);
1056 (void) printf("src_addr %s\n", src
);
1060 union DL_primitives
*dlp
;
1062 u_char dest
[MAXDLADDR
];
1064 addrtostring(OFFADDR(dlp
, dlp
->xid_res
.dl_dest_addr_offset
),
1065 dlp
->xid_res
.dl_dest_addr_length
, dest
);
1067 (void) printf("DL_XID_RES: flag 0x%x dest_addr_length %d dest_addr_offset %d\n",
1068 dlp
->xid_res
.dl_flag
,
1069 dlp
->xid_res
.dl_dest_addr_length
,
1070 dlp
->xid_res
.dl_dest_addr_offset
);
1071 (void) printf("dest_addr %s\n", dest
);
1075 union DL_primitives
*dlp
;
1077 u_char dest
[MAXDLADDR
];
1078 u_char src
[MAXDLADDR
];
1080 addrtostring(OFFADDR(dlp
, dlp
->xid_con
.dl_dest_addr_offset
),
1081 dlp
->xid_con
.dl_dest_addr_length
, dest
);
1082 addrtostring(OFFADDR(dlp
, dlp
->xid_con
.dl_src_addr_offset
),
1083 dlp
->xid_con
.dl_src_addr_length
, src
);
1085 (void) printf("DL_XID_CON: flag 0x%x dest_addr_length %d dest_addr_offset %d\n",
1086 dlp
->xid_con
.dl_flag
,
1087 dlp
->xid_con
.dl_dest_addr_length
,
1088 dlp
->xid_con
.dl_dest_addr_offset
);
1089 (void) printf("src_addr_length %d src_addr_offset %d\n",
1090 dlp
->xid_con
.dl_src_addr_length
,
1091 dlp
->xid_con
.dl_src_addr_offset
);
1092 (void) printf("dest_addr %s\n", dest
);
1093 (void) printf("src_addr %s\n", src
);
1096 printdludqosreq(dlp
)
1097 union DL_primitives
*dlp
;
1099 (void) printf("DL_UDQOS_REQ: qos_length %d qos_offset %d\n",
1100 dlp
->udqos_req
.dl_qos_length
,
1101 dlp
->udqos_req
.dl_qos_offset
);
1107 addrtostring(addr
, length
, s
)
1114 for (i
= 0; i
< length
; i
++) {
1115 (void) sprintf((char*) s
, "%x:", addr
[i
] & 0xff);
1116 s
= s
+ strlen((char*)s
);
1125 stringtoaddr(sp
, addr
)
1134 while (p
= strtok(p
, ":")) {
1135 if (sscanf(p
, "%x", &val
) != 1)
1136 err("stringtoaddr: invalid input string: %s", sp
);
1138 err("stringtoaddr: invalid input string: %s", sp
);
1152 static char hextab
[] = {
1153 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
1154 'a', 'b', 'c', 'd', 'e', 'f'
1157 return (hextab
[c
& 0x0f]);
1164 static char primbuf
[80];
1166 switch ((int)prim
) {
1167 CASERET(DL_INFO_REQ
);
1168 CASERET(DL_INFO_ACK
);
1169 CASERET(DL_ATTACH_REQ
);
1170 CASERET(DL_DETACH_REQ
);
1171 CASERET(DL_BIND_REQ
);
1172 CASERET(DL_BIND_ACK
);
1173 CASERET(DL_UNBIND_REQ
);
1175 CASERET(DL_ERROR_ACK
);
1176 CASERET(DL_SUBS_BIND_REQ
);
1177 CASERET(DL_SUBS_BIND_ACK
);
1178 CASERET(DL_UNITDATA_REQ
);
1179 CASERET(DL_UNITDATA_IND
);
1180 CASERET(DL_UDERROR_IND
);
1181 CASERET(DL_UDQOS_REQ
);
1182 CASERET(DL_CONNECT_REQ
);
1183 CASERET(DL_CONNECT_IND
);
1184 CASERET(DL_CONNECT_RES
);
1185 CASERET(DL_CONNECT_CON
);
1186 CASERET(DL_TOKEN_REQ
);
1187 CASERET(DL_TOKEN_ACK
);
1188 CASERET(DL_DISCONNECT_REQ
);
1189 CASERET(DL_DISCONNECT_IND
);
1190 CASERET(DL_RESET_REQ
);
1191 CASERET(DL_RESET_IND
);
1192 CASERET(DL_RESET_RES
);
1193 CASERET(DL_RESET_CON
);
1195 (void) sprintf(primbuf
, "unknown primitive 0x%x", prim
);
1205 static char statebuf
[80];
1208 CASERET(DL_UNATTACHED
);
1209 CASERET(DL_ATTACH_PENDING
);
1210 CASERET(DL_DETACH_PENDING
);
1211 CASERET(DL_UNBOUND
);
1212 CASERET(DL_BIND_PENDING
);
1213 CASERET(DL_UNBIND_PENDING
);
1215 CASERET(DL_UDQOS_PENDING
);
1216 CASERET(DL_OUTCON_PENDING
);
1217 CASERET(DL_INCON_PENDING
);
1218 CASERET(DL_CONN_RES_PENDING
);
1219 CASERET(DL_DATAXFER
);
1220 CASERET(DL_USER_RESET_PENDING
);
1221 CASERET(DL_PROV_RESET_PENDING
);
1222 CASERET(DL_RESET_RES_PENDING
);
1223 CASERET(DL_DISCON8_PENDING
);
1224 CASERET(DL_DISCON9_PENDING
);
1225 CASERET(DL_DISCON11_PENDING
);
1226 CASERET(DL_DISCON12_PENDING
);
1227 CASERET(DL_DISCON13_PENDING
);
1228 CASERET(DL_SUBS_BIND_PND
);
1230 (void) sprintf(statebuf
, "unknown state 0x%x", state
);
1239 static char errnobuf
[80];
1243 CASERET(DL_BADADDR
);
1244 CASERET(DL_BADCORR
);
1245 CASERET(DL_BADDATA
);
1247 CASERET(DL_BADPRIM
);
1248 CASERET(DL_BADQOSPARAM
);
1249 CASERET(DL_BADQOSTYPE
);
1251 CASERET(DL_BADTOKEN
);
1253 CASERET(DL_INITFAILED
);
1255 CASERET(DL_NOTINIT
);
1256 CASERET(DL_OUTSTATE
);
1258 CASERET(DL_UNSUPPORTED
);
1259 CASERET(DL_UNDELIVERABLE
);
1260 CASERET(DL_NOTSUPPORTED
);
1261 CASERET(DL_TOOMANY
);
1262 CASERET(DL_NOTENAB
);
1265 CASERET(DL_NOXIDAUTO
);
1266 CASERET(DL_NOTESTAUTO
);
1267 CASERET(DL_XIDAUTO
);
1268 CASERET(DL_TESTAUTO
);
1269 CASERET(DL_PENDING
);
1272 (void) sprintf(errnobuf
, "unknown dlpi errno 0x%x", errno
);
1278 dlpromisclevel(level
)
1281 static char levelbuf
[80];
1284 CASERET(DL_PROMISC_PHYS
);
1285 CASERET(DL_PROMISC_SAP
);
1286 CASERET(DL_PROMISC_MULTI
);
1288 (void) sprintf(levelbuf
, "unknown promisc level 0x%x", level
);
1294 dlservicemode(servicemode
)
1297 static char servicemodebuf
[80];
1299 switch (servicemode
) {
1302 CASERET(DL_CODLS
|DL_CLDLS
);
1304 (void) sprintf(servicemodebuf
,
1305 "unknown provider service mode 0x%x", servicemode
);
1306 return (servicemodebuf
);
1314 static char stylebuf
[80];
1320 (void) sprintf(stylebuf
, "unknown provider style 0x%x", style
);
1329 static char mediabuf
[80];
1341 (void) sprintf(mediabuf
, "unknown media type 0x%x", media
);
1347 err(fmt
, a1
, a2
, a3
, a4
)
1349 char *a1
, *a2
, *a3
, *a4
;
1351 (void) fprintf(stderr
, fmt
, a1
, a2
, a3
, a4
);
1352 (void) fprintf(stderr
, "\n");
1363 strioctl(fd
, cmd
, timout
, len
, dp
)
1370 struct strioctl sioc
;
1374 sioc
.ic_timout
= timout
;
1377 rc
= ioctl(fd
, I_STR
, &sioc
);
1382 return (sioc
.ic_len
);