Native Datatypes
In order to work across a wide variety of platforms, libdnet specifies a series of native intermediate datatypes to represent different networking primitives (addressing, interfaces, and firewalling). These datatypes enable libdnet to maintain an operating system agnostic stance while still providing robust functionality. The datatypes are high-level enough that the application programmer can work with them, but they also contain enough information for libdnet to internally translate them to their operating system-specific counterpart.
struct addr {
struct addr is a partially opaque structure used to represent a network address.
u_short addr_type;
addr_type is the type of address contained in the structure.
u_short addr_bits;
addr_bits is the size of the address in bits contained in the structure.
Other members of this structure are internal to libdnet, and the application programmer does not need to know about them.
};
struct arp_entry {
In the ARP cache functions, struct arp_entry describes an ARP table entry.
struct addr arp_pa;
arp_pa is the ARP protocol address.
struct addr arp_ha;
arp_ha is the ARP hardware address.
};
struct route_entry {
In the ARP cache functions, struct route_entry describes an ARP table entry.
struct addr route_dst;
route_dst is the destination address.
struct addr route_gw;
route_gw is the default gateway to get to that destination address.
};
struct intf_entry {
struct intf_entry describes a network interface.
u_int intf_len;
intf_len is the length of the entry.
char intf_name[60];
intf_name is the canonical name of the interface.
u_short intf_type;
intf_type is a bitmask for the type of interface.
u_short intf_flags;
intf_flags are the flags set on the interface.
u_int intf_mtu;
intf_mtu is the maximum transmission unit (MTU) of the interface.
struct addr intf_addr;
intf_addr is the interface's network address.
struct addr intf_dst_addr;
intf_dst_addr is the interface's point-to-point destination address (for things like PPP).
struct addr intf_link_addr;
intf_link_addr is the interface's link-layer address.
u_int intf_alias_num;
intf_alias_num is the number of aliases for the interface.
struct addr intf_alias_addr_flexarr;
intf_alias_addr is the array of aliases for the interface.
};
struct fw_rule {
fw_rule describes a firewall rule.
char fw_device[14];
fw_device is the canonical name of the interface to which the rule applies (in other words, "fxp0", "eth0", and "any").
uint8_t fw_op:4,
fw_op is the type of operation (FW_OP_ALLOW or FW_OP_BLOCK).
fw_dir:4;
fw_dir is the direction in which the rule should be applied (FW_DIR_IN or FW_DIR_OUT).
uint8_t fw_proto;
fw_proto is the protocol to which the rule applies (IP_PROTO_IP, IP_PROTO_TCP, IP_PROTO_ICMP, and so on).
struct addr fw_src;
fw_src is the source IP address to which the rule applies.
struct addr fw_dst;
fw_dst is the destination IP address to which the rule applies.
uint16_t fw_sport[2];
fw_sport is the source port range of the rule or the ICMP type and mask.
uint16_t fw_dport[2];
fw_dport is the destination port range of the rule or the ICMP code and mask.
};
arp_t
arp_t refers to an ARP handle used in the ARP family of functions.
route_t
route_t refers to a route handle used in the route table family of functions.
intf_t
intf_t refers to an interface handle used in the interface family of functions.
fw_t
fw_t refers to a firewall handle used in the firewall family of functions.
ip_t
ip_t refers to an IP handle used in the IP packet family of functions.
eth_t
eth_t refers to an Ethernet handle used in the Ethernet frame family of functions.
blob_t
blob_t refers to a blob handle used in the blob buffer management family of functions.
rand_t
rand_t refers to a random number handle used in the random number generation family of functions.
No comments:
Post a Comment