[mpls-linux-devel] Quagga interface vty(sh)
Status: Beta
Brought to you by:
jleu
From: Julien B. <jul...@gm...> - 2006-12-19 11:31:06
|
Hello sir, The more I dive into the code (of quagga, not ldp) the more I found it really really tricky. The most difficult part was to understand how the interface worked. And I figured out that DEFUN was used : /* DEFUN for vty command interafce. Little bit hacky ;-). */ #define DEFUN(funcname, cmdname, cmdstr, helpstr) \ DEFUN_CMD_FUNC_DECL(funcname) \ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \ DEFUN_CMD_FUNC_TEXT(funcname) Which means : #define DEFUN_CMD_FUNC_DECL(funcname) \ static int funcname (struct cmd_element *, struct vty *, int, const char *[]); #define DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attrs, dnum) \ struct cmd_element cmdname = \ { \ .string = cmdstr, \ .func = funcname, \ .doc = helpstr, \ .attr = attrs, \ .daemon = dnum, \ }; #define DEFUN_CMD_FUNC_TEXT(funcname) \ static int funcname \ (struct cmd_element *self __attribute__ ((unused)), \ struct vty *vty __attribute__ ((unused)), \ int argc __attribute__ ((unused)), \ const char *argv[] __attribute__ ((unused)) ) To see how the macro is used according to the interface for quagga's usage of ldp-portable, maybe an example would be nice : This is the first example you can find in quagga-mpls/ldpd/ldp_vty.c DEFUN (mpls_ldp, mpls_ldp_cmd, "mpls ldp", "Global MPLS configuration\n" "Dynamic Label distribution via LDP\n") { vty->node = LDP_NODE; vty->index = ldp_get(); if (!vty->index) { if (!(vty->index = ldp_new())) { vty_out (vty, "Unable to create LDP instance.%s", VTY_NEWLINE); return CMD_WARNING; } } return CMD_SUCCESS; } And my question is : what is "mpls_ldp" or any other functions declared by the DEFUN macro? Is this a command we can use on the interface? Thank you for your help. Julien -- -------------------------------------------- Julien BISCONTI <julien.bisconti(at)student.fundp.ac.be> M.Sc. student in Computer Science, University of Namur FUNDP, Belgium Traineeship: UPC (Barcelona, Spain) |