⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cs427 talking to the zebra daemon.htm

📁 zebra免费软件
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0057)http://wiki.cs.uiuc.edu/cs427/Talking+to+the+Zebra+daemon -->
<HTML><HEAD><TITLE>cs427: Talking to the Zebra daemon</TITLE>
<META http-equiv=Content-Type content="text/html; charset=big5">
<META content="MSHTML 6.00.2800.1458" name=GENERATOR></HEAD>
<BODY vLink=#000000 link=#0000ff bgColor=#ffffff><FONT color=#000000>
<TABLE cellSpacing=2 cellPadding=0 width="100%" bgColor=#ffffc0>
  <TBODY>
  <TR>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/EDIT/Talking+to+the+Zebra+daemon">Edit</A></FONT></TD>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/RENAME/Talking+to+the+Zebra+daemon">Rename</A></FONT></TD>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/DIFF/8/7/Talking+to+the+Zebra+daemon">Changes</A></FONT></TD>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/HISTORY/Talking+to+the+Zebra+daemon">History</A></FONT></TD>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/UPLOAD">Upload</A></FONT></TD>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/DOWNLOAD/">Download</A></FONT></TD>
    <TD><FONT face=Arial><A href="http://wiki.cs.uiuc.edu/cs427">Back to 
      Top</A></FONT></TD></TR></TBODY></TABLE>
<H2><FONT face=Arial><A 
href="http://wiki.cs.uiuc.edu/cs427/SEARCH/Talking+to+the+Zebra+daemon">Talking 
to the Zebra daemon</A></FONT></H2><!-- unformatted page contents --


--------

[NEXT > http://wiki.cs.uiuc.edu/cs427/The+Thread+Mechanism+in+Zebra]  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [HOME > http://wiki.cs.uiuc.edu/cs427/Software+Architecture+of+Zebra]

----------


<br>


Zebra defines a protocol, called the Zebra protocol, for communicating with the various routing protocols. If someone wants to add a new routing protocol to the Zebra software, then they have to implement this interface in order to interact with the manager daemon. The communication with Zebra daemon provides information about interfaces and routes, allowing you to know which interfaces exist and their configurations, and which routes are installed and by what daemons (ospf, bgp, ...).

The zclient.h library declares the API. It defines the main structure, zclient,  for talking to the main daemon and many function prototypes. The elements of zclient are as follows:

* sock (Socket to zebra daemon.)
...
* thread *t_read;
* thread *t_connect;
* ...
* Pointer to the callback functions
* int (*interface_add) (int, struct zclient *, zebra_size_t);
* int (*interface_delete) (int, struct zclient *, zebra_size_t);
* int (*interface_up) (int, struct zclient *, zebra_size_t);
* int (*interface_down) (int, struct zclient *, zebra_size_t);
* int (*interface_address_add) (int, struct zclient *, zebra_size_t);
* int (*interface_address_delete) (int, struct zclient *, zebra_size_t);
* int (*ipv4_route_add) (int, struct zclient *, zebra_size_t);
* int (*ipv4_route_delete) (int, struct zclient *, zebra_size_t);
* int (*ipv6_route_add) (int, struct zclient *, zebra_size_t);
* int (*ipv6_route_delete) (int, struct zclient *, zebra_size_t);

All the routing protocols implement a file called <protocol_name>_zebra.c which implements the API defined in zclient.h. Each protocol fills in the callback functions in the zclient structure and the command node to be installed. Other command elements are installed as well in the respective command nodes. These functions are called whenever such an event happens. 

For example, the RIP protocol implements the communication protocol in a file named rip_zebra.c and implements the following callback functions

int rip_interface_add (int, struct zclient *, zebra_size_t);
int rip_interface_delete (int, struct zclient *, zebra_size_t);
int rip_interface_address_add (int, struct zclient *, zebra_size_t);
int rip_interface_address_delete (int, struct zclient *, zebra_size_t);
int rip_interface_up (int, struct zclient *, zebra_size_t);
int rip_interface_down (int, struct zclient *, zebra_size_t);


<b>Very short summary of ripd startup</b>

* rip started ?calls main() in rip_main.c 

* main() calls rip_zclient_init() in rip_zebra.c

* rip_zclient_init( ) sets default value to the zebra client structure, installs zebra node, and installs command elements into the zebra node and the rip node.




--------------------

[NEXT > http://wiki.cs.uiuc.edu/cs427/The+Thread+Mechanism+in+Zebra]  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [HOME > http://wiki.cs.uiuc.edu/cs427/Software+Architecture+of+Zebra]
//-- unformatted page contents -->
<P>
<P>
<HR>

<P><A 
href="http://wiki.cs.uiuc.edu/cs427/The+Thread+Mechanism+in+Zebra">NEXT</A> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A 
href="http://wiki.cs.uiuc.edu/cs427/Software+Architecture+of+Zebra">HOME</A> 
<P>
<HR>

<P>
<P><BR>
<P>
<P>Zebra defines a protocol, called the Zebra protocol, for communicating with 
the various routing protocols. If someone wants to add a new routing protocol to 
the Zebra software, then they have to implement this interface in order to 
interact with the manager daemon. The communication with Zebra daemon provides 
information about interfaces and routes, allowing you to know which interfaces 
exist and their configurations, and which routes are installed and by what 
daemons (ospf, bgp, ...). 
<P>The zclient.h library declares the API. It defines the main structure, 
zclient, for talking to the main daemon and many function prototypes. The 
elements of zclient are as follows: 
<P>
<UL>
  <LI>sock (Socket to zebra daemon.) ... 
  <LI>thread *t_read; 
  <LI>thread *t_connect; 
  <LI>... 
  <LI>Pointer to the callback functions 
  <LI>int (*interface_add) (int, struct zclient *, zebra_size_t); 
  <LI>int (*interface_delete) (int, struct zclient *, zebra_size_t); 
  <LI>int (*interface_up) (int, struct zclient *, zebra_size_t); 
  <LI>int (*interface_down) (int, struct zclient *, zebra_size_t); 
  <LI>int (*interface_address_add) (int, struct zclient *, zebra_size_t); 
  <LI>int (*interface_address_delete) (int, struct zclient *, zebra_size_t); 
  <LI>int (*ipv4_route_add) (int, struct zclient *, zebra_size_t); 
  <LI>int (*ipv4_route_delete) (int, struct zclient *, zebra_size_t); 
  <LI>int (*ipv6_route_add) (int, struct zclient *, zebra_size_t); 
  <LI>int (*ipv6_route_delete) (int, struct zclient *, zebra_size_t); 
</LI></UL>All the routing protocols implement a file called 
<PROTOCOL_NAME>_zebra.c which implements the API defined in zclient.h. Each 
protocol fills in the callback functions in the zclient structure and the 
command node to be installed. Other command elements are installed as well in 
the respective command nodes. These functions are called whenever such an event 
happens. 
<P>For example, the RIP protocol implements the communication protocol in a file 
named rip_zebra.c and implements the following callback functions 
<P>int rip_interface_add (int, struct zclient *, zebra_size_t); int 
rip_interface_delete (int, struct zclient *, zebra_size_t); int 
rip_interface_address_add (int, struct zclient *, zebra_size_t); int 
rip_interface_address_delete (int, struct zclient *, zebra_size_t); int 
rip_interface_up (int, struct zclient *, zebra_size_t); int rip_interface_down 
(int, struct zclient *, zebra_size_t); 
<P>
<P><B>Very short summary of ripd startup</B> 
<P>
<UL>
  <LI>rip started ?calls main() in rip_main.c </LI></UL>
<UL>
  <LI>main() calls rip_zclient_init() in rip_zebra.c </LI></UL>
<UL>
  <LI>rip_zclient_init( ) sets default value to the zebra client structure, 
  installs zebra node, and installs command elements into the zebra node and the 
  rip node. </LI></UL>
<P>
<P>
<P>
<HR>

<P><A 
href="http://wiki.cs.uiuc.edu/cs427/The+Thread+Mechanism+in+Zebra">NEXT</A> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A 
href="http://wiki.cs.uiuc.edu/cs427/Software+Architecture+of+Zebra">HOME</A>
<P>
<HR>

<FORM action=/cs427/SEARCH method=post><INPUT type=hidden value=SEARCH 
name=COMMAND> <INPUT type=submit value=Find...> <INPUT size=40 
name=SEARCHPATTERN> </FORM>
<TABLE cellSpacing=2 cellPadding=0 width="100%" bgColor=#ffffc0>
  <TBODY>
  <TR>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/EDIT/Talking+to+the+Zebra+daemon">Edit</A></FONT></TD>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/RENAME/Talking+to+the+Zebra+daemon">Rename</A></FONT></TD>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/DIFF/8/7/Talking+to+the+Zebra+daemon">Changes</A></FONT></TD>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/HISTORY/Talking+to+the+Zebra+daemon">History</A></FONT></TD>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/UPLOAD">Upload</A></FONT></TD>
    <TD><FONT face=Arial><A 
      href="http://wiki.cs.uiuc.edu/cs427/DOWNLOAD/">Download</A></FONT></TD>
    <TD><FONT face=Arial><A href="http://wiki.cs.uiuc.edu/cs427">Back to 
      Top</A></FONT></TD></TR></TBODY></TABLE></FONT></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -