summaryrefslogtreecommitdiff
path: root/share/man/man9/if_get.9
blob: 5174d7c26764a9dfc6b37141ed75ba6b271128de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
.\" $OpenBSD: if_get.9,v 1.2 2015/12/08 18:35:51 jmc Exp $
.\"
.\" Copyright (c) 2015 Martin Pieuchot
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: December 8 2015 $
.Dt IF_GET 9
.Os
.Sh NAME
.Nm if_get ,
.Nm if_put
.Nd get an interface pointer from an interface index
.Sh SYNOPSIS
.In net/if.h
.Ft struct ifnet *
.Fn if_get "unsigned int ifidx"
.Ft void
.Fn if_put "struct ifnet *ifp"
.Sh DESCRIPTION
The
.Fn if_get
function returns a pointer to the interface descriptor corresponding to the
unique index
.Fa ifidx .
This descriptor is guaranteed to be valid until
.Fn if_put
is called on the returned pointer.
.Pp
The index value
.Dv 0
is never associated with an interface descriptor and can be used to determine if
an interface index is valid or not.
.Pp
The
.Fn if_put
function releases a reference on the interface descriptor pointed by
.Fa ifp .
If
.Fa ifp
is a
.Dv NULL
pointer, no action occurs.
.Sh CONTEXT
.Fn if_get ,
and
.Fn if_put
can be called during autoconf, from process context, or from interrupt context.
.Sh RETURN VALUES
.Fn if_get
returns a pointer to an interface descriptor if the index is valid, otherwise
.Dv NULL .