]>
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
;
32 unsigned short instance
= 1;
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
);
39 static void process_next_call(uint32_t start
, uint32_t end
)
45 zebra_send_get_label_chunk();
46 else if (*sequence
== 'R')
47 zebra_send_release_label_chunk(start
, end
);
50 /* Connect to Label Manager */
52 static int zebra_send_label_manager_connect()
56 printf("Connect to Label Manager\n");
58 ret
= lm_label_manager_connect(zclient
);
59 printf("Label Manager connection result: %u \n", ret
);
61 fprintf(stderr
, "Error %d connecting to Label Manager %s\n",
62 ret
, strerror(errno
));
66 process_next_call(0, 0);
71 static int zebra_send_get_label_chunk()
77 printf("Ask for label chunk \n");
79 ret
= lm_get_label_chunk(zclient
, KEEP
, CHUNK_SIZE
, &start
, &end
);
81 fprintf(stderr
, "Error %d requesting label chunk %s\n", ret
,
88 printf("Label Chunk assign: %u - %u \n", start
, end
);
90 process_next_call(start
, end
);
93 /* Release Label Chunk */
95 static int zebra_send_release_label_chunk(uint32_t start
, uint32_t end
)
100 printf("Release label chunk: %u - %u\n", start
, end
);
102 ret
= lm_release_label_chunk(zclient
, start
, end
);
104 fprintf(stderr
, "Error releasing label chunk\n");
110 process_next_call(start
- CHUNK_SIZE
, end
- CHUNK_SIZE
);
114 void init_zclient(struct thread_master
*master
, char *lm_zserv_path
)
116 frr_zclient_addr(&zclient_addr
, &zclient_addr_len
, lm_zserv_path
);
118 zclient
= zclient_new_notify(master
, &zclient_options_default
);
119 /* zclient_init(zclient, ZEBRA_LABEL_MANAGER, 0); */
121 zclient
->redist_default
= ZEBRA_ROUTE_LDP
;
122 zclient
->instance
= instance
;
123 if (zclient_socket_connect(zclient
) < 0) {
124 printf("Error connecting synchronous zclient!\n");
129 int main(int argc
, char *argv
[])
131 struct thread_master
*master
;
132 struct thread thread
;
135 printf("Sequence to be tested: %s\n", sequence
);
137 master
= thread_master_create(NULL
);
138 init_zclient(master
, ZSERV_PATH
);
140 zebra_send_label_manager_connect();