Ejemplo n.º 1
0
ldp_fec *ldp_fec_create(ldp_global *g, mpls_fec *f)
{
  ldp_fec *fec = (ldp_fec *) mpls_malloc(sizeof(ldp_fec));

  if (fec != NULL) {
    memset(fec, 0, sizeof(ldp_fec));
    /*
     * note: this is init to 1 for a reason!
     * We're placing it in the global list, so this is our refcnt
     * when this refcnt gets to zero, it will be removed from the
     * global list and deleted
     */
    /*
     * TESTING: jleu 6/7/2004, since I want the FEC to be cleaned up
     * when it no longer has a nexthop, addr, or label, the only things that
     * should increment the ref are those (nh, addr, label etc), not global
     * nor inserting into the tree.  I also added this comment in
     * _ldp_global_add_fec()
    MPLS_REFCNT_INIT(fec, 1);
     */
    MPLS_LIST_ELEM_INIT(fec, _global);
    MPLS_LIST_ELEM_INIT(fec, _inlabel);
    MPLS_LIST_ELEM_INIT(fec, _outlabel);
    MPLS_LIST_ELEM_INIT(fec, _fec);
    MPLS_LIST_INIT(&fec->nh_root, ldp_nexthop);
    MPLS_LIST_INIT(&fec->fs_root_us, ldp_fs);
    MPLS_LIST_INIT(&fec->fs_root_ds, ldp_fs);
    fec->index = _ldp_fec_get_next_index();
    mpls_fec2ldp_fec(f,fec);

    _ldp_global_add_fec(g, fec);
    ldp_fec_insert(g, fec);
  }
  return fec;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
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;
}