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