Librouteros
203
if->running ? "running" : "stopped",
if->enabled ? "enabled" : "disabled");
print_interface (if->next);
}
/* Callback function that is called by "ros_interface" */
static int handle_interfaces (ros_connection_t *c, const ros_interface_t *if, void *user_data)
{
print_interface (if);
return (0);
}
int main (int argc, char **argv)
{
ros_connection_t *c;
/* Connect to the router */
c = ros_connect ("my-router.example.com", ROUTEROS_API_PORT,
"api_user", "secret");
if (c == NULL)
{
fprintf (stderr, "ros_connect failed: %s\n", strerror (errno));
exit (EXIT_FAILURE);
}
/* Query a list of interfaces and call "handle_interfaces". */
ros_interface (c, handle_interfaces, /* user data = */ NULL);
/* Disconnect from the router. */
ros_disconnect (c);
exit (EXIT_SUCCESS);
}
External links
• librouteros' homepage
[1]
• librouteros(3) manual page
[2]
• ros.c
[3]
, a thorough example program.
• Freshmeat entry
[4]
• li/jointfilesconvert/437201/bgcrypt in the Free Software Directory
[5]
Comments to this Manuals