[quagga-dev 5312] Re: how to communicate with quagga daemons?

huhao huhao at is.iscas.ac.cn
Mon Apr 21 11:42:44 BST 2008


hi,all
        i have fixed my problem.Following is the correct codes
        Thank Emmanuel! Thank all!


#define HOST	"localhost"
#define PORT	2601

#define BUFFER_SIZE 1024


int main()
{
	int sock_fd, ret,i=0;
	char *msg[] ={
		"zebra\n",
		"enable\n",
		"zebra\n",
		"configure terminal\n",
		"interface eth0\n",
		"ip address 133.144.10.1/24\n",
		"quit\n",
		"write\n",
	};

	sock_fd = tcp_connect();
		
	while(i<8){
	memset(buffer,0,BUFFER_SIZE);
	ret = read(sock_fd,buffer,BUFFER_SIZE);
	if (ret == -1)
		err_exit("send error");

	printf("received %s\n",buffer);
	
	ret = send(sock_fd,msg[i],strlen(msg[i]),0);
	if (ret == -1)
		err_exit("send error");
	printf("this is %d times\n",i);
	i++;
	}
	
	close(sock_fd);
	printf("successfully closed\n");
	return 1;
}

---------- Original Message ----------------------------------
From: "huhao" <huhao at is.iscas.ac.cn>
Reply-To: huhao at is.iscas.ac.cn
Date:  Mon, 21 Apr 2008 17:29:53 +0800

>
>hi  Emmanue
>
>         i do get connected with quagga daemons using a socket in my program,but i don't know how to give my configuration through my,program.i first try to write commands in socket and send them 
>to the daemons,but it doesn't work.
>
>the following is my programs for simple:
>
>#define HOST	"localhost"
>#define PORT	2601
>
>int main()
>{
>	int sock_fd, ret,i=0;
>	char *msg[] ={                             //I write all my commands here
>		"zebra",
>		"enable",
>		"zebra",
>		"configure terminal",
>		"interface eth0",
>		"ip address 192.168.10.1/24",
>		"quit",
>		"write",
>	};
>
>	sock_fd = tcp_connect();// create tcp socket
>
>	while(i<8){
>	ret = send(sock_fd,msg[i],strlen(msg[i]),0); 
>	if (ret == -1)
>		err_exit("send error"); // my own fuction for errors
>	printf("this is %d times\n",i);
>	i++;
>	}
>	
>	close(sock_fd);
>	printf("successfully closed\n");
>	return 1;
>}
>
>
>
>---------- Original Message ----------------------------------
>From: Emmanuel Vize <emmanuel.vize at 6wind.com>
>Date:  Wed, 16 Apr 2008 07:51:31 +0200
>
>>Hi HuHao,
>>
>>Quagga offers another approach:
>>You can access directly each daemon during runtime and configure it.
>>You can use vtysh to access the CLI of zebra. The commands you type here
>>will be sent to the corresponding daemons.
>>Or you can have a direct access to each daemon, via a telnet socket.
>>Each daemon has its own dedicated port
>>telnet 127.0.0.1 2605 : bgp,  2602 for RIP, 2603 for RIPNG, 2604 for
>>OSPF, 2606 for OSPF6, 2608 for IS-IS.
>>
>>Once your there, you have a CLI close to the CISCO CLI. And you can
>>change your configurations dynamically.
>>
>>Your C program could open a TCP session with the quagga daemons and send
>>the new commands.
>>Or, more simply, you can write the configuration in a file, and send
>>this file to vtysh  (try vtysh -help).
>>
>>Regards,
>>Emmanuel
>>
>>huhao a 閏rit :
>>> hi all:
>>>
>>> 	I have installed quagga 0.98.6, and I want to communicate with quagga
>>> daemons. That is, I need to send new configuration to quagga runtimely
>>> in my programs (not Linux terminal) and quagga will act on this new
>>> configuration at once. All my programs should be written in C language.
>>>
>>> 	Problem: 
>>> 	I have considered two approaches:
>>> 	The first one and the easiest one is to modify the configuration file
>>> of each daemon. This approach is my first choice, however, each daemon
>>> should restart to read the configuration file, isn't it? While I do not
>>> want daemons to restart, is it possible? i need your instructions.
>>>
>>> 	The second one of course is to modify quagga itself. I am intended to
>>> send configurations to quagga interfaces by my program, then quagga will
>>> analyze and set the configurations. But I know little about the quagga
>>> development, i do not know how quagga works and whether can this
>>> approach works. Can you help me?
>>>
>>> 	Any instructions is graceful. Thank you all.
>>> 	Best regards
>>>
>>> 				POP
>>>
>>> _______________________________________________
>>> Quagga-dev mailing list
>>> Quagga-dev at lists.quagga.net
>>> http://lists.quagga.net/mailman/listinfo/quagga-dev
>>>
>>>   
>>
>>
>>-- 
>>Emmanuel Vize
>>Project Leader
>>Tel: +33-1-39-30-92-12
>>Fax: +33-1-39-30-92-11
>>visit our web http://www.6wind.com
>>
>>
>>_______________________________________________
>>Quagga-dev mailing list
>>Quagga-dev at lists.quagga.net
>>http://lists.quagga.net/mailman/listinfo/quagga-dev
>>
> 
>
>
>
>
>________________________________________________________________
>Sent via the WebMail system at is.iscas.ac.cn
>
>
> 
>                   
>
>
>_______________________________________________
>Quagga-dev mailing list
>Quagga-dev at lists.quagga.net
>http://lists.quagga.net/mailman/listinfo/quagga-dev
>
 




________________________________________________________________
Sent via the WebMail system at is.iscas.ac.cn


 
                   





More information about the Quagga-dev mailing list