zebra(quagga) 설치 후 활용에 대한 질문입니다.

vktod25의 이미지

quagga-0.99.20.tar.gz 를 리눅스에 설치 하였습니다.

zebra를 실행 시키고

vtysh을 실행 시키면 cli가 잘 동작 하는걸 확인 할 수 있습니다.

명령어를 추가하기 위해 기존에 zebra/interface.c 에

871 DEFUN (show_test, show_test_cmd,
872 "show test",
873 SHOW_STR
874 "test\n")
875 {
876 vty_out(vty, "test....\n");
877
878 return CMD_SUCCESS;
879 }

1595 zebra_if_init (void) 안에

1607 install_element (ENABLE_NODE, &show_test_cmd);

위와 같은 코드를 추가하고

make를 하면 vtysh/vtysh_cmd.c에

15261 DEFSH (VTYSH_ZEBRA, show_test_cmd_vtysh,
15262 "show test",
15263 "Show running system information\n"
15264 "test\n")

18021 install_element (ENABLE_NODE, &show_test_cmd_vtysh);

가 자동으로 등록되고 vtysh을

동작하면 명령어 동작도 되고 help메뉴에서도 추가한 test 가 보이는 것을 확인 할 수 있었습니다,

문제는 zebra폴더안에 새로운 파일을 추가하여

다음과 같은 코드를 추가하고

1 #include
2 #include
3 #include "phone_list.h"
4 #include "command.h"
5
6
7 DEFUN (show_phone_list,
8 show_phone_list_cli,
9 "show phone list",
10 SHOW_STR
11 "show phone list dec")
12 {
13 vty_out(vty,"print phone list!!");
14 return CMD_SUCCESS;
15 }
16
17 void
18 phone_list_init(void)
19 {
20 install_element (ENABLE_NODE, &show_phone_list_cli);
21 }

zebra 폴더안에 Makefile.am에 해당 파일과 헤더를 등록,
vtysh 폴더안에 Makefile.am에 vtysh_cmd_FILES 부분에 해당 파일.c 를 등록하여

자동으로 vtysh_cmd.c에 install_element와 DEFSH가 생성되기를 희망했습니다.

상위폴더에서 make를 하면 install_element는 자동으로 생성되지만 DEFSH가 생성되지 않아

컴파일 에러가 뜹니다.

어느 부분이 누락된걸까요.??

vktod25의 이미지

등록된 코드.c파일에서 DEFUN과 install_element를 추출 하는 extract.pl의 주요 내용입니다.

print < #include
#include "command.h"
#include "vtysh.h"

EOF

$ignore{'"interface IFNAME"'} = "ignore";
$ignore{'"ip vrf NAME"'} = "ignore";
$ignore{'"router rip"'} = "ignore";
$ignore{'"router ripng"'} = "ignore";
$ignore{'"router ospf"'} = "ignore";
$ignore{'"router ospf <0-65535>"'} = "ignore";
$ignore{'"router ospf6"'} = "ignore";
$ignore{'"router bgp " "<1-4294967295>"'} = "ignore";
$ignore{'"router bgp " "<1-4294967295>" " view WORD"'} = "ignore";
$ignore{'"router isis WORD"'} = "ignore";
$ignore{'"router zebra"'} = "ignore";
$ignore{'"address-family ipv4"'} = "ignore";
$ignore{'"address-family ipv4 (unicast|multicast)"'} = "ignore";
$ignore{'"address-family ipv6"'} = "ignore";
$ignore{'"address-family ipv6 unicast"'} = "ignore";
$ignore{'"address-family vpnv4"'} = "ignore";
$ignore{'"address-family vpnv4 unicast"'} = "ignore";
$ignore{'"address-family ipv4 vrf NAME"'} = "ignore";
$ignore{'"exit-address-family"'} = "ignore";
$ignore{'"key chain WORD"'} = "ignore";
$ignore{'"key <0-2147483647>"'} = "ignore";
$ignore{'"route-map WORD (deny|permit) <1-65535>"'} = "ignore";
$ignore{'"show route-map"'} = "ignore";
$ignore{'"line vty"'} = "ignore";
$ignore{'"who"'} = "ignore";
$ignore{'"terminal monitor"'} = "ignore";
$ignore{'"terminal no monitor"'} = "ignore";
$ignore{'"show history"'} = "ignore";

foreach (@ARGV) {
$file = $_;

open (FH, "cpp -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -DHAVE_IPV6 -I.. -I./ -I./.. -I../lib -I../isisd/topology $file |");
local $/; undef $/;
$line = ;
close (FH);

@defun = ($line =~ /(?:DEFUN|ALIAS)\s*\((.+?)\);?\s?\s?\n/sg);
@install = ($line =~ /install_element \(\s*[0-9A-Z_]+,\s*&[^;]*;\s*\n/sg);

# DEFUN process
foreach (@defun) {
my (@defun_array);
@defun_array = split (/,/);
$defun_array[0] = '';

# Actual input command string.
$str = "$defun_array[2]";
$str =~ s/^\s+//g;
$str =~ s/\s+$//g;

# Get VTY command structure. This is needed for searching
# install_element() command.
$cmd = "$defun_array[1]";
$cmd =~ s/^\s+//g;
$cmd =~ s/\s+$//g;

# $protocol is VTYSH_PROTO format for redirection of user input
if ($file =~ /lib/) {
if ($file =~ /keychain.c/) {
$protocol = "VTYSH_RIPD";
}
if ($file =~ /routemap.c/) {
$protocol = "VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA";
}
if ($file =~ /filter.c/) {
$protocol = "VTYSH_ALL";
}
if ($file =~ /plist.c/) {
if ($defun_array[1] =~ m/ipv6/) {
$protocol = "VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA";
} else {
$protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA";
}
}
if ($file =~ /distribute.c/) {
if ($defun_array[1] =~ m/ipv6/) {
$protocol = "VTYSH_RIPNGD";
} else {
$protocol = "VTYSH_RIPD";
}
}
if ($file =~ /if_rmap.c/) {
if ($defun_array[1] =~ m/ipv6/) {
$protocol = "VTYSH_RIPNGD";
} else {
$protocol = "VTYSH_RIPD";
}
}
if ($file =~ /vty.c/) {
$protocol = "VTYSH_ALL";
}
} else {
($protocol) = ($file =~ /^.*\/([a-z0-9]+)\/[a-zA-Z0-9_\-]+\.c$/);
$protocol = "VTYSH_" . uc $protocol;
}

# Append _vtysh to structure then build DEFUN again
$defun_array[1] = $cmd . "_vtysh";
$defun_body = join (", ", @defun_array);

# $cmd -> $str hash for lookup
$cmd2str{$cmd} = $str;
$cmd2defun{$cmd} = $defun_body;
$cmd2proto{$cmd} = $protocol;
}

# install_element() process
foreach (@install) {
my (@element_array);
@element_array = split (/,/);

# Install node
$enode = $element_array[0];
$enode =~ s/^\s+//g;
$enode =~ s/\s+$//g;
($enode) = ($enode =~ /([0-9A-Z_]+)$/);

# VTY command structure.
($ecmd) = ($element_array[1] =~ /&([^\)]+)/);
$ecmd =~ s/^\s+//g;
$ecmd =~ s/\s+$//g;

# Register $ecmd
if (defined ($cmd2str{$ecmd})
&& ! defined ($ignore{$cmd2str{$ecmd}})) {
my ($key);
$key = $enode . "," . $cmd2str{$ecmd};
$ocmd{$key} = $ecmd;
$odefun{$key} = $cmd2defun{$ecmd};
push (@{$oproto{$key}}, $cmd2proto{$ecmd});
}
}
}

vktod25의 이미지

.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.