]>
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 along
20 * with this program; see the file COPYING; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "lib/stream.h"
25 #include "lib/zclient.h"
27 #define ZSERV_PATH "/tmp/zserv.api" // TODO!!
28 #define KEEP 0 /* change to 1 to avoid garbage collection */
31 struct zclient
*zclient
;
34 const char *sequence
= "GGRGGGRRG";
36 static int zebra_send_get_label_chunk (void);
37 static int zebra_send_release_label_chunk (uint32_t start
, uint32_t end
);
40 process_next_call (uint32_t start
, uint32_t end
)
46 zebra_send_get_label_chunk ();
47 else if (*sequence
== 'R')
48 zebra_send_release_label_chunk (start
, end
);
51 /* Connect to Label Manager */
54 zebra_send_label_manager_connect ()
58 printf("Connect to Label Manager\n");
60 ret
= lm_label_manager_connect (zclient
);
61 printf ("Label Manager connection result: %u \n", ret
);
63 fprintf (stderr
, "Error %d connecting to Label Manager %s\n", ret
,
68 process_next_call (0, 0);
74 zebra_send_get_label_chunk ()
80 printf("Ask for label chunk \n");
82 ret
= lm_get_label_chunk (zclient
, KEEP
, CHUNK_SIZE
, &start
, &end
);
84 fprintf (stderr
, "Error %d requesting label chunk %s\n", ret
, strerror(errno
));
90 printf ("Label Chunk assign: %u - %u \n",
93 process_next_call (start
, end
);
96 /* Release Label Chunk */
99 zebra_send_release_label_chunk (uint32_t start
, uint32_t end
)
104 printf("Release label chunk: %u - %u\n", start
, end
);
106 ret
= lm_release_label_chunk (zclient
, start
, end
);
108 fprintf (stderr
, "Error releasing label chunk\n");
114 process_next_call (start
-CHUNK_SIZE
, end
-CHUNK_SIZE
);
118 void init_zclient (struct thread_master
*master
, char *lm_zserv_path
)
121 zclient_serv_path_set(lm_zserv_path
);
123 zclient
= zclient_new(master
);
124 /* zclient_init(zclient, ZEBRA_LABEL_MANAGER, 0); */
126 zclient
->redist_default
= ZEBRA_ROUTE_LDP
;
127 zclient
->instance
= instance
;
128 if (zclient_socket_connect (zclient
) < 0) {
129 printf ("Error connecting synchronous zclient!\n");
135 int main (int argc
, char *argv
[])
137 struct thread_master
*master
;
138 struct thread thread
;
141 printf ("Sequence to be tested: %s\n", sequence
);
143 master
= thread_master_create();
144 init_zclient (master
, ZSERV_PATH
);
146 zebra_send_label_manager_connect ();