int vr_mpls_get(vr_mpls_req *req) { int ret = 0; struct vr_nexthop *nh = NULL; struct vrouter *router; router = vrouter_get(req->mr_rid); if (!router || req->mr_label > (int)router->vr_max_labels) { ret = -ENODEV; } else { nh = vrouter_get_label(req->mr_rid, req->mr_label); if (!nh) ret = -ENOENT; } if (!ret) vr_mpls_make_req(req, nh, req->mr_label); else req = NULL; vr_message_response(VR_MPLS_OBJECT_ID, req, ret); return 0; }
int vr_mpls_get(vr_mpls_req *req) { int ret = 0; struct vr_nexthop *nh = NULL; struct vrouter *router; router = vrouter_get(req->mr_rid); if (!router) { ret = -ENODEV; goto generate_response; } if (((unsigned int)req->mr_label >= router->vr_max_labels)) { ret = -EINVAL; goto generate_response; } nh = vrouter_get_label(req->mr_rid, req->mr_label); if (!nh) { ret = -ENOENT; goto generate_response; } vr_mpls_make_req(req, nh, req->mr_label); generate_response: if (ret) req = NULL; vr_message_response(VR_MPLS_OBJECT_ID, req, ret); return 0; }
int vr_mpls_dump(vr_mpls_req *r) { int ret = 0; unsigned int i; struct vr_nexthop *nh; struct vrouter *router = vrouter_get(r->mr_rid); struct vr_message_dumper *dumper = NULL; vr_mpls_req req; if (!router && (ret = -ENODEV)) goto generate_response; if ((unsigned int)(r->mr_marker) + 1 >= router->vr_max_labels) goto generate_response; dumper = vr_message_dump_init(r); if (!dumper && (ret = -ENOMEM)) goto generate_response; for (i = (unsigned int)(r->mr_marker + 1); i < router->vr_max_labels; i++) { nh = router->vr_ilm[i]; if (nh) { vr_mpls_make_req(&req, nh, i); ret = vr_message_dump_object(dumper, VR_MPLS_OBJECT_ID, &req); if (ret <= 0) break; } } generate_response: vr_message_dump_exit(dumper, ret); return 0; }