Exemple #1
0
inline static u_int32_t gatewayEncodingLength(SFLExtended_gateway *gw) {
    u_int32_t elemSiz = addressEncodingLength(&gw->nexthop);
    u_int32_t seg = 0;
    elemSiz += 16; // as, src_as, src_peer_as, dst_as_path_segments
    for(; seg < gw->dst_as_path_segments; seg++) {
	elemSiz += 8; // type, length
	elemSiz += 4 * gw->dst_as_path[seg].length; // set/seq bytes
    }
    elemSiz += 4; // communities_length
    elemSiz += 4 * gw->communities_length; // communities
    elemSiz += 4; // localpref
    return elemSiz;
}
static uint32_t natEncodingLength(SFLExtended_nat *nat) {
  return addressEncodingLength(&nat->src)
    + addressEncodingLength(&nat->dst);
}
static uint32_t mplsEncodingLength(SFLExtended_mpls *mpls) {
  return addressEncodingLength(&mpls->nextHop)
    + labelStackEncodingLength(&mpls->in_stack)
    + labelStackEncodingLength(&mpls->out_stack);
}
static uint32_t routerEncodingLength(SFLExtended_router *router) {
  return addressEncodingLength(&router->nexthop) + 8;
}