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) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
24 * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
25 */
26 /* Copyright (c) 1990 Mentat Inc. */
27
28 #include <sys/sysmacros.h>
29 #include <sys/types.h>
30 #include <sys/stream.h>
31 #include <sys/stropts.h>
32 #include <sys/strlog.h>
33 #include <sys/strsun.h>
34 #define _SUN_TPI_VERSION 2
35 #include <sys/tihdr.h>
36 #include <sys/timod.h>
37 #include <sys/ddi.h>
38 #include <sys/sunddi.h>
39 #include <sys/strsubr.h>
40 #include <sys/suntpi.h>
41 #include <sys/xti_inet.h>
42 #include <sys/kmem.h>
43 #include <sys/cred_impl.h>
44 #include <sys/policy.h>
2330 }
2331 mp1->b_cont = mp;
2332 mp1->b_datap->db_type = M_PROTO;
2333 tudi = (struct T_unitdata_ind *)mp1->b_rptr;
2334 mp1->b_wptr = (uchar_t *)tudi + udi_size;
2335 tudi->PRIM_type = T_UNITDATA_IND;
2336 tudi->SRC_length = sizeof (sin_t);
2337 tudi->SRC_offset = sizeof (struct T_unitdata_ind);
2338 tudi->OPT_offset = sizeof (struct T_unitdata_ind) +
2339 sizeof (sin_t);
2340 udi_size -= (sizeof (struct T_unitdata_ind) + sizeof (sin_t));
2341 tudi->OPT_length = udi_size;
2342 sin = (sin_t *)&tudi[1];
2343 sin->sin_addr.s_addr = ((ipha_t *)rptr)->ipha_src;
2344 sin->sin_port = udpha->uha_src_port;
2345 sin->sin_family = connp->conn_family;
2346 *(uint32_t *)&sin->sin_zero[0] = 0;
2347 *(uint32_t *)&sin->sin_zero[4] = 0;
2348
2349 /*
2350 * Add options if IP_RECVDSTADDR, IP_RECVIF, IP_RECVSLLA or
2351 * IP_RECVTTL has been set.
2352 */
2353 if (udi_size != 0) {
2354 conn_recvancillary_add(connp, recv_ancillary, ira,
2355 &ipps, (uchar_t *)&sin[1], udi_size);
2356 }
2357 } else {
2358 sin6_t *sin6;
2359
2360 /*
2361 * Handle both IPv4 and IPv6 packets for IPv6 sockets.
2362 *
2363 * Normally we only send up the address. If receiving of any
2364 * optional receive side information is enabled, we also send
2365 * that up as options.
2366 */
2367 udi_size = sizeof (struct T_unitdata_ind) + sizeof (sin6_t);
2368
2369 if (recv_ancillary.crb_all != 0) {
2370 udi_size += conn_recvancillary_size(connp,
2371 recv_ancillary, ira, mp, &ipps);
|
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) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
24 * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
25 * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
26 */
27 /* Copyright (c) 1990 Mentat Inc. */
28
29 #include <sys/sysmacros.h>
30 #include <sys/types.h>
31 #include <sys/stream.h>
32 #include <sys/stropts.h>
33 #include <sys/strlog.h>
34 #include <sys/strsun.h>
35 #define _SUN_TPI_VERSION 2
36 #include <sys/tihdr.h>
37 #include <sys/timod.h>
38 #include <sys/ddi.h>
39 #include <sys/sunddi.h>
40 #include <sys/strsubr.h>
41 #include <sys/suntpi.h>
42 #include <sys/xti_inet.h>
43 #include <sys/kmem.h>
44 #include <sys/cred_impl.h>
45 #include <sys/policy.h>
2331 }
2332 mp1->b_cont = mp;
2333 mp1->b_datap->db_type = M_PROTO;
2334 tudi = (struct T_unitdata_ind *)mp1->b_rptr;
2335 mp1->b_wptr = (uchar_t *)tudi + udi_size;
2336 tudi->PRIM_type = T_UNITDATA_IND;
2337 tudi->SRC_length = sizeof (sin_t);
2338 tudi->SRC_offset = sizeof (struct T_unitdata_ind);
2339 tudi->OPT_offset = sizeof (struct T_unitdata_ind) +
2340 sizeof (sin_t);
2341 udi_size -= (sizeof (struct T_unitdata_ind) + sizeof (sin_t));
2342 tudi->OPT_length = udi_size;
2343 sin = (sin_t *)&tudi[1];
2344 sin->sin_addr.s_addr = ((ipha_t *)rptr)->ipha_src;
2345 sin->sin_port = udpha->uha_src_port;
2346 sin->sin_family = connp->conn_family;
2347 *(uint32_t *)&sin->sin_zero[0] = 0;
2348 *(uint32_t *)&sin->sin_zero[4] = 0;
2349
2350 /*
2351 * Add options if IP_RECVDSTADDR, IP_RECVIF, IP_RECVSLLA,
2352 * IP_RECVTTL or IP_RECVTOS has been set.
2353 */
2354 if (udi_size != 0) {
2355 conn_recvancillary_add(connp, recv_ancillary, ira,
2356 &ipps, (uchar_t *)&sin[1], udi_size);
2357 }
2358 } else {
2359 sin6_t *sin6;
2360
2361 /*
2362 * Handle both IPv4 and IPv6 packets for IPv6 sockets.
2363 *
2364 * Normally we only send up the address. If receiving of any
2365 * optional receive side information is enabled, we also send
2366 * that up as options.
2367 */
2368 udi_size = sizeof (struct T_unitdata_ind) + sizeof (sin6_t);
2369
2370 if (recv_ancillary.crb_all != 0) {
2371 udi_size += conn_recvancillary_size(connp,
2372 recv_ancillary, ira, mp, &ipps);
|