Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / net_inject.9f
blobc446e3637022d69d5d57ecd0d4f2ff658561c84a
1 '\" te
2 .\" Copyright (C) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH NET_INJECT 9F "May 1, 2008"
7 .SH NAME
8 net_inject \- determine if a network interface name exists for a network
9 protocol
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/neti.h>
15 \fBint\fR \fBnet_inject\fR(\fBconst\fR \fBnet_data_t\fR \fInet\fR, \fBinject_t\fR \fIstyle\fR,
16       \fBnet_inject_t\fR *\fIpacket\fR);
17 .fi
19 .SH INTERFACE LEVEL
20 .sp
21 .LP
22 Solaris DDI specific (Solaris DDI).
23 .SH PARAMETERS
24 .sp
25 .ne 2
26 .na
27 \fB\fInet\fR\fR
28 .ad
29 .RS 10n
30 value returned from a successful call to \fBnet_protocol_lookup\fR(9F).
31 .RE
33 .sp
34 .ne 2
35 .na
36 \fB\fIstyle\fR\fR
37 .ad
38 .RS 10n
39 method that determines how this packet is to be injected into the network or
40 kernel.
41 .RE
43 .sp
44 .ne 2
45 .na
46 \fB\fIpacket\fR\fR
47 .ad
48 .RS 10n
49 details about the packet to be injected.
50 .RE
52 .SH DESCRIPTION
53 .sp
54 .LP
55 The \fBnet_inject()\fR function provides an interface to allow delivery of
56 network layer (layer 3) packets either into the kernel or onto the network. The
57 method of delivery is determined by style.
58 .sp
59 .LP
60 If \fBNI_QUEUE_IN\fR is specified, the packet is scheduled for delivery up into
61 the kernel, imitating its reception by a network interface. In this mode,
62 \fBpacket->ni_addr\fR is ignored and \fB packet->ni_physical\fR  specifies the
63 interface for which the packet is made to appear as if it arrived on.
64 .sp
65 .LP
66 If \fBNI_QUEUE_OUT\fR is specified, the packet is scheduled for delivery out of
67 the kernel, as if it were being sent by a raw socket. In this mode,
68 \fBpacket->ni_addr\fR and \fBpacket->ni_physical\fR are both ignored.
69 .sp
70 .LP
71 Neither \fBNI_QUEUE_IN\fR or \fBNI_QUEUE_OUT\fR cause the packet to be
72 immediately processed by the kernel. Instead, the packet is added to a list and
73 a timeout is scheduled (if there are none already pending) to deliver the
74 packet. The  call to \fBnet_inject()\fR returns once the setup has been
75 completed, and not after the packet has been processed. The packet processing
76 is completed on a different thread and in a different context to that of the
77 original packet. Thus, a packet queued up using \fBnet_inject()\fR for either
78 \fBNI_QUEUE_IN\fR or \fBNI_QUEUE_OUT\fR is presented to the packet event again.
79 A packet received by a hook from \fBNH_PHYSICAL_IN\fR and then queued up with
80 \fBNI_QUEUE_IN\fR is seen by the hook as another \fBNH_PHYSICAL_IN\fR packet.
81 This also applies to both \fBNH_PHYSICAL_OUT\fR and \fBNI_QUEUE_OUT\fR packets.
82 .sp
83 .LP
84 If \fBNI_DIRECT_OUT\fR is specified, an attempt is made to send the packet out
85 to a network interface immediately. No processing on the packet, aside from
86 prepending any required layer 2 information, is made. In this instance,
87 \fBpacket->ni_addr\fR may be used to specify the next hop (for the purpose of
88 link layer address resolution) and \fBpacket->ni_physical\fR determines which
89 interface the packet should be sent out.
90 .sp
91 .LP
92 For all three packets, \fBpacket->ni_packet\fR must point to an \fBmblk\fR
93 structure with the packet to be delivered.
94 .sp
95 .LP
96 See \fBnet_inject_t\fR(9S) for more details on the structure
97 \fBnet_inject_t\fR.
98 .SH RETURN VALUES
99 .sp
101 The \fBnet_inject()\fR function returns:
103 .ne 2
105 \fB-1\fR
107 .RS 6n
108 The network protocol does not support this function.
112 .ne 2
114 \fB0\fR
116 .RS 6n
117 The packet is successfully queued or sent.
121 .ne 2
123 \fB1\fR
125 .RS 6n
126 The packet could not be queued up or sent out immediately.
129 .SH CONTEXT
132 The \fBnet_inject()\fR function may be called from user,  kernel, or interrupt
133 context.
134 .SH ATTRIBUTES
137 See \fBattributes\fR(5) for descriptions of the following attributes:
142 box;
143 c | c
144 l | l .
145 ATTRIBUTE TYPE  ATTRIBUTE VALUE
147 Interface Stability     Committed
150 .SH SEE ALSO
153 \fBnet_protocol_lookup\fR(9F), \fBnetinfo\fR(9F), \fBnet_inject_t\fR(9S)