Add enum type for user port data structure (PSTN or ISDN)

This commit is contained in:
Andreas Eversberg 2022-12-03 12:42:31 +01:00
parent f450f28681
commit e3e64f7e34
3 changed files with 15 additions and 7 deletions

2
main.c
View File

@ -361,7 +361,7 @@ int main(int argc, char **argv)
v5if = v5x_interface_alloc(v5i, V5X_DIALECT_V51, interface_id, interface_variant, ph_data_req);
if (!v5if)
return -ENOMEM;
v5up = v5x_user_port_create(v5if, 1001, 1);
v5up = v5x_user_port_create(v5if, 1001, V5X_USER_TYPE_ISDN);
if (!v5up)
return -ENOMEM;
#if 0

View File

@ -97,7 +97,7 @@ struct v5x_interface *v5x_interface_alloc(struct v5x_instance *v5i, enum v5x_dia
return v5if;
}
struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t nr, bool is_isdn)
struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t nr, enum v5x_user_type type)
{
struct v5x_user_port *v5up;
@ -105,17 +105,19 @@ struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t
if (!v5up)
return NULL;
v5up->inst = v5if;
v5up->is_isdn = is_isdn;
v5up->type = type;
v5up->ctrl = v51_ctrl_create(NULL, v5up, nr);
if (!v5up->ctrl)
return NULL;
if (is_isdn) {
switch (type) {
case V5X_USER_TYPE_ISDN:
/* TODO: allocate fi
v5up->state = v52_isdn_state_create(v5up, nr);
if (!v5up->state)
return NULL;
*/
} else {
break;
case V5X_USER_TYPE_PSTN:
/* TODO: allocate fi
v5up->state = v52_pstn_state_create(v5up, nr);
if (!v5up->state)
@ -124,6 +126,7 @@ struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t
if (!v5up->pstn.proto)
return NULL;
*/
break;
}
v5up->nr = nr;

View File

@ -35,6 +35,11 @@ enum v5x_dialect {
V5X_DIALECT_V52 = 2,
};
enum v5x_user_type {
V5X_USER_TYPE_ISDN = 1,
V5X_USER_TYPE_PSTN = 2,
};
/* forward-declarations */
struct v5x_interface;
struct v5x_instance;
@ -117,7 +122,7 @@ struct v5x_user_port {
struct v5x_interface *inst; /* back-pointer to instance we're part of */
uint16_t nr; /* port-number in decoded form (0..32767) */
bool is_isdn; /* is this port an ISDN port? */
enum v5x_user_type type; /* type of port (ISDN/PSTN) */
struct v5x_ctrl_proto *ctrl; /* port control instance */
#if 0
@ -138,5 +143,5 @@ struct v5x_instance {
struct v5x_instance *v5x_instance_alloc(void *ctx);
struct v5x_interface *v5x_interface_alloc(struct v5x_instance *v5i, enum v5x_dialect dialect,
uint32_t id, uint8_t variant, 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, bool is_isdn);
struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t nr, enum v5x_user_type);
struct v5x_user_port *v5x_user_port_find(struct v5x_interface *v5if, uint16_t nr);