384 case TIOCREMOTE:
385 ptioc(q, mp, RDSIDE);
386 break;
387
388 case JWINSIZE:
389 case TIOCGWINSZ:
390 mp->b_datap->db_type = M_IOCACK;
391 mioc2ack(mp, NULL, 0, 0);
392 qreply(q, mp);
393 break;
394
395 default:
396 freemsg(mp);
397 break;
398 }
399 break;
400
401 case M_IOCACK:
402 case M_IOCNAK:
403 /*
404 * We only pass write-side ioctls through to the master that
405 * we've already ACKed or NAKed to the stream head. Thus, we
406 * discard ones arriving from below, since they're redundant
407 * from the point of view of modules above us.
408 */
409 freemsg(mp);
410 break;
411
412 case M_HANGUP:
413 /*
414 * clear blocked state.
415 */
416 {
417 struct ptem *ntp = (struct ptem *)q->q_ptr;
418 if (ntp->state & OFLOW_CTL) {
419 ntp->state &= ~OFLOW_CTL;
420 qenable(WR(q));
421 }
422 }
423 /* FALLTHROUGH */
424 default:
609 ptemwmsg(queue_t *q, mblk_t *mp)
610 {
611 struct ptem *ntp = (struct ptem *)q->q_ptr;
612 struct iocblk *iocp; /* outgoing ioctl structure */
613 struct termio *termiop;
614 struct termios *termiosp;
615 mblk_t *dack_ptr; /* disconnect message ACK block */
616 mblk_t *pckt_msgp; /* message sent to the PCKT module */
617 mblk_t *dp; /* ioctl reply data */
618 tcflag_t cflags;
619 int error;
620
621 switch (mp->b_datap->db_type) {
622
623 case M_IOCTL:
624 /*
625 * Note: for each "set" type operation a copy
626 * of the M_IOCTL message is made and passed
627 * downstream. Eventually the PCKT module, if
628 * it has been pushed, should pick up this message.
629 * If the PCKT module has not been pushed the master
630 * side stream head will free it.
631 */
632 iocp = (struct iocblk *)mp->b_rptr;
633 switch (iocp->ioc_cmd) {
634
635 case TCSETAF:
636 case TCSETSF:
637 /*
638 * Flush the read queue.
639 */
640 if (putnextctl1(q, M_FLUSH, FLUSHR) == 0) {
641 miocnak(q, mp, 0, EAGAIN);
642 break;
643 }
644 /* FALLTHROUGH */
645
646 case TCSETA:
647 case TCSETAW:
648 case TCSETS:
649 case TCSETSW:
826 qreply(q, bp);
827 }
828
829 putnext(q, pckt_msgp);
830 mioc2ack(mp, NULL, 0, 0);
831 qreply(q, mp);
832 break;
833
834 case PTSSTTY:
835 if (ntp->state & IS_PTSTTY) {
836 miocnak(q, mp, 0, EEXIST);
837 } else {
838 ntp->state |= IS_PTSTTY;
839 mioc2ack(mp, NULL, 0, 0);
840 qreply(q, mp);
841 }
842 break;
843
844 default:
845 /*
846 * End of the line. The slave driver doesn't see any
847 * ioctls that we don't explicitly pass along to it.
848 */
849 miocnak(q, mp, 0, EINVAL);
850 break;
851 }
852 break;
853
854 case M_DELAY: /* tty delays not supported */
855 freemsg(mp);
856 break;
857
858 case M_DATA:
859 if ((mp->b_wptr - mp->b_rptr) < 0) {
860 /*
861 * Free all bad length messages.
862 */
863 freemsg(mp);
864 break;
865 } else if ((mp->b_wptr - mp->b_rptr) == 0) {
866 if (!(ntp->state & IS_PTSTTY)) {
867 freemsg(mp);
966 }
967
968 wb = (struct winsize *)mp->b_cont->b_rptr;
969 /*
970 * Send a SIGWINCH signal if the row/col information has
971 * changed.
972 */
973 if ((tp->wsz.ws_row != wb->ws_row) ||
974 (tp->wsz.ws_col != wb->ws_col) ||
975 (tp->wsz.ws_xpixel != wb->ws_xpixel) ||
976 (tp->wsz.ws_ypixel != wb->ws_xpixel)) {
977 /*
978 * SIGWINCH is always sent upstream.
979 */
980 if (qside == WRSIDE)
981 (void) putnextctl1(RD(q), M_SIG, SIGWINCH);
982 else if (qside == RDSIDE)
983 (void) putnextctl1(q, M_SIG, SIGWINCH);
984 /*
985 * Message may have come in as an M_IOCDATA; pass it
986 * to the master side as an M_IOCTL.
987 */
988 mp->b_datap->db_type = M_IOCTL;
989 if (qside == WRSIDE) {
990 /*
991 * Need a copy of this message to pass on to
992 * the PCKT module, only if the M_IOCTL
993 * orginated from the slave side.
994 */
995 if ((pckt_msgp = copymsg(mp)) == NULL) {
996 miocnak(q, mp, 0, EAGAIN);
997 return;
998 }
999 putnext(q, pckt_msgp);
1000 }
1001 tp->wsz.ws_row = wb->ws_row;
1002 tp->wsz.ws_col = wb->ws_col;
1003 tp->wsz.ws_xpixel = wb->ws_xpixel;
1004 tp->wsz.ws_ypixel = wb->ws_ypixel;
1005 }
1006
1007 mioc2ack(mp, NULL, 0, 0);
1008 qreply(q, mp);
1009 return;
1010
1011 case TIOCSIGNAL: {
1012 /*
1013 * This ioctl can emanate from the master side in remote
1014 * mode only.
1015 */
1016 int sig;
1017
1018 if (DB_TYPE(mp) == M_IOCTL && iocp->ioc_count != TRANSPARENT) {
1019 error = miocpullup(mp, sizeof (int));
1020 if (error != 0) {
1021 miocnak(q, mp, 0, error);
1022 return;
1023 }
1024 }
1025
1026 if (DB_TYPE(mp) == M_IOCDATA || iocp->ioc_count != TRANSPARENT)
1027 sig = *(int *)mp->b_cont->b_rptr;
1028 else
1029 sig = (int)*(intptr_t *)mp->b_cont->b_rptr;
1030
1031 if (sig < 1 || sig >= NSIG) {
1032 miocnak(q, mp, 0, EINVAL);
1033 return;
1034 }
1035
1036 /*
1037 * Send an M_PCSIG message up the slave's read side and
1038 * respond back to the master with an ACK or NAK as
1039 * appropriate.
1040 */
1041 if (putnextctl1(q, M_PCSIG, sig) == 0) {
1042 miocnak(q, mp, 0, EAGAIN);
1043 return;
1044 }
1045
1046 mioc2ack(mp, NULL, 0, 0);
1047 qreply(q, mp);
1048 return;
1049 }
1050
1051 case TIOCREMOTE: {
1052 int onoff;
1053 mblk_t *mctlp;
1054
1055 if (DB_TYPE(mp) == M_IOCTL) {
1056 error = miocpullup(mp, sizeof (int));
1057 if (error != 0) {
1058 miocnak(q, mp, 0, error);
|
384 case TIOCREMOTE:
385 ptioc(q, mp, RDSIDE);
386 break;
387
388 case JWINSIZE:
389 case TIOCGWINSZ:
390 mp->b_datap->db_type = M_IOCACK;
391 mioc2ack(mp, NULL, 0, 0);
392 qreply(q, mp);
393 break;
394
395 default:
396 freemsg(mp);
397 break;
398 }
399 break;
400
401 case M_IOCACK:
402 case M_IOCNAK:
403 /*
404 * We only pass write-side ioctls through to the manager that
405 * we've already ACKed or NAKed to the stream head. Thus, we
406 * discard ones arriving from below, since they're redundant
407 * from the point of view of modules above us.
408 */
409 freemsg(mp);
410 break;
411
412 case M_HANGUP:
413 /*
414 * clear blocked state.
415 */
416 {
417 struct ptem *ntp = (struct ptem *)q->q_ptr;
418 if (ntp->state & OFLOW_CTL) {
419 ntp->state &= ~OFLOW_CTL;
420 qenable(WR(q));
421 }
422 }
423 /* FALLTHROUGH */
424 default:
609 ptemwmsg(queue_t *q, mblk_t *mp)
610 {
611 struct ptem *ntp = (struct ptem *)q->q_ptr;
612 struct iocblk *iocp; /* outgoing ioctl structure */
613 struct termio *termiop;
614 struct termios *termiosp;
615 mblk_t *dack_ptr; /* disconnect message ACK block */
616 mblk_t *pckt_msgp; /* message sent to the PCKT module */
617 mblk_t *dp; /* ioctl reply data */
618 tcflag_t cflags;
619 int error;
620
621 switch (mp->b_datap->db_type) {
622
623 case M_IOCTL:
624 /*
625 * Note: for each "set" type operation a copy
626 * of the M_IOCTL message is made and passed
627 * downstream. Eventually the PCKT module, if
628 * it has been pushed, should pick up this message.
629 * If the PCKT module has not been pushed the manager
630 * side stream head will free it.
631 */
632 iocp = (struct iocblk *)mp->b_rptr;
633 switch (iocp->ioc_cmd) {
634
635 case TCSETAF:
636 case TCSETSF:
637 /*
638 * Flush the read queue.
639 */
640 if (putnextctl1(q, M_FLUSH, FLUSHR) == 0) {
641 miocnak(q, mp, 0, EAGAIN);
642 break;
643 }
644 /* FALLTHROUGH */
645
646 case TCSETA:
647 case TCSETAW:
648 case TCSETS:
649 case TCSETSW:
826 qreply(q, bp);
827 }
828
829 putnext(q, pckt_msgp);
830 mioc2ack(mp, NULL, 0, 0);
831 qreply(q, mp);
832 break;
833
834 case PTSSTTY:
835 if (ntp->state & IS_PTSTTY) {
836 miocnak(q, mp, 0, EEXIST);
837 } else {
838 ntp->state |= IS_PTSTTY;
839 mioc2ack(mp, NULL, 0, 0);
840 qreply(q, mp);
841 }
842 break;
843
844 default:
845 /*
846 * End of the line. The subsidiary driver doesn't see
847 * any ioctls that we don't explicitly pass along to
848 * it.
849 */
850 miocnak(q, mp, 0, EINVAL);
851 break;
852 }
853 break;
854
855 case M_DELAY: /* tty delays not supported */
856 freemsg(mp);
857 break;
858
859 case M_DATA:
860 if ((mp->b_wptr - mp->b_rptr) < 0) {
861 /*
862 * Free all bad length messages.
863 */
864 freemsg(mp);
865 break;
866 } else if ((mp->b_wptr - mp->b_rptr) == 0) {
867 if (!(ntp->state & IS_PTSTTY)) {
868 freemsg(mp);
967 }
968
969 wb = (struct winsize *)mp->b_cont->b_rptr;
970 /*
971 * Send a SIGWINCH signal if the row/col information has
972 * changed.
973 */
974 if ((tp->wsz.ws_row != wb->ws_row) ||
975 (tp->wsz.ws_col != wb->ws_col) ||
976 (tp->wsz.ws_xpixel != wb->ws_xpixel) ||
977 (tp->wsz.ws_ypixel != wb->ws_xpixel)) {
978 /*
979 * SIGWINCH is always sent upstream.
980 */
981 if (qside == WRSIDE)
982 (void) putnextctl1(RD(q), M_SIG, SIGWINCH);
983 else if (qside == RDSIDE)
984 (void) putnextctl1(q, M_SIG, SIGWINCH);
985 /*
986 * Message may have come in as an M_IOCDATA; pass it
987 * to the manager side as an M_IOCTL.
988 */
989 mp->b_datap->db_type = M_IOCTL;
990 if (qside == WRSIDE) {
991 /*
992 * Need a copy of this message to pass on to
993 * the PCKT module, only if the M_IOCTL
994 * orginated from the subsidiary side.
995 */
996 if ((pckt_msgp = copymsg(mp)) == NULL) {
997 miocnak(q, mp, 0, EAGAIN);
998 return;
999 }
1000 putnext(q, pckt_msgp);
1001 }
1002 tp->wsz.ws_row = wb->ws_row;
1003 tp->wsz.ws_col = wb->ws_col;
1004 tp->wsz.ws_xpixel = wb->ws_xpixel;
1005 tp->wsz.ws_ypixel = wb->ws_ypixel;
1006 }
1007
1008 mioc2ack(mp, NULL, 0, 0);
1009 qreply(q, mp);
1010 return;
1011
1012 case TIOCSIGNAL: {
1013 /*
1014 * This ioctl can emanate from the manager side in remote
1015 * mode only.
1016 */
1017 int sig;
1018
1019 if (DB_TYPE(mp) == M_IOCTL && iocp->ioc_count != TRANSPARENT) {
1020 error = miocpullup(mp, sizeof (int));
1021 if (error != 0) {
1022 miocnak(q, mp, 0, error);
1023 return;
1024 }
1025 }
1026
1027 if (DB_TYPE(mp) == M_IOCDATA || iocp->ioc_count != TRANSPARENT)
1028 sig = *(int *)mp->b_cont->b_rptr;
1029 else
1030 sig = (int)*(intptr_t *)mp->b_cont->b_rptr;
1031
1032 if (sig < 1 || sig >= NSIG) {
1033 miocnak(q, mp, 0, EINVAL);
1034 return;
1035 }
1036
1037 /*
1038 * Send an M_PCSIG message up the subsidiary's read side and
1039 * respond back to the manager with an ACK or NAK as
1040 * appropriate.
1041 */
1042 if (putnextctl1(q, M_PCSIG, sig) == 0) {
1043 miocnak(q, mp, 0, EAGAIN);
1044 return;
1045 }
1046
1047 mioc2ack(mp, NULL, 0, 0);
1048 qreply(q, mp);
1049 return;
1050 }
1051
1052 case TIOCREMOTE: {
1053 int onoff;
1054 mblk_t *mctlp;
1055
1056 if (DB_TYPE(mp) == M_IOCTL) {
1057 error = miocpullup(mp, sizeof (int));
1058 if (error != 0) {
1059 miocnak(q, mp, 0, error);
|