Skip to content

Commit

Permalink
xorp: Remove InvalidString exception.
Browse files Browse the repository at this point in the history
Latest gcc doesn't like exceptions anymore.

Signed-off-by: Ben Greear <greearb@candelatech.com>
  • Loading branch information
greearb committed Sep 8, 2017
1 parent 296d43d commit 2adeb19
Show file tree
Hide file tree
Showing 68 changed files with 1,370 additions and 1,354 deletions.
102 changes: 62 additions & 40 deletions xorp/bgp/aspath.cc
Expand Up @@ -397,11 +397,12 @@ AS4Segment::encode(size_t &len, uint8_t *data) const
* blank spaces " " can appear at any point in the string.
*/

ASPath::ASPath(const char *as_path) throw(InvalidString)
ASPath::ASPath(const char *as_path)
{
debug_msg("ASPath(%s) constructor called\n", as_path);
_num_segments = 0;
_path_len = 0;
_invalid = false;

// make a copy removing all spaces from the string.

Expand Down Expand Up @@ -435,89 +436,109 @@ ASPath::ASPath(const char *as_path) throw(InvalidString)
// push previous thing and start a new one
add_segment(seg);
seg.clear();
} else if (seg.type() != AS_NONE) // nested, invalid
xorp_throw(InvalidString,
c_format("Illegal character: <%c> %s",
c, path.c_str()));
} else if (seg.type() != AS_NONE) { // nested, invalid
_invalid = true;
XLOG_ERROR("Illegal character: <%c> %s",
c, path.c_str());
return;
}
seg.set_type(AS_SEQUENCE);
} else if (c == ']') {
if (seg.type() == AS_SEQUENCE) {
// push previous thing and start a new one
add_segment(seg);
seg.clear();
} else
xorp_throw(InvalidString,
c_format("Illegal character: <%c> %s",
c, path.c_str()));
} else {
_invalid = true;
XORP_ERROR("Illegal character: <%c> %s",
c, path.c_str());
return;
}
} else if (c == '{') {
if (seg.type() == AS_SEQUENCE) {
// push previous thing and start a new one
add_segment(seg);
seg.clear();
} else if (seg.type() != AS_NONE) // nested, invalid
xorp_throw(InvalidString,
c_format("Illegal character: <%c> %s",
c, path.c_str()));
} else if (seg.type() != AS_NONE) { // nested, invalid
_invalid = true;
XLOG_ERROR("Illegal character: <%c> %s",
c, path.c_str());
return;
}
seg.set_type(AS_SET);
} else if (c == '}') {
if (seg.type() == AS_SET) {
// push previous thing and start a new one
add_segment(seg);
seg.clear();
} else
xorp_throw(InvalidString,
c_format("Illegal character: <%c> %s",
c, path.c_str()));
} else {
_invalid = true;
XLOG_ERROR("Illegal character: <%c> %s",
c, path.c_str());
return;
}
} else if (c == '(') {
if (seg.type() == AS_SEQUENCE) {
// push previous thing and start a new one
add_segment(seg);
seg.clear();
} else if (seg.type() != AS_NONE) // nested, invalid
xorp_throw(InvalidString,
c_format("Illegal character: <%c> %s",
c, path.c_str()));
} else if (seg.type() != AS_NONE) { // nested, invalid
_invalid = true;
XLOG_ERROR("Illegal character: <%c> %s",
c, path.c_str());
return;
}
seg.set_type(AS_CONFED_SEQUENCE);
} else if (c == ')') {
if (seg.type() == AS_CONFED_SEQUENCE) {
// push previous thing and start a new one
add_segment(seg);
seg.clear();
} else
xorp_throw(InvalidString,
c_format("Illegal character: <%c> %s",
c, path.c_str()));
} else {
_invalid = true;
XLOG_ERROR("Illegal character: <%c> %s",
c, path.c_str());
return;
}
} else if (c == '<') {
if (seg.type() == AS_SEQUENCE) {
// push previous thing and start a new one
add_segment(seg);
seg.clear();
} else if (seg.type() != AS_NONE) // nested, invalid
xorp_throw(InvalidString,
c_format("Illegal character: <%c> %s",
c, path.c_str()));
} else if (seg.type() != AS_NONE) { // nested, invalid
_invalid = true;
XLOG_ERROR("Illegal character: <%c> %s",
c, path.c_str());
return;
}
seg.set_type(AS_CONFED_SET);
} else if (c == '>') {
if (seg.type() == AS_CONFED_SET) {
// push previous thing and start a new one
add_segment(seg);
seg.clear();
} else
xorp_throw(InvalidString,
c_format("Illegal character: <%c> %s",
c, path.c_str()));
} else {
_invalid = true;
XLOG_ERROR("Illegal character: <%c> %s",
c, path.c_str());
return;
}
} else if (c == ',') {
} else if (c == ' ' || c == '\t') {
} else
xorp_throw(InvalidString,
c_format("Illegal character: <%c> %s",
c, path.c_str()));
} else {
_invalid = true;
XLOG_ERROR("Illegal character: <%c> %s",
c, path.c_str());
return;
}
}
if (seg.type() == AS_SEQUENCE) // close existing seg.
add_segment(seg);
else if (seg.type() == AS_SET)
xorp_throw(InvalidString,
c_format("Unterminated ASSet: %s", path.c_str()));
else if (seg.type() == AS_SET) {
_invalid = true;
XLOG_ERROR("Unterminated ASSet: %s", path.c_str());
return;
}
debug_msg("end of ASPath()\n");
}

Expand Down Expand Up @@ -551,6 +572,7 @@ ASPath::ASPath(const ASPath &asp1, const ASPath &asp2)
{
_num_segments = 0;
_path_len = 0;
_invalid = asp1._invalid | asp2.invalid;

size_t curseg;
size_t matchelem = 0;
Expand Down
19 changes: 11 additions & 8 deletions xorp/bgp/aspath.hh
Expand Up @@ -18,8 +18,6 @@
// XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
// http://xorp.net

// $XORP: xorp/bgp/aspath.hh,v 1.34 2008/10/02 21:56:14 bms Exp $

#ifndef __BGP_ASPATH_HH__
#define __BGP_ASPATH_HH__

Expand Down Expand Up @@ -129,7 +127,7 @@ public:
/**
* Constructor of an empty ASSegment
*/
ASSegment(ASPathSegType t = AS_NONE) : _type(t) {
ASSegment(ASPathSegType t = AS_NONE) : _type(t), _invalid(0) {
}

/**
Expand All @@ -140,14 +138,15 @@ public:
* _type is d[0], l is d[1], entries follow.
*/
ASSegment(const uint8_t* d) throw(CorruptMessage) {
_invalid = 0;
decode(d);
}

/**
* Copy constructor
*/
ASSegment(const ASSegment& a) :
_type(a._type), _aslist(a._aslist) {}
_type(a._type), _aslist(a._aslist), _invalid(a._invalid) {}

/**
* The destructor has nothing to do, the underlying container will
Expand Down Expand Up @@ -279,8 +278,11 @@ public:
*/
bool two_byte_compatible() const;

bool invalid() const { return _invalid; }

protected:
ASPathSegType _type;
uint8_t _invalid;
ASLIST _aslist;
};

Expand Down Expand Up @@ -330,7 +332,7 @@ public:
* Initialize from a string in the format
* 1,2,(3,4,5),6,7,8,(9,10,11),12,13
*/
ASPath(const char *as_path) throw(InvalidString);
ASPath(const char *as_path);

/**
* construct from received data
Expand Down Expand Up @@ -381,7 +383,6 @@ public:
return (*iter);
}
XLOG_FATAL("Segment %u doesn't exist.", (uint32_t)n);
xorp_throw(InvalidString, "segment invalid n\n");
}

size_t num_segments() const { return _num_segments; }
Expand Down Expand Up @@ -451,14 +452,16 @@ public:
*/
void merge_as4_path(AS4Path& as4_path);

bool invalid() const { return _invalid; }

protected:
/**
* internal representation
*/
list <ASSegment> _segments;
size_t _num_segments;
size_t _path_len;

uint8_t _invalid;
private:
/**
* populate an ASPath from received data. Only used in the constructor.
Expand All @@ -478,7 +481,7 @@ public:
* Initialize from a string in the format
* 3.1,2,(3,10.4,5),6,7,8,(9,10,11),12,13
*/
AS4Path(const char *as_path) throw(InvalidString)
AS4Path(const char *as_path)
: ASPath(as_path)
{};

Expand Down

0 comments on commit 2adeb19

Please sign in to comment.