Annotation of embedaddon/libpdel/net/uroute.3, revision 1.1.1.1

1.1       misho       1: .\" Copyright (c) 2001-2002 Packet Design, LLC.
                      2: .\" All rights reserved.
                      3: .\" 
                      4: .\" Subject to the following obligations and disclaimer of warranty,
                      5: .\" use and redistribution of this software, in source or object code
                      6: .\" forms, with or without modifications are expressly permitted by
                      7: .\" Packet Design; provided, however, that:
                      8: .\" 
                      9: .\"    (i)  Any and all reproductions of the source or object code
                     10: .\"         must include the copyright notice above and the following
                     11: .\"         disclaimer of warranties; and
                     12: .\"    (ii) No rights are granted, in any manner or form, to use
                     13: .\"         Packet Design trademarks, including the mark "PACKET DESIGN"
                     14: .\"         on advertising, endorsements, or otherwise except as such
                     15: .\"         appears in the above copyright notice or in the software.
                     16: .\" 
                     17: .\" THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
                     18: .\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
                     19: .\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
                     20: .\" THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
                     21: .\" WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
                     22: .\" OR NON-INFRINGEMENT.  PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
                     23: .\" OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
                     24: .\" OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
                     25: .\" RELIABILITY OR OTHERWISE.  IN NO EVENT SHALL PACKET DESIGN BE
                     26: .\" LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
                     27: .\" OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
                     28: .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
                     29: .\" DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
                     30: .\" USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
                     31: .\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     32: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
                     33: .\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
                     34: .\" THE POSSIBILITY OF SUCH DAMAGE.
                     35: .\"
                     36: .\" Author: Archie Cobbs <archie@freebsd.org>
                     37: .\"
                     38: .\" $Id: uroute.3,v 1.5 2004/06/02 17:24:37 archie Exp $
                     39: .\"
                     40: .Dd April 22, 2002
                     41: .Dt UROUTE 3
                     42: .Os
                     43: .Sh NAME
                     44: .Nm uroute
                     45: .Nd networking route objects
                     46: .Sh LIBRARY
                     47: PDEL Library (libpdel, \-lpdel)
                     48: .Sh SYNOPSIS
                     49: .In sys/types.h
                     50: .In sys/socket.h
                     51: .In stdio.h
                     52: .In pdel/net/uroute.h
                     53: .Ft "struct uroute *"
                     54: .Fn uroute_create "const struct sockaddr *dest" "const struct sockaddr *gateway" "const struct sockaddr *netmask"
                     55: .Ft "void"
                     56: .Fn uroute_destroy "struct uroute **routep"
                     57: .Ft "const struct sockaddr *"
                     58: .Fn uroute_get_dest "struct uroute *route"
                     59: .Ft "const struct sockaddr *"
                     60: .Fn uroute_get_gateway "struct uroute *route"
                     61: .Ft "const struct sockaddr *"
                     62: .Fn uroute_get_netmask "struct uroute *route"
                     63: .Ft "int"
                     64: .Fn uroute_get_flags "struct uroute *route"
                     65: .Ft "void"
                     66: .Fn uroute_set_flags "struct uroute *route" "int flags"
                     67: .Ft "int"
                     68: .Fn uroute_add "struct uroute *route"
                     69: .Ft "int"
                     70: .Fn uroute_delete "struct uroute *route"
                     71: .Ft "struct uroute *"
                     72: .Fn uroute_get "const struct sockaddr *dest"
                     73: .Ft "int"
                     74: .Fn uroute_get_all "struct uroute ***listp" "const char *mtype"
                     75: .Ft "void"
                     76: .Fn uroute_print "struct uroute *route" "FILE *fp"
                     77: .Sh DESCRIPTION
                     78: These functions support
                     79: .Nm uroute
                     80: objects, used for representing kernel routes in user code.
                     81: Each
                     82: .Nm uroute
                     83: instance is represented by a
                     84: .Li "struct uroute" .
                     85: .Pp
                     86: .Fn uroute_create
                     87: creates a new
                     88: .Nm uroute
                     89: object using copies of the supplied
                     90: .Fa dest ,
                     91: .Fa gateway ,
                     92: and
                     93: .Fa netmask .
                     94: The
                     95: .Fa netmask
                     96: should be
                     97: .Dv NULL
                     98: to specify a host route instead of a network route.
                     99: .Pp
                    100: .Fn uroute_destroy
                    101: destroys the object pointed to by
                    102: .Fa "*routep" .
                    103: Upon return,
                    104: .Fa "*routep"
                    105: will be set to
                    106: .Dv NULL .
                    107: If
                    108: .Fa "*routep"
                    109: is already
                    110: .Dv NULL
                    111: when
                    112: .Fn uroute_destroy
                    113: is invoked, nothing happens.
                    114: .Pp
                    115: .Fn uroute_get_dest ,
                    116: .Fn uroute_get_gateway ,
                    117: and
                    118: .Fn uroute_get_netmask
                    119: return the addresses associated with the route.
                    120: Note that
                    121: .Fn uroute_get_netmask
                    122: returns
                    123: .Dv NULL
                    124: to indicate that
                    125: .Fa route
                    126: is a host route.
                    127: .Pp
                    128: .Fn uroute_get_flags
                    129: and
                    130: .Fn uroute_set_flags
                    131: are used to access or modify the flags associated with the route;
                    132: these flags are defined in the header file
                    133: .Li "<net/route.h>" .
                    134: The only flag set for a newly created route is
                    135: .Dv RTF_STATIC .
                    136: .Pp
                    137: .Fn uroute_add
                    138: attempts to add the
                    139: .Fa route
                    140: to the kernel routing table.
                    141: .Pp
                    142: .Fn uroute_delete
                    143: attempts to remove the
                    144: .Fa route
                    145: from the kernel routing table.
                    146: .Pp
                    147: .Fn uroute_get
                    148: attempts to retrieve the route matching
                    149: .Fa dest
                    150: from the kernel routing table.
                    151: .Pp
                    152: .Fn uroute_get_all
                    153: retrieves the entire kernel routing table.
                    154: Zero or more
                    155: .Nm uroute
                    156: objects are constructed and pointed to by the elements of a newly
                    157: allocated array of pointers.
                    158: The length of the array is returned by
                    159: .Fn uroute_get_all
                    160: and a pointer to the array is stored in
                    161: .Fa "*listp" .
                    162: The array itself is allocated with
                    163: .Xr typed_mem 3
                    164: type
                    165: .Fa mtype ,
                    166: and the caller is responsible for eventually freeing it (as well as
                    167: destroying the individudal
                    168: .Nm uroute
                    169: objects).
                    170: .Pp
                    171: .Fn uroute_print
                    172: prints out
                    173: .Fa uroute
                    174: to the stream
                    175: .Fa fp
                    176: for debugging purposes.
                    177: .Sh RETURN VALUES
                    178: .Fn uroute_create ,
                    179: .Fn uroute_add ,
                    180: .Fn uroute_delete ,
                    181: .Fn uroute_get ,
                    182: and
                    183: .Fn uroute_get_all
                    184: return -1 or
                    185: .Dv NULL
                    186: to indicate an error, with
                    187: .Va errno
                    188: set appropriately.
                    189: .Sh SEE ALSO
                    190: .Xr if_util 3 ,
                    191: .Xr libpdel 3 ,
                    192: .Xr typed_mem 3 ,
                    193: .Xr route_msg 3 ,
                    194: .Xr route 4
                    195: .Sh HISTORY
                    196: The PDEL library was developed at Packet Design, LLC.
                    197: .Dv "http://www.packetdesign.com/"
                    198: .Sh AUTHORS
                    199: .An Archie Cobbs Aq archie@freebsd.org

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>