Implement patty_ax25_open()
This commit is contained in:
parent
0d40883e59
commit
87ec27dd92
3 changed files with 38 additions and 8 deletions
|
@ -25,6 +25,24 @@ enum patty_ax25_event {
|
|||
PATTY_AX25_IO_WRITE
|
||||
};
|
||||
|
||||
typedef struct _patty_ax25_sock {
|
||||
enum patty_ax25_obj_type type;
|
||||
|
||||
int iface;
|
||||
int address;
|
||||
int port;
|
||||
int link;
|
||||
} patty_ax25_sock;
|
||||
|
||||
struct _patty_ax25 {
|
||||
patty_list * ifaces;
|
||||
patty_list * ports;
|
||||
patty_list * links;
|
||||
|
||||
patty_dict * fd_lookup;
|
||||
int fd;
|
||||
};
|
||||
|
||||
int patty_ax25_init(patty_ax25 *ax25);
|
||||
|
||||
void patty_ax25_stop(patty_ax25 *ax25);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
enum patty_ax25_obj_type {
|
||||
PATTY_AX25_OBJ_UNKNOWN,
|
||||
PATTY_AX25_OBJ_IF,
|
||||
PATTY_AX25_OBJ_SOCKET,
|
||||
PATTY_AX25_OBJ_PORT,
|
||||
PATTY_AX25_OBJ_LINK
|
||||
};
|
||||
|
@ -19,13 +20,6 @@ typedef struct _patty_ax25_stats {
|
|||
size_t dropped;
|
||||
} patty_ax25_stats;
|
||||
|
||||
typedef struct _patty_ax25 {
|
||||
patty_list * ifaces;
|
||||
patty_list * ports;
|
||||
patty_list * links;
|
||||
|
||||
patty_dict * fd_lookup;
|
||||
int fd;
|
||||
} patty_ax25;
|
||||
typedef struct _patty_ax25 patty_ax25;
|
||||
|
||||
#endif /* _PATTY_AX25_DEFS_H */
|
||||
|
|
18
src/ax25.c
18
src/ax25.c
|
@ -47,3 +47,21 @@ void patty_ax25_stop(patty_ax25 *ax25) {
|
|||
patty_list_destroy(ax25->ports);
|
||||
patty_list_destroy(ax25->ifaces);
|
||||
}
|
||||
|
||||
int patty_ax25_open(patty_ax25 *ax25, const char *ifname) {
|
||||
patty_ax25_if *iface;
|
||||
|
||||
if ((iface = patty_ax25_get_if(ax25, ifname)) == NULL) {
|
||||
goto error_get_if;
|
||||
}
|
||||
|
||||
if (patty_dict_set(ax25->fd_lookup, &ax25->fd, sizeof(ax25->fd), iface) == NULL) {
|
||||
goto error_dict_set;
|
||||
}
|
||||
|
||||
return ax25->fd++;
|
||||
|
||||
error_dict_set:
|
||||
error_get_if:
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue