File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libpdel / net / if_util.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:25:53 2012 UTC (13 years, 9 months ago) by misho
Branches: libpdel, MAIN
CVS tags: v0_5_3, HEAD
libpdel

    1: 
    2: /*
    3:  * Copyright (c) 2001-2002 Packet Design, LLC.
    4:  * All rights reserved.
    5:  * 
    6:  * Subject to the following obligations and disclaimer of warranty,
    7:  * use and redistribution of this software, in source or object code
    8:  * forms, with or without modifications are expressly permitted by
    9:  * Packet Design; provided, however, that:
   10:  * 
   11:  *    (i)  Any and all reproductions of the source or object code
   12:  *         must include the copyright notice above and the following
   13:  *         disclaimer of warranties; and
   14:  *    (ii) No rights are granted, in any manner or form, to use
   15:  *         Packet Design trademarks, including the mark "PACKET DESIGN"
   16:  *         on advertising, endorsements, or otherwise except as such
   17:  *         appears in the above copyright notice or in the software.
   18:  * 
   19:  * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
   20:  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
   21:  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
   22:  * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
   23:  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
   24:  * OR NON-INFRINGEMENT.  PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
   25:  * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
   26:  * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
   27:  * RELIABILITY OR OTHERWISE.  IN NO EVENT SHALL PACKET DESIGN BE
   28:  * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
   29:  * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
   30:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
   31:  * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
   32:  * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
   33:  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   34:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
   35:  * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
   36:  * THE POSSIBILITY OF SUCH DAMAGE.
   37:  *
   38:  * Author: Archie Cobbs <archie@freebsd.org>
   39:  */
   40: 
   41: #ifndef _PDEL_NET_IF_UTIL_H_
   42: #define _PDEL_NET_IF_UTIL_H_
   43: 
   44: struct sockaddr_dl;
   45: 
   46: __BEGIN_DECLS
   47: 
   48: /*
   49:  * Gets the names of all system interfaces, returned as an array of
   50:  * char * pointers. Caller must free each pointer and the array itself.
   51:  * Returns the length of the array.
   52:  *
   53:  * Returns -1 and sets errno if there was a problem.
   54:  */
   55: extern int	if_get_list(char ***listp, const char *mtype);
   56: 
   57: /*
   58:  * Get the interface type.
   59:  * Returns -1 and sets errno if there was a problem.
   60:  */
   61: extern int	if_get_type(const char *ifname);
   62: 
   63: /*
   64:  * Get the flags associated with an interface.
   65:  * Returns -1 and sets errno if there was a problem.
   66:  */
   67: extern int	if_get_flags(const char *ifname);
   68: 
   69: /*
   70:  * Set the flags associated with an interface.
   71:  * Returns -1 and sets errno if there was a problem.
   72:  */
   73: extern int	if_set_flags(const char *ifname, int flags);
   74: 
   75: /*
   76:  * Get the MTU associated with an interface.
   77:  * Returns -1 and sets errno if there was a problem.
   78:  */
   79: extern int	if_get_mtu(const char *ifname);
   80: 
   81: /*
   82:  * Set the MTU associated with an interface.
   83:  * Returns -1 and sets errno if there was a problem.
   84:  */
   85: extern int	if_set_mtu(const char *ifname, u_int mtu);
   86: 
   87: /*
   88:  * Get the link address associated with an interface.
   89:  * Caller must free the returned structure.
   90:  *
   91:  * Returns -1 and sets errno if there was a problem.
   92:  */
   93: extern int	if_get_link_addr(const char *ifname,
   94: 			struct sockaddr_dl **sdlp, const char *mtype);
   95: 
   96: /*
   97:  * Get a list of all IP addresses and netmasks configured on an interface.
   98:  * Caller must free both lists. Returns the length of the arrays.
   99:  *
  100:  * Returns -1 and sets errno if there was a problem.
  101:  */
  102: extern int	if_get_ip_addrs(const char *ifname, struct in_addr **iplistp,
  103: 			struct in_addr **nmlistp, const char *mtype);
  104: 
  105: /*
  106:  * Get the first IP address and netmask configured on an interface.
  107:  * "ipp" and/or "nmp" may be NULL. Returns -1 and sets errno on error;
  108:  * in particular, if there are no addresses, then errno will be ENOENT.
  109:  */
  110: extern int	if_get_ip_addr(const char *ifname,
  111: 			struct in_addr *ipp, struct in_addr *nmp);
  112: 
  113: /*
  114:  * Add an IP address assignment to a broadcast or p2p interface.
  115:  * The "dest" should be 0.0.0.0 for non-p2p interfaces.
  116:  *
  117:  * Returns -1 and sets errno if there was a problem.
  118:  */
  119: extern int	if_add_ip_addr(const char *iface, struct in_addr ip,
  120: 			struct in_addr mask, struct in_addr dest);
  121: 
  122: /*
  123:  * Remove an IP address assignment from a broadcast or p2p interface.
  124:  * The "dest" should be 0.0.0.0 for non-p2p interfaces.
  125:  *
  126:  * Returns -1 and sets errno if there was a problem.
  127:  */
  128: extern int	if_del_ip_addr(const char *iface, struct in_addr ip,
  129: 			struct in_addr mask, struct in_addr dest);
  130: 
  131: /*
  132:  * Get an ARP entry.
  133:  *
  134:  * Returns -1 and sets errno if there was a problem.
  135:  * In particular, errno = ENOENT if entry not found.
  136:  */
  137: extern int	if_get_arp(struct in_addr ip, u_char *ether);
  138: 
  139: /*
  140:  * Set (or remove, if ether == NULL) an ARP entry.
  141:  *
  142:  * Returns -1 and sets errno if there was a problem.
  143:  */
  144: extern int	if_set_arp(struct in_addr ip, const u_char *ether,
  145: 			int temp, int publish);
  146: 
  147: /*
  148:  * Flush all ARP entries.
  149:  *
  150:  * Returns -1 and sets errno if there was a problem.
  151:  */
  152: extern int	if_flush_arp(void);
  153: 
  154: __END_DECLS
  155: 
  156: #endif	/* _PDEL_NET_IF_UTIL_H_ */
  157: 

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