]> git.proxmox.com Git - mirror_frr.git/blobdiff - tests/test_lblmgr.c
*: remove --enable-tcp-zebra, rework ZAPI path
[mirror_frr.git] / tests / test_lblmgr.c
index 4a4aaa001484026a3e738cfca44c13a837b7ef19..5e604db61a2a3c89a980fd975cdcb6ff71017473 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with FRR; see the file COPYING.  If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include "lib/stream.h"
@@ -34,117 +33,111 @@ u_short instance = 1;
 
 const char *sequence = "GGRGGGRRG";
 
-static int zebra_send_get_label_chunk (void);
-static int zebra_send_release_label_chunk (uint32_t start, uint32_t end);
+static int zebra_send_get_label_chunk(void);
+static int zebra_send_release_label_chunk(uint32_t start, uint32_t end);
 
-static void
-process_next_call (uint32_t start, uint32_t end)
+static void process_next_call(uint32_t start, uint32_t end)
 {
-               sleep (3);
-               if (!*sequence)
-                               exit (0);
-               if (*sequence == 'G')
-                               zebra_send_get_label_chunk ();
-               else if (*sequence == 'R')
-                               zebra_send_release_label_chunk (start, end);
+       sleep(3);
+       if (!*sequence)
+               exit(0);
+       if (*sequence == 'G')
+               zebra_send_get_label_chunk();
+       else if (*sequence == 'R')
+               zebra_send_release_label_chunk(start, end);
 }
 
 /* Connect to Label Manager */
 
-static int
-zebra_send_label_manager_connect ()
+static int zebra_send_label_manager_connect()
 {
-               int ret;
+       int ret;
 
-               printf("Connect to Label Manager\n");
+       printf("Connect to Label Manager\n");
 
-               ret = lm_label_manager_connect (zclient);
-               printf ("Label Manager connection result: %u \n", ret);
-               if (ret != 0 ) {
-                               fprintf (stderr, "Error %d connecting to Label Manager %s\n", ret,
-                                                strerror(errno));
-                               exit (1);
-               }
+       ret = lm_label_manager_connect(zclient);
+       printf("Label Manager connection result: %u \n", ret);
+       if (ret != 0) {
+               fprintf(stderr, "Error %d connecting to Label Manager %s\n",
+                       ret, strerror(errno));
+               exit(1);
+       }
 
-               process_next_call (0, 0);
+       process_next_call(0, 0);
 }
 
 /* Get Label Chunk */
 
-static int
-zebra_send_get_label_chunk ()
+static int zebra_send_get_label_chunk()
 {
-               uint32_t start;
-               uint32_t end;
-               int ret;
+       uint32_t start;
+       uint32_t end;
+       int ret;
 
-               printf("Ask for label chunk \n");
+       printf("Ask for label chunk \n");
 
-               ret = lm_get_label_chunk (zclient, KEEP, CHUNK_SIZE, &start, &end);
-               if (ret != 0 ) {
-                               fprintf (stderr, "Error %d requesting label chunk %s\n", ret, strerror(errno));
-                               exit (1);
-               }
+       ret = lm_get_label_chunk(zclient, KEEP, CHUNK_SIZE, &start, &end);
+       if (ret != 0) {
+               fprintf(stderr, "Error %d requesting label chunk %s\n", ret,
+                       strerror(errno));
+               exit(1);
+       }
 
-               sequence++;
+       sequence++;
 
-               printf ("Label Chunk assign: %u - %u \n",
-                               start, end);
+       printf("Label Chunk assign: %u - %u \n", start, end);
 
-               process_next_call (start, end);
+       process_next_call(start, end);
 }
 
 /* Release Label Chunk */
 
-static int
-zebra_send_release_label_chunk (uint32_t start, uint32_t end)
+static int zebra_send_release_label_chunk(uint32_t start, uint32_t end)
 {
-               struct stream *s;
-               int ret;
+       struct stream *s;
+       int ret;
 
-               printf("Release label chunk: %u - %u\n", start, end);
+       printf("Release label chunk: %u - %u\n", start, end);
 
-               ret = lm_release_label_chunk (zclient, start, end);
-               if (ret != 0 ) {
-                               fprintf (stderr, "Error releasing label chunk\n");
-                               exit (1);
-               }
+       ret = lm_release_label_chunk(zclient, start, end);
+       if (ret != 0) {
+               fprintf(stderr, "Error releasing label chunk\n");
+               exit(1);
+       }
 
-               sequence++;
+       sequence++;
 
-               process_next_call (start-CHUNK_SIZE, end-CHUNK_SIZE);
+       process_next_call(start - CHUNK_SIZE, end - CHUNK_SIZE);
 }
 
 
-void init_zclient (struct thread_master *master, char *lm_zserv_path)
+void init_zclient(struct thread_master *master, char *lm_zserv_path)
 {
-               if (lm_zserv_path)
-                               zclient_serv_path_set(lm_zserv_path);
-
-               zclient = zclient_new(master);
-               /* zclient_init(zclient, ZEBRA_LABEL_MANAGER, 0); */
-               zclient->sock = -1;
-               zclient->redist_default = ZEBRA_ROUTE_LDP;
-               zclient->instance = instance;
-               if (zclient_socket_connect (zclient) < 0) {
-                               printf ("Error connecting synchronous zclient!\n");
-                               exit (1);
-               }
-
+       frr_zclient_addr(&zclient_addr, &zclient_addr_len, lm_zserv_path);
+
+       zclient = zclient_new(master);
+       /* zclient_init(zclient, ZEBRA_LABEL_MANAGER, 0); */
+       zclient->sock = -1;
+       zclient->redist_default = ZEBRA_ROUTE_LDP;
+       zclient->instance = instance;
+       if (zclient_socket_connect(zclient) < 0) {
+               printf("Error connecting synchronous zclient!\n");
+               exit(1);
+       }
 }
 
-int main (int argc, char *argv[])
+int main(int argc, char *argv[])
 {
-               struct thread_master *master;
-               struct thread            thread;
-               int ret;
+       struct thread_master *master;
+       struct thread thread;
+       int ret;
 
-               printf ("Sequence to be tested: %s\n", sequence);
+       printf("Sequence to be tested: %s\n", sequence);
 
-               master = thread_master_create();
-               init_zclient (master, ZSERV_PATH);
+       master = thread_master_create(NULL);
+       init_zclient(master, ZSERV_PATH);
 
-               zebra_send_label_manager_connect ();
+       zebra_send_label_manager_connect();
 
-               return 0;
+       return 0;
 }