ldp_attr *ldp_attr_create(ldp_global *g, mpls_fec * fec) { ldp_attr *a = (ldp_attr *) mpls_malloc(sizeof(ldp_attr)); if (a != NULL) { memset(a, 0, sizeof(ldp_attr)); MPLS_LIST_ELEM_INIT(a, _session); MPLS_LIST_ELEM_INIT(a, _global); MPLS_LIST_ELEM_INIT(a, _fs); MPLS_LIST_INIT(&a->us_attr_root, ldp_attr); MPLS_REFCNT_INIT(a, 0); a->index = _ldp_attr_get_next_index(); a->in_tree = MPLS_BOOL_FALSE; a->ingress = MPLS_BOOL_FALSE; a->filtered = MPLS_BOOL_FALSE; if (fec != NULL) { mpls_fec2fec_tlv(fec, &a->fecTlv, 0); a->fecTlv.numberFecElements = 1; a->fecTlvExists = 1; } _ldp_global_add_attr(g, a); } return a; }
ldp_resource *ldp_resource_create() { ldp_resource *r = (ldp_resource *) mpls_malloc(sizeof(ldp_resource)); if (r) { memset(r, 0, sizeof(ldp_resource)); MPLS_REFCNT_INIT(r, 0); MPLS_LIST_ELEM_INIT(r, _global); r->index = _ldp_resource_get_next_index(); } return r; }
ldp_inlabel *ldp_inlabel_create() { ldp_inlabel *i = (ldp_inlabel *) mpls_malloc(sizeof(ldp_inlabel)); if (i) { memset(i, 0, sizeof(ldp_inlabel)); MPLS_REFCNT_INIT(i, 0); mpls_link_list_init(&i->session_root); mpls_link_list_init(&i->attr_root); MPLS_LIST_ELEM_INIT(i, _global); MPLS_LIST_ELEM_INIT(i, _outlabel); i->index = _ldp_inlabel_get_next_index(); i->info.label.type = MPLS_LABEL_TYPE_NONE; } return i; }
ldp_adj *ldp_adj_create(mpls_inet_addr * source, mpls_inet_addr * lsraddr, int labelspace, int remote_hellotime, mpls_inet_addr * remote_transport_address, uint32_t remote_csn) { ldp_adj *a = (ldp_adj *) mpls_malloc(sizeof(ldp_adj)); struct in_addr addr; if (lsraddr == NULL || source == NULL) return NULL; if (a) { memset(a, 0, sizeof(ldp_adj)); MPLS_REFCNT_INIT(a, 0); MPLS_LIST_ELEM_INIT(a, _global); MPLS_LIST_ELEM_INIT(a, _session); MPLS_LIST_ELEM_INIT(a, _entity); a->index = _ldp_adj_get_next_index(); /* these are operational values */ /* JLEU: where do I grab these values from */ /* these values are learned form the remote peer */ memcpy(&a->remote_source_address, source, sizeof(mpls_inet_addr)); memcpy(&a->remote_lsr_address, lsraddr, sizeof(mpls_inet_addr)); addr.s_addr = htonl(lsraddr->u.ipv4); LDP_TRACE_LOG(g->user_data, MPLS_TRACE_STATE_ALL, LDP_TRACE_FLAG_PERIODIC, "Adj(%d) created for 0x%08x/",a->index, addr); addr.s_addr = htonl(source->u.ipv4); LDP_TRACE_LOG(g->user_data, MPLS_TRACE_STATE_ALL, LDP_TRACE_FLAG_PERIODIC, "0x%08x\n", addr); if (remote_transport_address) { memcpy(&a->remote_transport_address, remote_transport_address, sizeof(mpls_inet_addr)); } else { memset(&a->remote_transport_address, 0, sizeof(mpls_inet_addr)); } a->remote_hellotime = remote_hellotime; a->remote_csn = remote_csn; a->state = MPLS_OPER_DOWN; a->role = LDP_NONE; } return a; }
ldp_nexthop *ldp_nexthop_create(ldp_global *g, mpls_nexthop *n) { ldp_nexthop *nh = (ldp_nexthop *) mpls_malloc(sizeof(ldp_nexthop)); if (nh != NULL) { memset(nh, 0, sizeof(ldp_nexthop)); MPLS_REFCNT_INIT(nh, 0); MPLS_LIST_INIT(&nh->outlabel_root, ldp_outlabel); MPLS_LIST_ELEM_INIT(nh, _fec); MPLS_LIST_ELEM_INIT(nh, _addr); MPLS_LIST_ELEM_INIT(nh, _if); MPLS_LIST_ELEM_INIT(nh, _outlabel); nh->index = _ldp_nexthop_get_next_index(); mpls_nexthop2ldp_nexthop(n, nh); _ldp_global_add_nexthop(g, nh); } return nh; }