This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/24940 ) Change subject: mgcp_protocol: refactor request handler array ...................................................................... mgcp_protocol: refactor request handler array the various types of MGCP requests are implemented in request handlers functions. The function pointers to those functions are held in an array that is used to find the right handler and call it then. The struct used to model the array is defined somewhat away from the array definition and there is also a macro in between that does not help to make the code more understandable. Lets refactor this a bit to have it more distinct. Change-Id: I2ef167b2ac179d2b0683a27a095f9662fda460bf Related: SYS#5535 --- M src/libosmo-mgcp/mgcp_protocol.c 1 file changed, 29 insertions(+), 18 deletions(-) Approvals: daniel: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 895dd9e..f6daffc 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -46,22 +46,47 @@ #include <osmocom/mgcp/mgcp_codec.h> #include <osmocom/mgcp/mgcp_conn.h> +/* Request handler specification, here we specify an array with function + * pointers to the various MGCP requests implemented below */ struct mgcp_request { + /* request name (e.g. "MDCX") */ char *name; + + /* function pointer to the request handler */ struct msgb *(*handle_request) (struct mgcp_parse_data * data); + + /* a human readable name that describes the request */ char *debug_name; }; -#define MGCP_REQUEST(NAME, REQ, DEBUG_NAME) \ - { .name = NAME, .handle_request = REQ, .debug_name = DEBUG_NAME }, - - static struct msgb *handle_audit_endpoint(struct mgcp_parse_data *data); static struct msgb *handle_create_con(struct mgcp_parse_data *data); static struct msgb *handle_delete_con(struct mgcp_parse_data *data); static struct msgb *handle_modify_con(struct mgcp_parse_data *data); static struct msgb *handle_rsip(struct mgcp_parse_data *data); static struct msgb *handle_noti_req(struct mgcp_parse_data *data); +static const struct mgcp_request mgcp_requests[] = { + { .name = "AUEP", + .handle_request = handle_audit_endpoint, + .debug_name = "AuditEndpoint" }, + { .name = "CRCX", + .handle_request = handle_create_con, + .debug_name = "CreateConnection" }, + { .name = "DLCX", + .handle_request = handle_delete_con, + .debug_name = "DeleteConnection" }, + { .name = "MDCX", + .handle_request = handle_modify_con, + .debug_name = "ModifiyConnection" }, + { .name = "RQNT", + .handle_request = handle_noti_req, + .debug_name = "NotificationRequest" }, + + /* SPEC extension */ + { .name = "RSIP", + .handle_request = handle_rsip, + .debug_name = "ReSetInProgress" }, +}; /* Initalize transcoder */ static int setup_rtp_processing(struct mgcp_endpoint *endp, @@ -95,20 +120,6 @@ return cfg->setup_rtp_processing_cb(endp, conn_dst, conn_src); } -/* array of function pointers for handling various - * messages. In the future this might be binary sorted - * for performance reasons. */ -static const struct mgcp_request mgcp_requests[] = { - MGCP_REQUEST("AUEP", handle_audit_endpoint, "AuditEndpoint") - MGCP_REQUEST("CRCX", handle_create_con, "CreateConnection") - MGCP_REQUEST("DLCX", handle_delete_con, "DeleteConnection") - MGCP_REQUEST("MDCX", handle_modify_con, "ModifiyConnection") - MGCP_REQUEST("RQNT", handle_noti_req, "NotificationRequest") - - /* SPEC extension */ - MGCP_REQUEST("RSIP", handle_rsip, "ReSetInProgress") -}; - /* Helper function to allocate some memory for responses and retransmissions */ static struct msgb *mgcp_msgb_alloc(void) { -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/24940 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I2ef167b2ac179d2b0683a27a095f9662fda460bf Gerrit-Change-Number: 24940 Gerrit-PatchSet: 4 Gerrit-Owner: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann at sysmocom.de> Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-Reviewer: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210719/64e33135/attachment.htm>