intf.h revision 6017:7e310503019e
1/* 2 * intf.c 3 * 4 * Network interface operations. 5 * 6 * Copyright (c) 2000 Dug Song <dugsong@monkey.org> 7 * 8 * $Id: intf.h,v 1.16 2004/01/13 07:41:09 dugsong Exp $ 9 */ 10 11#ifndef DNET_INTF_H 12#define DNET_INTF_H 13 14/* 15 * Interface entry 16 */ 17#define INTF_NAME_LEN 16 18 19struct intf_entry { 20 u_int intf_len; /* length of entry */ 21 char intf_name[INTF_NAME_LEN]; /* interface name */ 22 u_short intf_type; /* interface type (r/o) */ 23 u_short intf_flags; /* interface flags */ 24 u_int intf_mtu; /* interface MTU */ 25 struct addr intf_addr; /* interface address */ 26 struct addr intf_dst_addr; /* point-to-point dst */ 27 struct addr intf_link_addr; /* link-layer address */ 28 u_int intf_alias_num; /* number of aliases */ 29 struct addr intf_alias_addrs __flexarr; /* array of aliases */ 30}; 31 32/* 33 * MIB-II interface types - http://www.iana.org/assignments/ianaiftype-mib 34 */ 35#define INTF_TYPE_OTHER 1 /* other */ 36#define INTF_TYPE_ETH 6 /* Ethernet */ 37#define INTF_TYPE_TOKENRING 9 /* Token Ring */ 38#define INTF_TYPE_FDDI 15 /* FDDI */ 39#define INTF_TYPE_PPP 23 /* Point-to-Point Protocol */ 40#define INTF_TYPE_LOOPBACK 24 /* software loopback */ 41#define INTF_TYPE_SLIP 28 /* Serial Line Interface Protocol */ 42#define INTF_TYPE_TUN 53 /* proprietary virtual/internal */ 43 44/* 45 * Interface flags 46 */ 47#define INTF_FLAG_UP 0x01 /* enable interface */ 48#define INTF_FLAG_LOOPBACK 0x02 /* is a loopback net (r/o) */ 49#define INTF_FLAG_POINTOPOINT 0x04 /* point-to-point link (r/o) */ 50#define INTF_FLAG_NOARP 0x08 /* disable ARP */ 51#define INTF_FLAG_BROADCAST 0x10 /* supports broadcast (r/o) */ 52#define INTF_FLAG_MULTICAST 0x20 /* supports multicast (r/o) */ 53 54typedef struct intf_handle intf_t; 55 56typedef int (*intf_handler)(const struct intf_entry *entry, void *arg); 57 58__BEGIN_DECLS 59intf_t *intf_open(void); 60int intf_get(intf_t *i, struct intf_entry *entry); 61int intf_get_src(intf_t *i, struct intf_entry *entry, struct addr *src); 62int intf_get_dst(intf_t *i, struct intf_entry *entry, struct addr *dst); 63int intf_set(intf_t *i, const struct intf_entry *entry); 64int intf_loop(intf_t *i, intf_handler callback, void *arg); 65intf_t *intf_close(intf_t *i); 66__END_DECLS 67 68#endif /* DNET_INTF_H */ 69