📄 addressinfo.hh
字号:
// -*- c-basic-offset: 2; related-file-name: "../../../elements/standard/addressinfo.cc" -*-#ifndef CLICK_ADDRESSINFO_HH#define CLICK_ADDRESSINFO_HH#include <click/element.hh>#include <click/hashmap.hh>#ifdef HAVE_IP6# include <click/ip6address.hh>#endifCLICK_DECLS/*=cAddressInfo(NAME ADDRESS [ADDRESS...], ...)=s informationspecifies address information=ioNone=dLets you use mnemonic names for IPv4 and IPv6 addresses, IPv4 and IPv6address prefixes, and Ethernet addresses. Each argument has the form `NAMEADDRESS [ADDRESS...]', which associates the given ADDRESSes with NAME. Forexample, if a configuration contains this AddressInfo element, AddressInfo(mauer 10.0.0.1, mazu 10.0.0.10);then other configuration strings can use C<mauer> and C<mazu> as mnemonicsfor the IP addresses 10.0.0.1 and 10.0.0.10, respectively.The mnemonic names introduced by AddressInfo elements are local withrespect to compound elements. That is, names created inside a compoundelement apply only within that compound element and its subelements. Forexample: AddressInfo(mauer 10.0.0.1); compound :: { AddressInfo(mazu 10.0.0.10); ... -> IPEncap(6, mauer, mazu) -> ... // OK }; ... -> IPEncap(6, mauer, mazu) -> ... // error: `mazu' undefinedAny name can be simultaneously associated with an IP address, an IP networkaddress, and an Ethernet address. The kind of address that is returned isgenerally determined from context. For example: AddressInfo(mauer 10.0.0.1/8 00:50:BA:85:84:A9); ... -> IPEncap(6, mauer, ...) // as IP address -> EtherEncap(0x0800, mauer, ...) -> ... // as Ethernet address ... -> ARPResponder(mauer) -> ... // as IP prefix AND Ethernet address!An optional suffix makes the context unambiguous. C<NAME> is an ambiguousreference to some address, but C<NAME:ip> is always an IPv4 address,C<NAME:ipnet> is always an IPv4 network address (IPv4 address prefix),C<NAME:ip6> is always an IPv6 address, C<NAME:ip6net> is always an IPv6network address, and C<NAME:eth> is always an Ethernet address.=head1 DEFAULT ADDRESSESIf you do not define an address for a given name, AddressInfo will use thedefault, if any. Defaults are as follows:=over 2=item *If DEVNAME is the name of an Ethernet device, then C<DEVNAME:eth> defaults toDEVNAME's Ethernet address. (At userlevel, this works only on BSD and Linux.)=item *C<DEVNAME:ip> defaults to the first primary IPv4 address associated with thedevice DEVNAME.=backThese defaults are not available on all platforms.=aPortInfo */class AddressInfo : public Element { public: AddressInfo(); ~AddressInfo(); const char *class_name() const { return "AddressInfo"; } int configure_phase() const { return CONFIGURE_PHASE_FIRST; } int configure(Vector<String> &, ErrorHandler *); static bool query_ip(String, unsigned char *, Element *); static bool query_ip_prefix(String, unsigned char *, unsigned char *, Element *);#ifdef HAVE_IP6 static bool query_ip6(String, unsigned char *, Element *); static bool query_ip6_prefix(String, unsigned char *, int *, Element *);#endif static bool query_ethernet(String, unsigned char *, Element *);};CLICK_ENDDECLS#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -