Module compile error

Hi,

I’m trying to develop my first module.

#include "asterisk.h"

#include <pjsip.h>
#include <pjsip_ua.h>

#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_session.h"
#include "asterisk/module.h"
//#include "asterisk/strings.h"
#include "asterisk/pbx.h"

/*** MODULEINFO
	<depend>pjproject</depend>
	<depend>res_pjsip</depend>
	<depend>res_pjsip_session</depend>
	<support_level>core</support_level>
 ***/

// static void set_transport_variable(struct ast_sip_session *session)
// {
// 	pbx_builtin_setvar_helper(session->channel, "TRANSPORT_ID", transport_id);
// 	return;
// }

static int pbxhelper_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
{
    //set_transport_variable(session);

    return 0;
}

static struct ast_sip_session_supplement pbxhelper_supplement = {
    .method = "INVITE",
	.priority = AST_SIP_SUPPLEMENT_PRIORITY_LAST,
    //.outgoing_request = pbxhelper_outgoing_request,
    .incoming_request = pbxhelper_incoming_request,
};

static int load_module(void)
{
    if (ast_sip_session_register_supplement(&pbxhelper_supplement)) {
		ast_log(LOG_ERROR, "Unable to register PBX Helper supplement\n");
        return AST_MODULE_LOAD_DECLINE;
    }
    return AST_MODULE_LOAD_SUCCESS;
}

static int unload_module(void)
{
    ast_sip_session_unregister_supplement(&pbxhelper_supplement);
    return 0;
}

AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PBX Helper",
    .support_level = AST_MODULE_SUPPORT_CORE,
    .load = load_module,
    .unload = unload_module,
    .load_pri = AST_MODPRI_APP_DEPEND,
);

When I want to compile this simple code, I get the following error. Where am I making a mistake?

In file included from res_pbxhelper.c:7:
res_pbxhelper.c: In function ‘load_module’:
/opt/asterisk-20.8.1/include/asterisk/res_pjsip_session.h:617:3: error: void value not ignored as it ought to be
ast_sip_session_register_supplement_with_module(AST_MODULE_SELF, supplement)

ast_sip_session_register_supplement_with_module doesn’t return anything, it returns void, therefore you can’t check for a return value.

:blush: Thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.