xref: /openbsd-src/share/man/man9/if_get.9 (revision 3106ab340dcb50c20a5dced4de5940b11de81fee)
1*3106ab34Smvs.\" $OpenBSD: if_get.9,v 1.3 2021/01/18 09:55:43 mvs Exp $
2c4d76bc3Smpi.\"
3c4d76bc3Smpi.\" Copyright (c) 2015 Martin Pieuchot
4c4d76bc3Smpi.\"
5c4d76bc3Smpi.\" Permission to use, copy, modify, and distribute this software for any
6c4d76bc3Smpi.\" purpose with or without fee is hereby granted, provided that the above
7c4d76bc3Smpi.\" copyright notice and this permission notice appear in all copies.
8c4d76bc3Smpi.\"
9c4d76bc3Smpi.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10c4d76bc3Smpi.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11c4d76bc3Smpi.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12c4d76bc3Smpi.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13c4d76bc3Smpi.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14c4d76bc3Smpi.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15c4d76bc3Smpi.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16c4d76bc3Smpi.\"
17*3106ab34Smvs.Dd $Mdocdate: January 18 2021 $
18c4d76bc3Smpi.Dt IF_GET 9
19c4d76bc3Smpi.Os
20c4d76bc3Smpi.Sh NAME
21c4d76bc3Smpi.Nm if_get ,
22*3106ab34Smvs.Nm if_unit ,
23c4d76bc3Smpi.Nm if_put
24c4d76bc3Smpi.Nd get an interface pointer from an interface index
25c4d76bc3Smpi.Sh SYNOPSIS
26c4d76bc3Smpi.In net/if.h
27c4d76bc3Smpi.Ft struct ifnet *
28c4d76bc3Smpi.Fn if_get "unsigned int ifidx"
29*3106ab34Smvs.Ft struct ifnet *
30*3106ab34Smvs.Fn if_unit "const char *name"
31c4d76bc3Smpi.Ft void
32c4d76bc3Smpi.Fn if_put "struct ifnet *ifp"
33c4d76bc3Smpi.Sh DESCRIPTION
34c4d76bc3SmpiThe
35c4d76bc3Smpi.Fn if_get
36c4d76bc3Smpifunction returns a pointer to the interface descriptor corresponding to the
37c4d76bc3Smpiunique index
38c4d76bc3Smpi.Fa ifidx .
39c4d76bc3SmpiThis descriptor is guaranteed to be valid until
40c4d76bc3Smpi.Fn if_put
41c4d76bc3Smpiis called on the returned pointer.
42c4d76bc3Smpi.Pp
43c4d76bc3SmpiThe index value
44c4d76bc3Smpi.Dv 0
45decd3de3Sjmcis never associated with an interface descriptor and can be used to determine if
46decd3de3Sjmcan interface index is valid or not.
47c4d76bc3Smpi.Pp
48c4d76bc3SmpiThe
49*3106ab34Smvs.Fn if_unit
50*3106ab34Smvsfunction returns a pointer to the interface descriptor corresponding to the
51*3106ab34Smvsunique name
52*3106ab34Smvs.Fa name .
53*3106ab34SmvsThis descriptor is guaranteed to be valid until
54*3106ab34Smvs.Fn if_put
55*3106ab34Smvsis called on the returned pointer.
56*3106ab34Smvs.Pp
57*3106ab34SmvsThe
58c4d76bc3Smpi.Fn if_put
59c4d76bc3Smpifunction releases a reference on the interface descriptor pointed by
60c4d76bc3Smpi.Fa ifp .
61c4d76bc3SmpiIf
62c4d76bc3Smpi.Fa ifp
63c4d76bc3Smpiis a
64c4d76bc3Smpi.Dv NULL
65c4d76bc3Smpipointer, no action occurs.
66c4d76bc3Smpi.Sh CONTEXT
67c4d76bc3Smpi.Fn if_get ,
68*3106ab34Smvs.Fn if_unit
69c4d76bc3Smpiand
70c4d76bc3Smpi.Fn if_put
71c4d76bc3Smpican be called during autoconf, from process context, or from interrupt context.
72c4d76bc3Smpi.Sh RETURN VALUES
73c4d76bc3Smpi.Fn if_get
74c4d76bc3Smpireturns a pointer to an interface descriptor if the index is valid, otherwise
75c4d76bc3Smpi.Dv NULL .
76*3106ab34Smvs.Pp
77*3106ab34Smvs.Fn if_unit
78*3106ab34Smvsreturns a pointer to an interface descriptor if the interface with present
79*3106ab34Smvsname exists, otherwise
80*3106ab34Smvs.Dv NULL .
81