]>
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
);
40 static void 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 */
53 static int zebra_send_label_manager_connect()
57 printf("Connect to Label Manager\n");
59 ret
= lm_label_manager_connect(zclient
);
60 printf("Label Manager connection result: %u \n", ret
);
62 fprintf(stderr
, "Error %d connecting to Label Manager %s\n",
63 ret
, strerror(errno
));
67 process_next_call(0, 0);
72 static int zebra_send_get_label_chunk()
78 printf("Ask for label chunk \n");
80 ret
= lm_get_label_chunk(zclient
, KEEP
, CHUNK_SIZE
, &start
, &end
);
82 fprintf(stderr
, "Error %d requesting label chunk %s\n", ret
,
89 printf("Label Chunk assign: %u - %u \n", start
, end
);
91 process_next_call(start
, end
);
94 /* Release Label Chunk */
96 static int zebra_send_release_label_chunk(uint32_t start
, uint32_t end
)
101 printf("Release label chunk: %u - %u\n", start
, end
);
103 ret
= lm_release_label_chunk(zclient
, start
, end
);
105 fprintf(stderr
, "Error releasing label chunk\n");
111 process_next_call(start
- CHUNK_SIZE
, end
- CHUNK_SIZE
);
115 void init_zclient(struct thread_master
*master
, char *lm_zserv_path
)
118 zclient_serv_path_set(lm_zserv_path
);
120 zclient
= zclient_new(master
);
121 /* zclient_init(zclient, ZEBRA_LABEL_MANAGER, 0); */
123 zclient
->redist_default
= ZEBRA_ROUTE_LDP
;
124 zclient
->instance
= instance
;
125 if (zclient_socket_connect(zclient
) < 0) {
126 printf("Error connecting synchronous zclient!\n");
131 int main(int argc
, char *argv
[])
133 struct thread_master
*master
;
134 struct thread thread
;
137 printf("Sequence to be tested: %s\n", sequence
);
139 master
= thread_master_create();
140 init_zclient(master
, ZSERV_PATH
);
142 zebra_send_label_manager_connect();