]>
git.proxmox.com Git - mirror_frr.git/blob - tests/test_lblmgr.c
4 * Copyright (C) 2017 by Bingen Eguzkitza,
7 * This file is part of FreeRangeRouting (FRR)
9 * FRR is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any
14 * FRR is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with FRR; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 #include "lib/stream.h"
26 #include "lib/zclient.h"
28 #define ZSERV_PATH "/tmp/zserv.api" // TODO!!
29 #define KEEP 0 /* change to 1 to avoid garbage collection */
32 struct zclient
*zclient
;
35 const char *sequence
= "GGRGGGRRG";
37 static int zebra_send_get_label_chunk (void);
38 static int zebra_send_release_label_chunk (uint32_t start
, uint32_t end
);
41 process_next_call (uint32_t start
, uint32_t end
)
47 zebra_send_get_label_chunk ();
48 else if (*sequence
== 'R')
49 zebra_send_release_label_chunk (start
, end
);
52 /* Connect to Label Manager */
55 zebra_send_label_manager_connect ()
59 printf("Connect to Label Manager\n");
61 ret
= lm_label_manager_connect (zclient
);
62 printf ("Label Manager connection result: %u \n", ret
);
64 fprintf (stderr
, "Error %d connecting to Label Manager %s\n", ret
,
69 process_next_call (0, 0);
75 zebra_send_get_label_chunk ()
81 printf("Ask for label chunk \n");
83 ret
= lm_get_label_chunk (zclient
, KEEP
, CHUNK_SIZE
, &start
, &end
);
85 fprintf (stderr
, "Error %d requesting label chunk %s\n", ret
, strerror(errno
));
91 printf ("Label Chunk assign: %u - %u \n",
94 process_next_call (start
, end
);
97 /* Release Label Chunk */
100 zebra_send_release_label_chunk (uint32_t start
, uint32_t end
)
105 printf("Release label chunk: %u - %u\n", start
, end
);
107 ret
= lm_release_label_chunk (zclient
, start
, end
);
109 fprintf (stderr
, "Error releasing label chunk\n");
115 process_next_call (start
-CHUNK_SIZE
, end
-CHUNK_SIZE
);
119 void init_zclient (struct thread_master
*master
, char *lm_zserv_path
)
122 zclient_serv_path_set(lm_zserv_path
);
124 zclient
= zclient_new(master
);
125 /* zclient_init(zclient, ZEBRA_LABEL_MANAGER, 0); */
127 zclient
->redist_default
= ZEBRA_ROUTE_LDP
;
128 zclient
->instance
= instance
;
129 if (zclient_socket_connect (zclient
) < 0) {
130 printf ("Error connecting synchronous zclient!\n");
136 int main (int argc
, char *argv
[])
138 struct thread_master
*master
;
139 struct thread thread
;
142 printf ("Sequence to be tested: %s\n", sequence
);
144 master
= thread_master_create();
145 init_zclient (master
, ZSERV_PATH
);
147 zebra_send_label_manager_connect ();