base: Eliminate macros in base/inet.hh|cc.

The macro in base/inet.hh, HOME_ADDRESS_OPTION, was not used by
anything. The IP6_EXTENSION macro was replaced with a static inline
function called ip6Extension. The awkward nested ternary operator was
replaced with an equivalent ||.

Change-Id: I100894811159b39b964a49c43a09d493d1268739
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45739
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2021-05-18 17:52:26 -07:00
parent 0fd71ca168
commit e0750c7a76
2 changed files with 15 additions and 10 deletions

View File

@@ -274,12 +274,18 @@ IpHdr::options(std::vector<const IpOpt *> &vec) const
return true;
}
#define IP6_EXTENSION(nxt) (nxt == IP_PROTO_HOPOPTS) ? true : \
(nxt == IP_PROTO_ROUTING) ? true : \
(nxt == IP_PROTO_FRAGMENT) ? true : \
(nxt == IP_PROTO_AH) ? true : \
(nxt == IP_PROTO_ESP) ? true: \
(nxt == IP_PROTO_DSTOPTS) ? true : false
namespace
{
bool
ip6Extension(uint8_t nxt)
{
return nxt == IP_PROTO_HOPOPTS || nxt == IP_PROTO_ROUTING ||
nxt == IP_PROTO_FRAGMENT || nxt == IP_PROTO_AH ||
nxt == IP_PROTO_ESP || nxt == IP_PROTO_DSTOPTS;
}
} // anonymous namespace
/* Scan the IP6 header for all header extensions
* and return the number of headers found
@@ -292,7 +298,7 @@ Ip6Hdr::extensionLength() const
int len = 0;
int all = plen();
while (IP6_EXTENSION(nxt)) {
while (ip6Extension(nxt)) {
const Ip6Opt *ext = (const Ip6Opt *)data;
nxt = ext->nxt();
len += ext->len();
@@ -315,7 +321,7 @@ Ip6Hdr::getExt(uint8_t ext_type) const
Ip6Opt* opt = NULL;
int all = plen();
while (IP6_EXTENSION(nxt)) {
while (ip6Extension(nxt)) {
opt = (Ip6Opt *)data;
if (nxt == ext_type) {
break;
@@ -340,7 +346,7 @@ Ip6Hdr::proto() const
uint8_t nxt = ip6_nxt;
int all = plen();
while (IP6_EXTENSION(nxt)) {
while (ip6Extension(nxt)) {
const Ip6Opt *ext = (const Ip6Opt *)data;
nxt = ext->nxt();
data += ext->len();

View File

@@ -565,7 +565,6 @@ struct ip6_opt_routing_type2
ip6_addr_t addr;
};
#define HOME_ADDRESS_OPTION 0xC9
struct GEM5_PACKED ip6_opt_dstopts
{
uint8_t type;