Need some shit for managing routing tables
This commit is contained in:
parent
94b9a9d481
commit
22366f2d0c
6 changed files with 34 additions and 1 deletions
|
@ -28,11 +28,11 @@ typedef struct _patty_ax25_if patty_ax25_if;
|
|||
#include <patty/ax25/macros.h>
|
||||
#include <patty/ax25/proto.h>
|
||||
#include <patty/ax25/frame.h>
|
||||
#include <patty/ax25/server.h>
|
||||
#include <patty/ax25/call.h>
|
||||
#include <patty/ax25/if.h>
|
||||
#include <patty/ax25/route.h>
|
||||
#include <patty/ax25/sock.h>
|
||||
#include <patty/ax25/server.h>
|
||||
|
||||
int patty_ax25_pton(const char *callsign,
|
||||
uint8_t ssid,
|
||||
|
|
|
@ -32,4 +32,7 @@ patty_ax25_route *patty_ax25_route_table_find(patty_ax25_route_table *table,
|
|||
int patty_ax25_route_table_add(patty_ax25_route_table *table,
|
||||
patty_ax25_route *route);
|
||||
|
||||
int patty_ax25_route_table_delete(patty_ax25_route_table *route,
|
||||
patty_ax25_addr *dest);
|
||||
|
||||
#endif /* _PATTY_AX25_ROUTE_H */
|
||||
|
|
|
@ -23,6 +23,9 @@ int patty_ax25_server_each_if(patty_ax25_server *server,
|
|||
int (*callback)(patty_ax25_if *, void *),
|
||||
void *ctx);
|
||||
|
||||
int patty_ax25_server_add_route(patty_ax25_server *server,
|
||||
patty_ax25_route *route);
|
||||
|
||||
int patty_ax25_server_run(patty_ax25_server *server);
|
||||
|
||||
#endif /* _PATTY_AX25_SERVER_H */
|
||||
|
|
11
src/route.c
11
src/route.c
|
@ -101,3 +101,14 @@ error_dict_set_with_hash:
|
|||
error_exists:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int patty_ax25_route_table_delete(patty_ax25_route_table *route,
|
||||
patty_ax25_addr *dest) {
|
||||
uint32_t hash;
|
||||
|
||||
patty_hash_init(&hash);
|
||||
patty_ax25_addr_hash(&hash, dest);
|
||||
patty_hash_end(&hash);
|
||||
|
||||
return patty_dict_delete_with_hash(route, hash);
|
||||
}
|
||||
|
|
|
@ -425,6 +425,11 @@ error_list_start:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int patty_ax25_server_add_route(patty_ax25_server *server,
|
||||
patty_ax25_route *route) {
|
||||
return patty_ax25_route_table_add(server->routes, route);
|
||||
}
|
||||
|
||||
static int server_socket(patty_ax25_server *server,
|
||||
int client) {
|
||||
patty_ax25_call_socket_request request;
|
||||
|
|
|
@ -25,6 +25,7 @@ static void usage(int argc, char **argv, const char *message, ...) {
|
|||
int main(int argc, char **argv) {
|
||||
patty_ax25_server *server;
|
||||
patty_ax25_if *iface;
|
||||
patty_ax25_route *route;
|
||||
|
||||
if (argc != 2) {
|
||||
usage(argc, argv, "No TNC device or KISS dump file provided");
|
||||
|
@ -46,6 +47,14 @@ int main(int argc, char **argv) {
|
|||
goto error_server_add_if;
|
||||
}
|
||||
|
||||
if ((route = patty_ax25_route_new_default(iface)) == NULL) {
|
||||
goto error_route_new_default;
|
||||
}
|
||||
|
||||
if (patty_ax25_server_add_route(server, route) < 0) {
|
||||
goto error_server_add_route;
|
||||
}
|
||||
|
||||
if (patty_ax25_server_run(server) < 0) {
|
||||
fprintf(stderr, "%s: %s: %s: %s\n",
|
||||
argv[0], argv[1], "patty_ax25_server_run()", strerror(errno));
|
||||
|
@ -58,6 +67,8 @@ int main(int argc, char **argv) {
|
|||
return 0;
|
||||
|
||||
error_server_run:
|
||||
error_server_add_route:
|
||||
error_route_new_default:
|
||||
error_server_add_if:
|
||||
error_if_addr_add:
|
||||
error_if_new:
|
||||
|
|
Loading…
Add table
Reference in a new issue