Print this page
onc plus-be-gone

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/timod.c
          +++ new/usr/src/uts/common/io/timod.c
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21      -/* ONC_PLUS EXTRACT START */
  22   21  /*
  23   22   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24   23   * Use is subject to license terms.
  25   24   */
  26   25  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  27   26  /*        All Rights Reserved   */
  28   27  
  29   28  
  30   29  /*
  31   30   * Transport Interface Library cooperating module - issue 2
  32   31   */
  33   32  
  34      -/* ONC_PLUS EXTRACT END */
  35   33  #include <sys/param.h>
  36   34  #include <sys/types.h>
  37   35  #include <sys/stream.h>
  38   36  #include <sys/stropts.h>
  39   37  #include <sys/strsubr.h>
  40   38  #define _SUN_TPI_VERSION 2
  41   39  #include <sys/tihdr.h>
  42   40  #include <sys/timod.h>
  43   41  #include <sys/suntpi.h>
  44   42  #include <sys/debug.h>
↓ open down ↓ 143 lines elided ↑ open up ↑
 188  186   *
 189  187   */
 190  188  #define PEEK_RDQ_EXPIND 0x0001  /* look for expinds on stream rd queues */
 191  189  #define WAITIOCACK      0x0002  /* waiting for info for ioctl act       */
 192  190  #define CLTS            0x0004  /* connectionless transport             */
 193  191  #define COTS            0x0008  /* connection-oriented transport        */
 194  192  #define CONNWAIT        0x0010  /* waiting for connect confirmation     */
 195  193  #define LOCORDREL       0x0020  /* local end has orderly released       */
 196  194  #define REMORDREL       0x0040  /* remote end had orderly released      */
 197  195  #define NAMEPROC        0x0080  /* processing a NAME ioctl              */
 198      -/* ONC_PLUS EXTRACT START */
 199  196  #define DO_MYNAME       0x0100  /* timod handles TI_GETMYNAME           */
 200      -/* ONC_PLUS EXTRACT END */
 201  197  #define DO_PEERNAME     0x0200  /* timod handles TI_GETPEERNAME         */
 202  198  #define TI_CAP_RECVD    0x0400  /* TI_CAPABILITY received               */
 203  199  #define CAP_WANTS_INFO  0x0800  /* TI_CAPABILITY has TC1_INFO set       */
 204  200  #define WAIT_IOCINFOACK 0x1000  /* T_INFO_REQ generated from ioctl      */
 205  201  #define WAIT_CONNRESACK 0x2000  /* waiting for T_OK_ACK to T_CONN_RES   */
 206  202  
 207  203  
 208  204  /* Debugging facilities */
 209  205  /*
 210  206   * Logging needed for debugging timod should only appear in DEBUG kernel.
↓ open down ↓ 95 lines elided ↑ open up ↑
 306  302  static void tim_addlink(struct tim_tim  *);
 307  303  static void tim_dellink(struct tim_tim  *);
 308  304  static struct tim_tim *tim_findlink(t_uscalar_t);
 309  305  static void tim_recover(queue_t *, mblk_t *, t_scalar_t);
 310  306  static void tim_ioctl_retry(queue_t *);
 311  307  
 312  308  int dotilog = 0;
 313  309  
 314  310  #define TIMOD_ID        3
 315  311  
 316      -/* ONC_PLUS EXTRACT START */
 317  312  static int timodopen(queue_t *, dev_t *, int, int, cred_t *);
 318      -/* ONC_PLUS EXTRACT END */
 319  313  static int timodclose(queue_t *, int, cred_t *);
 320  314  static void timodwput(queue_t *, mblk_t *);
 321  315  static void timodrput(queue_t *, mblk_t *);
 322      -/* ONC_PLUS EXTRACT START */
 323  316  static void timodrsrv(queue_t *);
 324      -/* ONC_PLUS EXTRACT END */
 325  317  static void timodwsrv(queue_t *);
 326      -/* ONC_PLUS EXTRACT START */
 327  318  static int timodrproc(queue_t *, mblk_t *);
 328  319  static int timodwproc(queue_t *, mblk_t *);
 329      -/* ONC_PLUS EXTRACT END */
 330  320  
 331  321  /* stream data structure definitions */
 332  322  
 333  323  static struct module_info timod_info =
 334  324          {TIMOD_ID, "timod", 0, INFPSZ, 512, 128};
 335  325  static struct qinit timodrinit = {
 336  326          (int (*)())timodrput,
 337  327          (int (*)())timodrsrv,
 338  328          timodopen,
 339  329          timodclose,
↓ open down ↓ 5 lines elided ↑ open up ↑
 345  335          (int (*)())timodwput,
 346  336          (int (*)())timodwsrv,
 347  337          timodopen,
 348  338          timodclose,
 349  339          nulldev,
 350  340          &timod_info,
 351  341          NULL
 352  342  };
 353  343  static struct streamtab timinfo = { &timodrinit, &timodwinit, NULL, NULL };
 354  344  
 355      -/* ONC_PLUS EXTRACT START */
 356  345  /*
 357  346   * timodopen -  open routine gets called when the module gets pushed
 358  347   *              onto the stream.
 359  348   */
 360  349  /*ARGSUSED*/
 361  350  static int
 362  351  timodopen(
 363  352          queue_t *q,
 364  353          dev_t *devp,
 365  354          int flag,
↓ open down ↓ 115 lines elided ↑ open up ↑
 481  470          if (q->q_flag & QREADR) {
 482  471                  ASSERT(tp->tim_rbufcid);
 483  472                  tp->tim_rbufcid = 0;
 484  473          } else {
 485  474                  ASSERT(tp->tim_wbufcid);
 486  475                  tp->tim_wbufcid = 0;
 487  476          }
 488  477          enableok(q);
 489  478          qenable(q);
 490  479  }
 491      -/* ONC_PLUS EXTRACT END */
 492  480  
 493  481  /*
 494  482   * timodclose - This routine gets called when the module gets popped
 495  483   * off of the stream.
 496  484   */
 497  485  /*ARGSUSED*/
 498  486  static int
 499  487  timodclose(
 500  488          queue_t *q,
 501  489          int flag,
↓ open down ↓ 128 lines elided ↑ open up ↑
 630  618                          (void) timodrproc(q, mp);
 631  619                          break;
 632  620                  }
 633  621                  break;
 634  622          default:
 635  623                  (void) timodrproc(q, mp);
 636  624                  break;
 637  625          }
 638  626  }
 639  627  
 640      -/* ONC_PLUS EXTRACT START */
 641  628  /*
 642  629   * timodrsrv -  Module read queue service procedure.  This is called when
 643  630   *              messages are placed on an empty queue, when high priority
 644  631   *              messages are placed on the queue, and when flow control
 645  632   *              restrictions subside.  This code used to be included in a
 646  633   *              put procedure, but it was moved to a service procedure
 647  634   *              because several points were added where memory allocation
 648  635   *              could fail, and there is no reasonable recovery mechanism
 649  636   *              from the put procedure.
 650  637   */
 651  638  /*ARGSUSED*/
 652  639  static void
 653  640  timodrsrv(queue_t *q)
 654  641  {
 655      -/* ONC_PLUS EXTRACT END */
 656  642          mblk_t *mp;
 657  643          struct tim_tim *tp;
 658  644  
 659  645          ASSERT(q != NULL);
 660  646  
 661  647          tp = (struct tim_tim *)q->q_ptr;
 662  648          if (!tp)
 663  649                  return;
 664  650  
 665  651          while ((mp = getq(q)) != NULL) {
 666  652                  if (timodrproc(q, mp)) {
 667  653                          /*
 668  654                           * timodrproc did a putbq - stop processing
 669  655                           * messages.
 670  656                           */
 671  657                          return;
 672  658                  }
 673  659          }
 674      -/* ONC_PLUS EXTRACT START */
 675  660  }
 676  661  
 677  662  /*
 678  663   * Perform common processing when a T_CAPABILITY_ACK or T_INFO_ACK
 679  664   * arrive.  Set the queue properties and adjust the tim_flags according
 680  665   * to the service type.
 681  666   */
 682  667  static void
 683  668  timodprocessinfo(queue_t *q, struct tim_tim *tp, struct T_info_ack *tia)
 684  669  {
↓ open down ↓ 9 lines elided ↑ open up ↑
 694  679  
 695  680  static int
 696  681  timodrproc(queue_t *q, mblk_t *mp)
 697  682  {
 698  683          uint32_t auditing = AU_AUDITING();
 699  684          union T_primitives *pptr;
 700  685          struct tim_tim *tp;
 701  686          struct iocblk *iocbp;
 702  687          mblk_t *nbp;
 703  688          size_t blen;
 704      -/* ONC_PLUS EXTRACT END */
 705  689  
 706  690          tp = (struct tim_tim *)q->q_ptr;
 707  691  
 708      -/* ONC_PLUS EXTRACT START */
 709  692          switch (mp->b_datap->db_type) {
 710  693          default:
 711  694                  putnext(q, mp);
 712  695                  break;
 713  696  
 714  697          case M_ERROR:
 715  698                  TILOG("timodrproc: Got M_ERROR, flags = %x\n", tp->tim_flags);
 716  699                  /*
 717  700                   * There is no specified standard response for driver when it
 718  701                   * receives unknown message type and M_ERROR is one
↓ open down ↓ 60 lines elided ↑ open up ↑
 779  762                                  (void) putbq(q, mp);
 780  763                                  return (1);
 781  764                          }
 782  765                          putnext(q, mp);
 783  766                          break;
 784  767                  }
 785  768  
 786  769                  pptr = (union T_primitives *)mp->b_rptr;
 787  770                  switch (pptr->type) {
 788  771                  default:
 789      -/* ONC_PLUS EXTRACT END */
 790  772  
 791  773                          if (auditing)
 792  774                                  audit_sock(T_UNITDATA_IND, q, mp, TIMOD_ID);
 793      -/* ONC_PLUS EXTRACT START */
 794  775                          putnext(q, mp);
 795  776                          break;
 796      -/* ONC_PLUS EXTRACT END */
 797  777  
 798  778                  case T_ERROR_ACK:
 799  779                          /* Restore db_type - recover() might have changed it */
 800  780                          mp->b_datap->db_type = M_PCPROTO;
 801  781                          if (blen < sizeof (struct T_error_ack)) {
 802  782                                  putnext(q, mp);
 803  783                                  break;
 804  784                          }
 805  785  
 806  786                          tilog("timodrproc: Got T_ERROR_ACK, flags = %x\n",
↓ open down ↓ 89 lines elided ↑ open up ↑
 896  876                                  tp->tim_flags &=
 897  877                                      ~(WAIT_CONNRESACK | WAITIOCACK);
 898  878                                  freemsg(tp->tim_iocsave);
 899  879                                  tp->tim_iocsave = NULL;
 900  880                                  tp->tim_saved_prim = -1;
 901  881                          }
 902  882  
 903  883                          tim_send_reply(q, mp, tp, pptr->ok_ack.CORRECT_prim);
 904  884                          break;
 905  885  
 906      -/* ONC_PLUS EXTRACT START */
 907  886                  case T_BIND_ACK: {
 908  887                          struct T_bind_ack *ackp =
 909  888                              (struct T_bind_ack *)mp->b_rptr;
 910  889  
 911  890                          /* Restore db_type - recover() might have changed it */
 912  891                          mp->b_datap->db_type = M_PCPROTO;
 913  892                          if (blen < sizeof (*ackp)) {
 914  893                                  putnext(q, mp);
 915  894                                  break;
 916  895                          }
↓ open down ↓ 43 lines elided ↑ open up ↑
 960  939                                      tp->tim_myname, tp->tim_mylen);
 961  940                          }
 962  941                          tim_ioctl_send_reply(q, tp->tim_iocsave, mp);
 963  942                          tp->tim_iocsave = NULL;
 964  943                          tp->tim_saved_prim = -1;
 965  944                          tp->tim_flags &= ~(WAITIOCACK | WAIT_IOCINFOACK |
 966  945                              TI_CAP_RECVD | CAP_WANTS_INFO);
 967  946                          break;
 968  947                  }
 969  948  
 970      -/* ONC_PLUS EXTRACT END */
 971  949                  case T_OPTMGMT_ACK:
 972  950  
 973  951                          tilog("timodrproc: Got T_OPTMGMT_ACK\n", 0);
 974  952  
 975  953                          /* Restore db_type - recover() might have change it */
 976  954                          mp->b_datap->db_type = M_PCPROTO;
 977  955  
 978  956                          if (((tp->tim_flags & WAITIOCACK) == 0) ||
 979  957                              ((tp->tim_saved_prim != T_SVR4_OPTMGMT_REQ) &&
 980  958                              (tp->tim_saved_prim != T_OPTMGMT_REQ))) {
↓ open down ↓ 212 lines elided ↑ open up ↑
1193 1171              }
1194 1172  
1195 1173              putnext(q, mp);
1196 1174              break;
1197 1175  
1198 1176              case T_ADDR_ACK:
1199 1177                  tilog("timodrproc: Got T_ADDR_ACK\n", 0);
1200 1178                  tim_send_reply(q, mp, tp, T_ADDR_REQ);
1201 1179                  break;
1202 1180  
1203      -/* ONC_PLUS EXTRACT START */
1204 1181                  case T_CONN_IND: {
1205 1182                          struct T_conn_ind *tcip =
1206 1183                              (struct T_conn_ind *)mp->b_rptr;
1207 1184  
1208 1185                          tilog("timodrproc: Got T_CONN_IND\n", 0);
1209 1186  
1210 1187                          if (blen >= sizeof (*tcip) &&
1211 1188                              MBLKIN(mp, tcip->SRC_offset, tcip->SRC_length)) {
1212 1189                                  if (((nbp = dupmsg(mp)) != NULL) ||
1213 1190                                      ((nbp = copymsg(mp)) != NULL)) {
1214 1191                                          nbp->b_next = tp->tim_consave;
1215 1192                                          tp->tim_consave = nbp;
1216 1193                                  } else {
1217 1194                                          tim_recover(q, mp,
1218 1195                                              (t_scalar_t)sizeof (mblk_t));
1219 1196                                          return (1);
1220 1197                                  }
1221 1198                          }
1222      -/* ONC_PLUS EXTRACT END */
1223 1199                          if (auditing)
1224 1200                                  audit_sock(T_CONN_IND, q, mp, TIMOD_ID);
1225      -/* ONC_PLUS EXTRACT START */
1226 1201                          putnext(q, mp);
1227 1202                          break;
1228 1203                  }
1229 1204  
1230      -/* ONC_PLUS EXTRACT END */
1231 1205              case T_CONN_CON:
1232 1206                  mutex_enter(&tp->tim_mutex);
1233 1207                  if (tp->tim_peercred != NULL)
1234 1208                          crfree(tp->tim_peercred);
1235 1209                  tp->tim_peercred = msg_getcred(mp, &tp->tim_cpid);
1236 1210                  if (tp->tim_peercred != NULL)
1237 1211                          crhold(tp->tim_peercred);
1238 1212                  mutex_exit(&tp->tim_mutex);
1239 1213  
1240 1214                  tilog("timodrproc: Got T_CONN_CON\n", 0);
↓ open down ↓ 92 lines elided ↑ open up ↑
1333 1307  
1334 1308                          if (tca->CAP_bits1 & TC1_INFO)
1335 1309                                  timodprocessinfo(q, tp, &tca->INFO_ack);
1336 1310  
1337 1311                          tim_send_reply(q, mp, tp, T_CAPABILITY_REQ);
1338 1312                  }
1339 1313                  break;
1340 1314              }
1341 1315              break;
1342 1316  
1343      -/* ONC_PLUS EXTRACT START */
1344 1317          case M_FLUSH:
1345 1318  
1346 1319                  tilog("timodrproc: Got M_FLUSH\n", 0);
1347 1320  
1348 1321                  if (*mp->b_rptr & FLUSHR) {
1349 1322                          if (*mp->b_rptr & FLUSHBAND)
1350 1323                                  flushband(q, *(mp->b_rptr + 1), FLUSHDATA);
1351 1324                          else
1352 1325                                  flushq(q, FLUSHDATA);
1353 1326                  }
1354 1327                  putnext(q, mp);
1355 1328                  break;
1356      -/* ONC_PLUS EXTRACT END */
1357 1329  
1358 1330          case M_IOCACK:
1359 1331              iocbp = (struct iocblk *)mp->b_rptr;
1360 1332  
1361 1333              tilog("timodrproc: Got M_IOCACK\n", 0);
1362 1334  
1363 1335              if (iocbp->ioc_cmd == TI_GETMYNAME) {
1364 1336  
1365 1337                  /*
1366 1338                   * Transport provider supports this ioctl,
↓ open down ↓ 55 lines elided ↑ open up ↑
1422 1394                  }
1423 1395                  /* tim_iocsave may already be overwritten. */
1424 1396                  if (tp->tim_saved_prim == -1) {
1425 1397                          freemsg(tp->tim_iocsave);
1426 1398                          tp->tim_iocsave = NULL;
1427 1399                  }
1428 1400              }
1429 1401              putnext(q, mp);
1430 1402              break;
1431 1403  
1432      -/* ONC_PLUS EXTRACT START */
1433 1404          case M_IOCNAK:
1434 1405  
1435 1406                  tilog("timodrproc: Got M_IOCNAK\n", 0);
1436 1407  
1437 1408                  iocbp = (struct iocblk *)mp->b_rptr;
1438 1409                  if (((iocbp->ioc_cmd == TI_GETMYNAME) ||
1439 1410                      (iocbp->ioc_cmd == TI_GETPEERNAME)) &&
1440 1411                      ((iocbp->ioc_error == EINVAL) || (iocbp->ioc_error == 0))) {
1441 1412                          PI_PROVLOCK(tp->tim_provinfo);
1442 1413                          if (iocbp->ioc_cmd == TI_GETMYNAME) {
↓ open down ↓ 12 lines elided ↑ open up ↑
1455 1426                                  tp->tim_iocsave = NULL;
1456 1427                                  tp->tim_flags |= NAMEPROC;
1457 1428                                  if (ti_doname(WR(q), mp) != DONAME_CONT) {
1458 1429                                          tp->tim_flags &= ~NAMEPROC;
1459 1430                                  }
1460 1431                                  break;
1461 1432                          }
1462 1433                  }
1463 1434                  putnext(q, mp);
1464 1435                  break;
1465      -/* ONC_PLUS EXTRACT END */
1466 1436          }
1467 1437  
1468 1438          return (0);
1469 1439  }
1470 1440  
1471      -/* ONC_PLUS EXTRACT START */
1472 1441  /*
1473 1442   * timodwput -  Module write put procedure.  This is called from
1474 1443   *              the module, driver, or stream head upstream/downstream.
1475 1444   *              Handles M_FLUSH, M_DATA and some M_PROTO (T_DATA_REQ,
1476 1445   *              and T_UNITDATA_REQ) messages. All others are queued to
1477 1446   *              be handled by the service procedures.
1478 1447   */
1479 1448  
1480 1449  static void
1481 1450  timodwput(queue_t *q, mblk_t *mp)
↓ open down ↓ 1 lines elided ↑ open up ↑
1483 1452          union T_primitives *pptr;
1484 1453          struct tim_tim *tp;
1485 1454          struct iocblk *iocbp;
1486 1455  
1487 1456          /*
1488 1457           * Enqueue normal-priority messages if our queue already
1489 1458           * holds some messages for deferred processing but don't
1490 1459           * enqueue those M_IOCTLs which will result in an
1491 1460           * M_PCPROTO (ie, high priority) message being created.
1492 1461           */
1493      -/* ONC_PLUS EXTRACT END */
1494 1462          if (q->q_first != 0 && mp->b_datap->db_type < QPCTL) {
1495 1463                  if (mp->b_datap->db_type == M_IOCTL) {
1496 1464                          iocbp = (struct iocblk *)mp->b_rptr;
1497 1465                          switch (iocbp->ioc_cmd) {
1498 1466                          default:
1499 1467                                  (void) putq(q, mp);
1500 1468                                  return;
1501 1469  
1502 1470                          case TI_GETINFO:
1503 1471                          case TI_SYNC:
1504 1472                          case TI_CAPABILITY:
1505 1473                                  break;
1506 1474                          }
1507 1475                  } else {
1508 1476                          (void) putq(q, mp);
1509 1477                          return;
1510 1478                  }
1511 1479          }
1512      -/* ONC_PLUS EXTRACT START */
1513 1480          /*
1514 1481           * Inline processing of data (to avoid additional procedure call).
1515 1482           * Rest is handled in timodwproc.
1516 1483           */
1517 1484  
1518 1485          switch (mp->b_datap->db_type) {
1519 1486          case M_DATA:
1520 1487                  tp = (struct tim_tim *)q->q_ptr;
1521 1488                  ASSERT(tp);
1522 1489                  if (tp->tim_flags & CLTS) {
↓ open down ↓ 8 lines elided ↑ open up ↑
1531 1498                  }
1532 1499                  if (bcanputnext(q, mp->b_band))
1533 1500                          putnext(q, mp);
1534 1501                  else
1535 1502                          (void) putq(q, mp);
1536 1503                  break;
1537 1504          case M_PROTO:
1538 1505          case M_PCPROTO:
1539 1506                  pptr = (union T_primitives *)mp->b_rptr;
1540 1507                  switch (pptr->type) {
1541      -/* ONC_PLUS EXTRACT END */
1542 1508                  case T_UNITDATA_REQ:
1543 1509                          tp = (struct tim_tim *)q->q_ptr;
1544 1510                          ASSERT(tp);
1545 1511                          if (tp->tim_flags & CLTS) {
1546 1512                                  mblk_t  *tmp;
1547 1513  
1548 1514                                  tmp = tim_filladdr(q, mp, B_FALSE);
1549 1515                                  if (tmp == NULL) {
1550 1516                                          (void) putq(q, mp);
1551 1517                                          break;
↓ open down ↓ 12 lines elided ↑ open up ↑
1564 1530                          if (bcanputnext(q, mp->b_band))
1565 1531                                  putnext(q, mp);
1566 1532                          else
1567 1533                                  (void) putq(q, mp);
1568 1534                          break;
1569 1535                  default:
1570 1536                          (void) timodwproc(q, mp);
1571 1537                          break;
1572 1538                  }
1573 1539                  break;
1574      -/* ONC_PLUS EXTRACT START */
1575 1540          default:
1576 1541                  (void) timodwproc(q, mp);
1577 1542                  break;
1578 1543          }
1579 1544  }
1580 1545  /*
1581 1546   * timodwsrv -  Module write queue service procedure.
1582 1547   *              This is called when messages are placed on an empty queue,
1583 1548   *              when high priority messages are placed on the queue, and
1584 1549   *              when flow control restrictions subside.  This code used to
↓ open down ↓ 35 lines elided ↑ open up ↑
1620 1585          mblk_t *tmp;
1621 1586          struct iocblk *iocbp;
1622 1587          int error;
1623 1588  
1624 1589          tp = (struct tim_tim *)q->q_ptr;
1625 1590  
1626 1591          switch (mp->b_datap->db_type) {
1627 1592          default:
1628 1593                  putnext(q, mp);
1629 1594                  break;
1630      -/* ONC_PLUS EXTRACT END */
1631 1595  
1632 1596          case M_DATA:
1633 1597                  if (tp->tim_flags & CLTS) {
1634 1598                          if ((tmp = tim_filladdr(q, mp, B_TRUE)) == NULL) {
1635 1599                                  return (1);
1636 1600                          } else {
1637 1601                                  mp = tmp;
1638 1602                          }
1639 1603                  }
1640 1604                  if (!bcanputnext(q, mp->b_band)) {
1641 1605                          (void) putbq(q, mp);
1642 1606                          return (1);
1643 1607                  }
1644 1608                  putnext(q, mp);
1645 1609                  break;
1646 1610  
1647      -/* ONC_PLUS EXTRACT START */
1648 1611          case M_IOCTL:
1649 1612  
1650 1613                  iocbp = (struct iocblk *)mp->b_rptr;
1651 1614                  TILOG("timodwproc: Got M_IOCTL(%d)\n", iocbp->ioc_cmd);
1652 1615  
1653 1616                  ASSERT(MBLKL(mp) == sizeof (struct iocblk));
1654 1617  
1655 1618                  /*
1656 1619                   * TPI requires we await response to a previously sent message
1657 1620                   * before handling another, put it back on the head of queue.
↓ open down ↓ 4 lines elided ↑ open up ↑
1662 1625                   */
1663 1626                  if (tp->tim_flags & WAITIOCACK) {
1664 1627                          TILOG("timodwproc: putbq M_IOCTL(%d)\n",
1665 1628                              iocbp->ioc_cmd);
1666 1629                          (void) putbq(q, mp);
1667 1630                          /* Called from timodwsrv() and messages on queue */
1668 1631                          if (!(q->q_flag & QWANTR))
1669 1632                                  tim_ioctl_retry(q);
1670 1633                          return (1);
1671 1634                  }
1672      -/* ONC_PLUS EXTRACT END */
1673 1635  
1674 1636                  switch (iocbp->ioc_cmd) {
1675 1637                  default:
1676 1638                          putnext(q, mp);
1677 1639                          break;
1678 1640  
1679 1641                  case _I_GETPEERCRED:
1680 1642                          if ((tp->tim_flags & COTS) == 0) {
1681 1643                                  miocnak(q, mp, 0, ENOTSUP);
1682 1644                          } else {
↓ open down ↓ 229 lines elided ↑ open up ↑
1912 1874  
1913 1875                          default:
1914 1876                                  cmn_err(CE_PANIC,
1915 1877                                      "timodwproc: unknown tpi_capability value "
1916 1878                                      "%d\n", tp->tim_provinfo->tpi_capability);
1917 1879                                  break;
1918 1880                          }
1919 1881                  }
1920 1882                  break;
1921 1883  
1922      -/* ONC_PLUS EXTRACT START */
1923 1884                  case TI_GETMYNAME:
1924 1885  
1925 1886                          tilog("timodwproc: Got TI_GETMYNAME\n", 0);
1926 1887  
1927 1888                          if (tp->tim_provinfo->tpi_myname == PI_YES) {
1928 1889                                  putnext(q, mp);
1929 1890                                  break;
1930 1891                          }
1931 1892                          goto getname;
1932 1893  
↓ open down ↓ 49 lines elided ↑ open up ↑
1982 1943                  case T_DATA_REQ:
1983 1944                          if (pptr->type == T_EXDATA_REQ)
1984 1945                                  tilog("timodwproc: Got T_EXDATA_REQ\n", 0);
1985 1946  
1986 1947                  if (!bcanputnext(q, mp->b_band)) {
1987 1948                          (void) putbq(q, mp);
1988 1949                          return (1);
1989 1950                  }
1990 1951                  putnext(q, mp);
1991 1952                  break;
1992      -/* ONC_PLUS EXTRACT END */
1993 1953  
1994 1954                  case T_UNITDATA_REQ:
1995 1955                          if (tp->tim_flags & CLTS) {
1996 1956                                  tmp = tim_filladdr(q, mp, B_TRUE);
1997 1957                                  if (tmp == NULL) {
1998 1958                                          return (1);
1999 1959                                  } else {
2000 1960                                          mp = tmp;
2001 1961                                  }
2002 1962                          }
2003 1963                          if (auditing)
2004 1964                                  audit_sock(T_UNITDATA_REQ, q, mp, TIMOD_ID);
2005 1965                  if (!bcanputnext(q, mp->b_band)) {
2006 1966                                  (void) putbq(q, mp);
2007 1967                                  return (1);
2008 1968                          }
2009 1969                          putnext(q, mp);
2010 1970                          break;
2011 1971  
2012      -/* ONC_PLUS EXTRACT START */
2013 1972                  case T_CONN_REQ: {
2014 1973                          struct T_conn_req *reqp = (struct T_conn_req *)
2015 1974                              mp->b_rptr;
2016 1975                          void *p;
2017 1976  
2018 1977                          tilog("timodwproc: Got T_CONN_REQ\n", 0);
2019 1978  
2020 1979                          if (MBLKL(mp) < sizeof (struct T_conn_req)) {
2021 1980                                  merror(q, mp, EPROTO);
2022 1981                                  return (1);
↓ open down ↓ 25 lines elided ↑ open up ↑
2048 2007                                          tp->tim_peername = p;
2049 2008                                          tp->tim_peermaxlen = reqp->DEST_length;
2050 2009                                  }
2051 2010                                  tp->tim_peerlen = reqp->DEST_length;
2052 2011                                  p = mp->b_rptr + reqp->DEST_offset;
2053 2012                                  bcopy(p, tp->tim_peername, tp->tim_peerlen);
2054 2013                                  mutex_exit(&tp->tim_mutex);
2055 2014                          }
2056 2015                          if (tp->tim_flags & COTS)
2057 2016                                  tp->tim_flags |= CONNWAIT;
2058      -/* ONC_PLUS EXTRACT END */
2059 2017                          if (auditing)
2060 2018                                  audit_sock(T_CONN_REQ, q, mp, TIMOD_ID);
2061      -/* ONC_PLUS EXTRACT START */
2062 2019                  putnext(q, mp);
2063 2020                  break;
2064 2021                  }
2065 2022  
2066 2023                  case O_T_CONN_RES:
2067 2024                  case T_CONN_RES: {
2068 2025                          struct T_conn_res *resp;
2069 2026                          struct T_conn_ind *indp;
2070 2027                          mblk_t *pmp = NULL;
2071 2028                          mblk_t *nbp;
↓ open down ↓ 40 lines elided ↑ open up ↑
2112 2069                          freemsg(tp->tim_iocsave);
2113 2070                          tp->tim_iocsave = nbp;
2114 2071                          tp->tim_saved_prim = pptr->type;
2115 2072                          tp->tim_flags |= WAIT_CONNRESACK | WAITIOCACK;
2116 2073  
2117 2074                  cresout:
2118 2075                          putnext(q, mp);
2119 2076                          break;
2120 2077                  }
2121 2078  
2122      -/* ONC_PLUS EXTRACT END */
2123 2079                  case T_DISCON_REQ: {
2124 2080                          struct T_discon_req *disp;
2125 2081                          struct T_conn_ind *conp;
2126 2082                          mblk_t *pmp = NULL;
2127 2083  
2128 2084                          if (MBLKL(mp) < sizeof (struct T_discon_req)) {
2129 2085                                  merror(q, mp, EPROTO);
2130 2086                                  return (1);
2131 2087                          }
2132 2088  
↓ open down ↓ 35 lines elided ↑ open up ↑
2168 2124  
2169 2125                  case T_CAPABILITY_REQ:
2170 2126                          tilog("timodwproc: Got T_CAPABILITY_REQ\n", 0);
2171 2127                          /*
2172 2128                           * XXX: We may know at this point whether transport
2173 2129                           * provides T_CAPABILITY_REQ or not and we may utilise
2174 2130                           * this knowledge here.
2175 2131                           */
2176 2132                          putnext(q, mp);
2177 2133                          break;
2178      -/* ONC_PLUS EXTRACT START */
2179 2134                  }
2180 2135                  break;
2181 2136          case M_FLUSH:
2182 2137  
2183 2138                  tilog("timodwproc: Got M_FLUSH\n", 0);
2184 2139  
2185 2140                  if (*mp->b_rptr & FLUSHW) {
2186 2141                          if (*mp->b_rptr & FLUSHBAND)
2187 2142                                  flushband(q, *(mp->b_rptr + 1), FLUSHDATA);
2188 2143                          else
↓ open down ↓ 250 lines elided ↑ open up ↑
2439 2394          default:
2440 2395                  tilog("ti_doname: freeing bad message type = %d\n",
2441 2396                      mp->b_datap->db_type);
2442 2397                  freemsg(mp);
2443 2398                  ret = DONAME_FAIL;
2444 2399                  break;
2445 2400          }
2446 2401          return (ret);
2447 2402  }
2448 2403  
2449      -/* ONC_PLUS EXTRACT END */
2450 2404  
2451 2405  /*
2452 2406   * Fill in the address of a connectionless data packet if a connect
2453 2407   * had been done on this endpoint.
2454 2408   */
2455 2409  static mblk_t *
2456 2410  tim_filladdr(queue_t *q, mblk_t *mp, boolean_t dorecover)
2457 2411  {
2458 2412          mblk_t *bp;
2459 2413          struct tim_tim *tp;
↓ open down ↓ 113 lines elided ↑ open up ↑
2573 2527          ASSERT(rw_lock_held(&tim_list_rwlock));
2574 2528  
2575 2529          for (tp = tim_hash[TIM_HASH(id)]; tp != NULL; tp = tp->tim_next) {
2576 2530                  if (tp->tim_acceptor == id) {
2577 2531                          break;
2578 2532                  }
2579 2533          }
2580 2534          return (tp);
2581 2535  }
2582 2536  
2583      -/* ONC_PLUS EXTRACT START */
2584 2537  static void
2585 2538  tim_recover(queue_t *q, mblk_t *mp, t_scalar_t size)
2586 2539  {
2587 2540          struct tim_tim  *tp;
2588 2541          bufcall_id_t    bid;
2589 2542          timeout_id_t    tid;
2590 2543  
2591 2544          tp = (struct tim_tim *)q->q_ptr;
2592 2545  
2593 2546          /*
↓ open down ↓ 90 lines elided ↑ open up ↑
2684 2637                          }
2685 2638                          bp = bp->b_next; /* next message */
2686 2639                  }
2687 2640                  mutex_exit(QLOCK(rq));
2688 2641                  rq = rq->q_next;        /* next upstream queue */
2689 2642          } while (rq != NULL);
2690 2643          releasestr(q);
2691 2644          return (0);             /* no expdata on read queues */
2692 2645  }
2693 2646  
2694      -/* ONC_PLUS EXTRACT END */
2695 2647  static void
2696 2648  tim_tcap_timer(void *q_ptr)
2697 2649  {
2698 2650          queue_t *q = (queue_t *)q_ptr;
2699 2651          struct tim_tim *tp = (struct tim_tim *)q->q_ptr;
2700 2652  
2701 2653          ASSERT(tp != NULL && tp->tim_tcap_timoutid != 0);
2702 2654          ASSERT((tp->tim_flags & TI_CAP_RECVD) != 0);
2703 2655  
2704 2656          tp->tim_tcap_timoutid = 0;
↓ open down ↓ 326 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX