]>
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
28 #include "lib/stream.h"
29 #include "lib/zclient.h"
31 #define ZSERV_PATH "/tmp/zserv.api" // TODO!!
32 #define KEEP 0 /* change to 1 to avoid garbage collection */
35 struct zclient
*zclient
;
36 unsigned short instance
= 1;
38 const char *sequence
= "GGRGGGRRG";
40 static int zebra_send_get_label_chunk(void);
41 static int zebra_send_release_label_chunk(uint32_t start
, uint32_t end
);
43 static void process_next_call(uint32_t start
, uint32_t end
)
49 zebra_send_get_label_chunk();
50 else if (*sequence
== 'R')
51 zebra_send_release_label_chunk(start
, end
);
54 /* Connect to Label Manager */
56 static int zebra_send_label_manager_connect()
60 printf("Connect to Label Manager\n");
62 ret
= lm_label_manager_connect(zclient
, 0);
63 printf("Label Manager connection result: %u \n", ret
);
65 fprintf(stderr
, "Error %d connecting to Label Manager %s\n",
66 ret
, strerror(errno
));
70 process_next_call(0, 0);
75 static int 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
,
92 printf("Label Chunk assign: %u - %u \n", start
, end
);
94 process_next_call(start
, end
);
97 /* Release Label Chunk */
99 static int 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
)
120 frr_zclient_addr(&zclient_addr
, &zclient_addr_len
, lm_zserv_path
);
122 zclient
= zclient_new(master
, &zclient_options_default
);
123 /* zclient_init(zclient, ZEBRA_LABEL_MANAGER, 0); */
125 zclient
->redist_default
= ZEBRA_ROUTE_LDP
;
126 zclient
->instance
= instance
;
127 if (zclient_socket_connect(zclient
) < 0) {
128 printf("Error connecting synchronous zclient!\n");
133 int main(int argc
, char *argv
[])
135 struct thread_master
*master
;
136 struct thread thread
;
139 printf("Sequence to be tested: %s\n", sequence
);
141 master
= thread_master_create(NULL
);
142 init_zclient(master
, ZSERV_PATH
);
144 zebra_send_label_manager_connect();