Refactor {cbsp,sbcap}_cbc_accept_cb

Delay allocating the structures until really needed.
First do checks agains the opened connection, and if an issue is
detected simply close the fd.
Next, fetch or allocate the related peer.
Finally, create the link from the fd.
This makes it easier to add early extra checks later when peers will
contain info on link_mode (client|server|disabled) later on.

Change-Id: Id4f83ec6b0b14e556b1caa9c80e7f68d062fec57
This commit is contained in:
Pau Espin Pedrol
2022-07-21 16:49:51 +02:00
parent 85bc27d394
commit 678a9cb385
6 changed files with 139 additions and 80 deletions

View File

@@ -40,6 +40,8 @@ struct cbc_cbsp_link {
struct cbc_peer *peer;
};
struct cbc_cbsp_link *cbc_cbsp_link_alloc(struct cbc_cbsp_mgr *cbc, struct cbc_peer *peer);
void cbc_cbsp_link_free(struct cbc_cbsp_link *link);
const char *cbc_cbsp_link_name(const struct cbc_cbsp_link *link);
void cbc_cbsp_link_tx(struct cbc_cbsp_link *link, struct osmo_cbsp_decoded *cbsp);
void cbc_cbsp_link_close(struct cbc_cbsp_link *link);

View File

@@ -38,6 +38,8 @@ struct cbc_sbcap_link {
struct cbc_peer *peer;
};
struct cbc_sbcap_link *cbc_sbcap_link_alloc(struct cbc_sbcap_mgr *cbc, struct cbc_peer *peer);
void cbc_sbcap_link_free(struct cbc_sbcap_link *link);
const char *cbc_sbcap_link_name(const struct cbc_sbcap_link *link);
void cbc_sbcap_link_tx(struct cbc_sbcap_link *link, SBcAP_SBC_AP_PDU_t *pdu);
void cbc_sbcap_link_close(struct cbc_sbcap_link *link);