Added destroy function for interface

This commit is contained in:
Andreas Eversberg 2022-12-18 10:07:24 +01:00
parent 65dac95ff0
commit 2a23a1c9cf
2 changed files with 32 additions and 0 deletions

View File

@ -106,6 +106,37 @@ struct v5x_interface *v5x_interface_alloc(struct v5x_instance *v5i, enum v5x_dia
return v5if;
}
void v5x_interface_free(struct v5x_interface *v5if) {
struct v5x_user_port *v5up, *v5up2;
llist_for_each_entry_safe(v5up, v5up2, &v5if->user_ports, list)
v5x_user_port_destroy(v5up);
if (v5if->control.ctrl)
v5x_le_ctrl_destroy(v5if->control.ctrl);
if (v5if->control.li)
lapv5_instance_free(v5if->control.li);
if (v5if->pstn.li)
lapv5_instance_free(v5if->pstn.li);
if (v5if->lcp.li)
lapv5_instance_free(v5if->lcp.li);
if (v5if->bcc.li)
lapv5_instance_free(v5if->bcc.li);
if (v5if->protection[0].li)
lapv5_instance_free(v5if->protection[0].li);
if (v5if->protection[1].li)
lapv5_instance_free(v5if->protection[1].li);
llist_del(&v5if->list);
talloc_free(v5if);
}
struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t nr, enum v5x_user_type type,
uint8_t ts1, uint8_t ts2)
{

View File

@ -208,6 +208,7 @@ struct v5x_interface *v5x_interface_alloc(struct v5x_instance *v5i, enum v5x_dia
int (*ph_data_req_cb)(struct msgb *msg, void *cbdata));
struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t nr, enum v5x_user_type,
uint8_t ts1, uint8_t ts2);
void v5x_interface_free(struct v5x_interface *v5if);
struct v5x_user_port *v5x_user_port_find(struct v5x_interface *v5if, uint16_t nr, bool is_isdn);
void v5x_user_port_destroy(struct v5x_user_port *v5up);
//FIXME: move this