openflow build environment setup

This commit is contained in:
2025-11-11 16:45:43 +08:00
parent be0a7ad9b3
commit 50ecb9a23f
2767 changed files with 62766 additions and 649828 deletions

View File

@ -0,0 +1,135 @@
// -*- related-file-name: "../../../elements/standard/addressinfo.cc" -*-
#ifndef CLICK_ADDRESSINFO_HH
#define CLICK_ADDRESSINFO_HH
#include <click/element.hh>
CLICK_DECLS
/*
=c
AddressInfo(NAME ADDRESS [ADDRESS...], ...)
=s information
specifies address information
=io
None
=d
Lets you use mnemonic names for IPv4 and IPv6 addresses, IPv4 and IPv6
address prefixes, and Ethernet addresses. Each argument has the form `NAME
ADDRESS [ADDRESS...]', which associates the given ADDRESSes with NAME. For
example, 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 mnemonics
for the IP addresses 10.0.0.1 and 10.0.0.10, respectively.
The mnemonic names introduced by AddressInfo elements are local with
respect to compound elements. That is, names created inside a compound
element apply only within that compound element and its subelements. For
example:
AddressInfo(mauer 10.0.0.1);
compound :: {
AddressInfo(mazu 10.0.0.10);
... -> IPEncap(6, mauer, mazu) -> ... // OK
};
... -> IPEncap(6, mauer, mazu) -> ... // error: `mazu' undefined
Any name can be simultaneously associated with an IP address, an IP network
address, and an Ethernet address. The kind of address that is returned is
generally determined from context. For example:
AddressInfo(mauer 10.0.0.1 00-50-BA-85-84-A9);
... -> IPEncap(6, mauer, ...) // as IP address
-> EtherEncap(0x0800, mauer, ...) -> ... // as Ethernet address
... -> ARPResponder(mauer) -> ... // as IP address and Ethernet address!
An optional suffix makes the context unambiguous. C<NAME> is an ambiguous
reference 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 IPv6
network address, and C<NAME:eth> is always an Ethernet address.
Names with both address and prefix definitions are preferentially parsed as
addresses. For example:
AddressInfo(boojum 10.0.0.1/24); // defines address and prefix
a1 :: ARPResponder(boojum 00-01-02-03-04-05);
// a1 will have the same configuration as:
a2 :: ARPResponder(10.0.0.1/32 00-01-02-03-04-05);
To prefer the network prefix, use C<NAME:ipnet>.
If C<NAME:ipnet> is a valid IPv4 network address, then C<NAME:bcast> is a
valid IPv4 address equaling the broadcast address for that network. This is
obtained by setting all the host bits in the address prefix to 1.
C<NAME:gw> usually equals the default gateway address for network
C<NAME>. If C<NAME> is a device, then C<NAME:gw> can sometimes be
looked up explicitly; otherwise, C<NAME:gw> is calculated from
C<NAME:ipnet> by setting the lowest-order bit in the network address.
=head1 DEFAULT ADDRESSES
If you do not define an address for a given NAME, AddressInfo will use the
default, if any. Defaults are as follows:
=over 2
=item *
For Ethernet addresses, Click checks for an Ethernet device named NAME, and
uses its address. (At userlevel, this works only on BSD and Linux.)
=item *
For IPv4 addresses, Click checks for a network device named NAME, and uses
its primary IPv4 address.
=item *
For C<NAME:gw>, Click checks for a network device named NAME, and uses its
default gateway.
=back
These defaults are not available on all platforms.
=a
PortInfo */
class AddressInfo : public Element { public:
AddressInfo();
const char *class_name() const { return "AddressInfo"; }
int configure_phase() const { return CONFIGURE_PHASE_FIRST; }
int configure(Vector<String> &conf, ErrorHandler *errh);
enum {
f_nodevice = 1
};
static bool query_ip(const String &s, unsigned char *store, const Element *context, int flags = 0);
static bool query_ip_prefix(String s, unsigned char *store_addr, unsigned char *store_mask, const Element *context, int flags = 0);
#if HAVE_IP6
static bool query_ip6(String s, unsigned char *store, const Element *context, int flags = 0);
static bool query_ip6_prefix(String s, unsigned char *store_addr, int *store_prefixlen, const Element *context, int flags = 0);
#endif
static bool query_ethernet(String s, unsigned char *store, const Element *context, int flags = 0);
private:
static bool query_netdevice(const String &name, unsigned char *store, int type, int len, const Element *context, int flags);
};
CLICK_ENDDECLS
#endif

View File

@ -0,0 +1,48 @@
// -*- related-file-name: "../../../elements/standard/alignmentinfo.cc" -*-
#ifndef CLICK_ALIGNMENTINFO_HH
#define CLICK_ALIGNMENTINFO_HH
#include <click/element.hh>
CLICK_DECLS
/*
* =c
* AlignmentInfo(ELEMENT [MODULUS OFFSET ...], ...)
* =s information
* specifies alignment information
* =io
* None
* =d
* Provides information about the packet alignment specified elements can
* expect. Each configuration argument has the form
* `ELEMENT [MODULUS0 OFFSET0 MODULUS1 OFFSET1 ...]',
* where there are zero or more MODULUS-OFFSET pairs.
* All packets arriving at ELEMENT's
* I<n>th input will start `OFFSETI<n>' bytes
* off from a `MODULUSI<n>'-byte boundary.
* =n
* This element is inserted automatically by click-align(1).
* =a Align, click-align(1)
*/
class AlignmentInfo : public Element { public:
AlignmentInfo();
const char *class_name() const { return "AlignmentInfo"; }
int configure_phase() const { return CONFIGURE_PHASE_INFO; }
int configure(Vector<String> &, ErrorHandler *);
bool query1(const Element *e, int port, int &chunk, int &offset) const;
static bool query(const Element *e, int port, int &chunk, int &offset);
private:
Vector<int> _elem_offset;
Vector<int> _elem_icount;
Vector<int> _chunks;
Vector<int> _offsets;
};
CLICK_ENDDECLS
#endif

View File

@ -0,0 +1,35 @@
// -*- c-basic-offset: 4; related-file-name: "../../../elements/standard/errorelement.cc" -*-
#ifndef CLICK_ERRORELEMENT_HH
#define CLICK_ERRORELEMENT_HH
#include <click/element.hh>
CLICK_DECLS
/*
* =c
* Error(...)
* =s debugging
* always fails
* =d
* The Error element always fails to initialize. It has any number of inputs
* and outputs, and accepts any configuration string without complaint. It is
* useful to prevent a router from initializing while avoiding
* spurious error messages about bad configuration strings or connections.
* =a Message
*/
class ErrorElement : public Element { public:
ErrorElement();
const char *class_name() const { return "Error"; }
const char *port_count() const { return "-/-"; }
const char *processing() const { return AGNOSTIC; }
const char *flow_code() const { return "x/y"; }
int configure(Vector<String> &, ErrorHandler *);
int initialize(ErrorHandler *);
};
CLICK_ENDDECLS
#endif

View File

@ -0,0 +1,71 @@
// -*- c-basic-offset: 4; related-file-name: "../../../elements/standard/portinfo.cc" -*-
#ifndef CLICK_PORTINFO_HH
#define CLICK_PORTINFO_HH
#include <click/element.hh>
CLICK_DECLS
/*
=c
PortInfo(NAME PORT[/PROTOCOL], ...)
=s information
stores named TCP/UDP port information
=io
None
=d
Lets you use mnemonic names for TCP and UDP ports. Each argument has the form
`NAME PORT[/PROTOCOL]', which associates the given PORT/PROTOCOL pair with the
NAME. If PROTOCOL is left off, the NAME applies to both TCP and UDP. For
example, in a configuration containing
PortInfo(ssh 22, http 80),
configuration strings can use C<ssh> and C<http> as mnemonics for the port
numbers 22 and 80, respectively.
PortInfo names are local with respect to compound elements. That is, names
created inside a compound element apply only within that compound element and
its subelements. For example:
PortInfo(src 10);
compound :: {
PortInfo(dst 100);
... -> UDPIPEncap(1.0.0.1, src, 2.0.0.1, dst) -> ... // OK
};
... -> UDPIPEncap(1.0.0.1, src, 2.0.0.1, dst) -> ...
// error: `dst' undefined
=n
If you do not define a port for a given name, PortInfo will use the default,
if any. At user level, PortInfo uses the L<getservbyname(3)> function to look
up ports by name. In the kernel, there are no default ports.
PortInfo will parse arguments containing more than one name, as `C<NAME
PORT/PROTOCOL NAME...>', and comments starting with `C<#>' are ignored. Thus,
lines from F</etc/services> can be used verbatim as PortInfo configuration
arguments.
=a
AddressInfo */
class PortInfo : public Element { public:
PortInfo();
const char *class_name() const { return "PortInfo"; }
int configure_phase() const { return CONFIGURE_PHASE_FIRST; }
int configure(Vector<String> &, ErrorHandler *);
};
CLICK_ENDDECLS
#endif

View File

@ -0,0 +1,104 @@
// -*- c-basic-offset: 4; related-file-name: "../../../elements/standard/scheduleinfo.cc" -*-
#ifndef CLICK_SCHEDULEINFO_HH
#define CLICK_SCHEDULEINFO_HH
#include <click/element.hh>
CLICK_DECLS
/*
=c
ScheduleInfo(ELEMENT PARAM, ...)
=s information
specifies scheduling parameters
=io
None
=d
Provides scheduling parameters for specified elements. Each configuration
argument has the form `ELEMENT PARAM', meaning that the element
named ELEMENT has scheduling parameter PARAM. Scheduling
parameters are real numbers that set how often one element should be
scheduled in relation to another. For example,
if elements A and B have
scheduling parameters 2 and 0.5, respectively, then A will be scheduled
2/0.5 = 4 times as often as B. The default scheduling parameter is 1.
ScheduleInfo elements inside a compound element can specify scheduling
parameters for that compound's components.
Outer ScheduleInfo elements
can specify a ``scheduling parameter'' for the compound
element as a whole. This ``scheduling parameter'' is really a scaling
factor affecting the compound's components. For example, consider this
configuration,
elementclass Compound {
i :: InfiniteSource -> output;
ScheduleInfo(i 0.5);
}
c :: Compound -> Discard;
ScheduleInfo(c 4);
which is the same as the following configuration, after compound elements
are expanded.
c/i :: InfiniteSource -> Discard@3 :: Discard;
c/ScheduleInfo@2 :: ScheduleInfo(i 0.5);
ScheduleInfo@4 :: ScheduleInfo(c 4);
The name of the first ScheduleInfo element starts with `c/', so it is
used to look up scheduling parameters for elements named `c/I<whatever>'.
V<>(This includes all components of the compound element `c'.)
The second ScheduleInfo element, however, has no slash in its name,
so it is used to look up all scheduling parameters,
including scaling factors for compound elements.
The InfiniteSource's final scaling parameter will be 2:
the scaling factor 4 times the local scheduling parameter 0.5.
An outer ScheduleInfo element can override local scheduling parameters.
For example, if the second ScheduleInfo element above was
ScheduleInfo@4 :: ScheduleInfo(c 4, c/i 10.5)
then the InfiniteSource's final scaling parameter would be 10.5.
*/
class ScheduleInfo : public Element { public:
enum { FRAC_BITS = 10 };
ScheduleInfo();
const char* class_name() const { return "ScheduleInfo"; }
int configure_phase() const { return CONFIGURE_PHASE_INFO; }
int configure(Vector<String>&, ErrorHandler*);
bool query(const String&, int&) const;
bool query_prefixes(const String&, int&, String&) const;
static int query(Element*, ErrorHandler*);
static void initialize_task(Element*, Task*, bool sched, ErrorHandler*);
static void initialize_task(Element*, Task*, ErrorHandler*);
static void join_scheduler(Element*, Task*, ErrorHandler*);
};
inline void
ScheduleInfo::initialize_task(Element* e, Task* t, ErrorHandler* errh)
{
initialize_task(e, t, true, errh);
}
inline void
ScheduleInfo::join_scheduler(Element* e, Task* t, ErrorHandler* errh)
{
initialize_task(e, t, true, errh);
}
CLICK_ENDDECLS
#endif

View File

@ -0,0 +1,123 @@
// -*- c-basic-offset: 4 -*-
#ifndef CLICK_STORAGE_HH
#define CLICK_STORAGE_HH
#include <click/machine.hh>
#include <click/atomic.hh>
CLICK_DECLS
class Packet;
class Storage { public:
typedef uint32_t index_type;
typedef int32_t signed_index_type;
static const index_type invalid_index = (index_type) -1;
Storage() : _head(0), _tail(0) { }
operator bool() const { return _head != _tail; }
bool empty() const { return _head == _tail; }
int size() const;
int size(index_type head, index_type tail) const;
int capacity() const { return _capacity; }
index_type head() const { return _head; }
index_type tail() const { return _tail; }
index_type next_i(index_type i) const {
return (i!=_capacity ? i+1 : 0);
}
index_type prev_i(index_type i) const {
return (i!=0 ? i-1 : _capacity);
}
// to be used with care
void set_capacity(index_type c) { _capacity = c; }
inline void set_head(index_type h); // acquire barrier (read pkt)
inline void set_tail(index_type t); // release barrier (write pkt)
inline void set_head_release(index_type h); // release barrier (LIFO)
inline void set_tail_acquire(index_type t); // acquire barrier (LIFO)
inline index_type reserve_tail_atomic();
static inline void packet_memory_barrier(Packet* volatile& packet,
volatile index_type& index)
__attribute__((deprecated));
inline void packet_memory_barrier(Packet* volatile& packet)
__attribute__((deprecated));
protected:
index_type _capacity;
private:
volatile index_type _head;
volatile index_type _tail;
};
inline int
Storage::size(index_type head, index_type tail) const
{
index_type x = tail - head;
return (signed_index_type(x) >= 0 ? x : _capacity + x + 1);
}
inline int
Storage::size() const
{
return size(_head, _tail);
}
inline void
Storage::set_head(index_type h)
{
click_read_fence();
_head = h;
}
inline void
Storage::set_tail(index_type t)
{
click_write_fence();
_tail = t;
}
inline void
Storage::set_head_release(index_type h)
{
click_write_fence();
_head = h;
}
inline void
Storage::set_tail_acquire(index_type t)
{
click_read_fence();
_tail = t;
}
inline Storage::index_type
Storage::reserve_tail_atomic()
{
index_type t, nt;
do {
t = _tail;
nt = next_i(t);
if (nt == _head)
return invalid_index;
} while (atomic_uint32_t::compare_swap(_tail, t, nt) != t);
return t;
}
inline void
Storage::packet_memory_barrier(Packet* volatile& packet, volatile index_type& index)
{
__asm__ volatile("" : : "m" (packet), "m" (index));
}
inline void
Storage::packet_memory_barrier(Packet * volatile &packet)
{
__asm__ volatile("" : : "m" (packet), "m" (_head), "m" (_tail));
}
CLICK_ENDDECLS
#endif

View File

@ -0,0 +1,18 @@
// -*- c-basic-offset: 4 -*-
#ifndef CLICK_THREADSCHED_HH
#define CLICK_THREADSCHED_HH
CLICK_DECLS
class ThreadSched { public:
enum { THREAD_QUIESCENT = -1, THREAD_UNKNOWN = -1000 };
ThreadSched() { }
virtual ~ThreadSched() { }
virtual int initial_home_thread_id(const Element *e);
};
CLICK_ENDDECLS
#endif