* NOT the internal representation!
*/
struct assegment_header {
- u_char type;
- u_char length;
+ uint8_t type;
+ uint8_t length;
};
/* Hash for aspath. This is the top level structure of AS path. */
* the caller should immediately assign data to the segment, as the segment
* otherwise is not generally valid
*/
-static struct assegment *assegment_new(u_char type, u_short length)
+static struct assegment *assegment_new(uint8_t type, unsigned short length)
{
struct assegment *new;
newas = XREALLOC(MTYPE_AS_SEG_DATA, seg->as,
ASSEGMENT_DATA_SIZE(seg->length + num, 1));
- if (newas) {
- seg->as = newas;
- memcpy(seg->as + seg->length, asnos,
- ASSEGMENT_DATA_SIZE(num, 1));
- seg->length += num;
- return seg;
- }
-
- assegment_free_all(seg);
- return NULL;
+ seg->as = newas;
+ memcpy(seg->as + seg->length, asnos,
+ ASSEGMENT_DATA_SIZE(num, 1));
+ seg->length += num;
+ return seg;
}
static int int_cmp(const void *p1, const void *p2)
/* Return the start or end delimiters for a particular Segment type */
#define AS_SEG_START 0
#define AS_SEG_END 1
-static char aspath_delimiter_char(u_char type, u_char which)
+static char aspath_delimiter_char(uint8_t type, uint8_t which)
{
int i;
struct {
if (!as->segments) {
if (make_json) {
json_object_string_add(as->json, "string", "Local");
- json_object_object_add(as->json, "segments", jaspath_segments);
+ json_object_object_add(as->json, "segments",
+ jaspath_segments);
json_object_int_add(as->json, "length", 0);
}
as->str = XMALLOC(MTYPE_AS_STR, 1);
/* write out the ASNs, with their seperators, bar the last one*/
for (i = 0; i < seg->length; i++) {
if (make_json)
- json_object_array_add(jseg_list,
- json_object_new_int(seg->as[i]));
+ json_object_array_add(
+ jseg_list,
+ json_object_new_int(seg->as[i]));
len += snprintf(str_buf + len, str_size - len, "%u",
seg->as[i]);
if (make_json) {
jseg = json_object_new_object();
- json_object_string_add(jseg, "type",
- aspath_segment_type_str[seg->type]);
+ json_object_string_add(
+ jseg, "type",
+ aspath_segment_type_str[seg->type]);
json_object_object_add(jseg, "list", jseg_list);
json_object_array_add(jaspath_segments, jseg);
}
}
}
-static size_t assegment_header_put(struct stream *s, u_char type, int length)
+static size_t assegment_header_put(struct stream *s, uint8_t type, int length)
{
size_t lenp;
assert(length <= AS_SEGMENT_MAX);
assegment_data_put(s, seg->as, AS_SEGMENT_MAX,
use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE(AS_SEGMENT_MAX, use32bit);
+ bytes += ASSEGMENT_SIZE(AS_SEGMENT_MAX,
+ use32bit);
}
/* write the final segment, probably is also the first
* We have no way to manage the storage, so we use a static stream
* wrapper around aspath_put.
*/
-u_char *aspath_snmp_pathseg(struct aspath *as, size_t *varlen)
+uint8_t *aspath_snmp_pathseg(struct aspath *as, size_t *varlen)
{
#define SNMP_PATHSEG_MAX 1024
/* Add specified AS to the leftmost of aspath. */
static struct aspath *aspath_add_asns(struct aspath *aspath, as_t asno,
- u_char type, unsigned num)
+ uint8_t type, unsigned num)
{
struct assegment *assegment = aspath->segments;
unsigned i;
struct aspath *newpath = NULL, *mergedpath;
int hops, cpasns = 0;
- if (!aspath)
+ if (!aspath || !as4path)
return NULL;
seg = aspath->segments;
/* Return next token and point for string parse. */
static const char *aspath_gettoken(const char *buf, enum as_token *token,
- u_long *asno)
+ unsigned long *asno)
{
const char *p = buf;
struct aspath *aspath_str2aspath(const char *str)
{
enum as_token token = as_token_unknown;
- u_short as_type;
- u_long asno = 0;
+ unsigned short as_type;
+ unsigned long asno = 0;
struct aspath *aspath;
int needtype;
/* AS path hash initialize. */
void aspath_init(void)
{
- ashash = hash_create_size(32768,
- aspath_key_make,
- aspath_cmp,
+ ashash = hash_create_size(32768, aspath_key_make, aspath_cmp,
"BGP AS Path");
}