4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012 Nexenta Systems, Inc. All rights reserved.
24 */
25
26 #include <sys/param.h>
27 #include <sys/types.h>
28 #include <sys/stream.h>
29 #include <sys/strsubr.h>
30 #include <sys/strsun.h>
31 #include <sys/stropts.h>
32 #include <sys/zone.h>
33 #include <sys/vnode.h>
34 #include <sys/sysmacros.h>
35 #define _SUN_TPI_VERSION 2
36 #include <sys/tihdr.h>
37 #include <sys/ddi.h>
38 #include <sys/sunddi.h>
39 #include <sys/mkdev.h>
40 #include <sys/debug.h>
41 #include <sys/kmem.h>
42 #include <sys/cmn_err.h>
43 #include <sys/suntpi.h>
44 #include <sys/policy.h>
45 #include <sys/dls.h>
46
47 #include <sys/socket.h>
48 #include <netinet/in.h>
49 #include <net/pfkeyv2.h>
50 #include <net/pfpolicy.h>
51
52 #include <inet/common.h>
53 #include <netinet/ip6.h>
54 #include <inet/ip.h>
55 #include <inet/ip6.h>
56 #include <inet/mi.h>
3387 if (((union T_primitives *)mp->b_rptr)->type ==
3388 T_SVR4_OPTMGMT_REQ) {
3389 svr4_optcom_req(q, mp, cr, &spdsock_opt_obj);
3390 } else {
3391 tpi_optcom_req(q, mp, cr, &spdsock_opt_obj);
3392 }
3393 break;
3394 case T_DATA_REQ:
3395 case T_EXDATA_REQ:
3396 case T_ORDREL_REQ:
3397 /* Illegal for spdsock. */
3398 freemsg(mp);
3399 (void) putnextctl1(RD(q), M_ERROR, EPROTO);
3400 break;
3401 default:
3402 /* Not supported by spdsock. */
3403 spdsock_err_ack(q, mp, TNOTSUPPORT, 0);
3404 break;
3405 }
3406 return;
3407 case M_IOCTL:
3408 iocp = (struct iocblk *)mp->b_rptr;
3409 error = EINVAL;
3410
3411 switch (iocp->ioc_cmd) {
3412 case ND_SET:
3413 case ND_GET:
3414 if (nd_getset(q, spds->spds_g_nd, mp)) {
3415 qreply(q, mp);
3416 return;
3417 } else
3418 error = ENOENT;
3419 /* FALLTHRU */
3420 default:
3421 miocnak(q, mp, 0, error);
3422 return;
3423 }
3424 case M_FLUSH:
3425 if (*mp->b_rptr & FLUSHW) {
3426 flushq(q, FLUSHALL);
3427 *mp->b_rptr &= ~FLUSHW;
3428 }
3429 if (*mp->b_rptr & FLUSHR) {
3430 qreply(q, mp);
3431 return;
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012 Nexenta Systems, Inc. All rights reserved.
24 * Copyright 2017 Joyent, Inc.
25 */
26
27 #include <sys/param.h>
28 #include <sys/types.h>
29 #include <sys/stream.h>
30 #include <sys/strsubr.h>
31 #include <sys/strsun.h>
32 #include <sys/stropts.h>
33 #include <sys/zone.h>
34 #include <sys/vnode.h>
35 #include <sys/sysmacros.h>
36 #define _SUN_TPI_VERSION 2
37 #include <sys/tihdr.h>
38 #include <sys/timod.h>
39 #include <sys/ddi.h>
40 #include <sys/sunddi.h>
41 #include <sys/mkdev.h>
42 #include <sys/debug.h>
43 #include <sys/kmem.h>
44 #include <sys/cmn_err.h>
45 #include <sys/suntpi.h>
46 #include <sys/policy.h>
47 #include <sys/dls.h>
48
49 #include <sys/socket.h>
50 #include <netinet/in.h>
51 #include <net/pfkeyv2.h>
52 #include <net/pfpolicy.h>
53
54 #include <inet/common.h>
55 #include <netinet/ip6.h>
56 #include <inet/ip.h>
57 #include <inet/ip6.h>
58 #include <inet/mi.h>
3389 if (((union T_primitives *)mp->b_rptr)->type ==
3390 T_SVR4_OPTMGMT_REQ) {
3391 svr4_optcom_req(q, mp, cr, &spdsock_opt_obj);
3392 } else {
3393 tpi_optcom_req(q, mp, cr, &spdsock_opt_obj);
3394 }
3395 break;
3396 case T_DATA_REQ:
3397 case T_EXDATA_REQ:
3398 case T_ORDREL_REQ:
3399 /* Illegal for spdsock. */
3400 freemsg(mp);
3401 (void) putnextctl1(RD(q), M_ERROR, EPROTO);
3402 break;
3403 default:
3404 /* Not supported by spdsock. */
3405 spdsock_err_ack(q, mp, TNOTSUPPORT, 0);
3406 break;
3407 }
3408 return;
3409 case M_IOCDATA:
3410 keysock_spdsock_wput_iocdata(q, mp, PF_POLICY);
3411 return;
3412 case M_IOCTL:
3413 iocp = (struct iocblk *)mp->b_rptr;
3414 error = EINVAL;
3415
3416 switch (iocp->ioc_cmd) {
3417 case TI_GETMYNAME:
3418 case TI_GETPEERNAME:
3419 /*
3420 * For pfiles(1) observability with getsockname().
3421 * See keysock_spdsock_wput_iocdata() for the rest of
3422 * this.
3423 */
3424 mi_copyin(q, mp, NULL,
3425 SIZEOF_STRUCT(strbuf, iocp->ioc_flag));
3426 return;
3427 case ND_SET:
3428 case ND_GET:
3429 if (nd_getset(q, spds->spds_g_nd, mp)) {
3430 qreply(q, mp);
3431 return;
3432 } else
3433 error = ENOENT;
3434 /* FALLTHRU */
3435 default:
3436 miocnak(q, mp, 0, error);
3437 return;
3438 }
3439 case M_FLUSH:
3440 if (*mp->b_rptr & FLUSHW) {
3441 flushq(q, FLUSHALL);
3442 *mp->b_rptr &= ~FLUSHW;
3443 }
3444 if (*mp->b_rptr & FLUSHR) {
3445 qreply(q, mp);
3446 return;
|