<div dir="ltr">Thank you for this simple solution, it solved the last problem. <div><br></div><div>Another issue arised: Before, system.c was in the main/ directory and used the project wide exports file to export its functions, now it's in channels/ where apparantly doesn't exist such a file.</div><div>I created <i><a href="http://system.exports.in" target="_blank">system.exports.in</a></i> in channels/ to export the functions but the Asterisk build system does not automatically generate the <i>system.exports</i> file and manually creating it doesn't work either.</div><div><div><span class="m_9102587054871105639gmail-im"><br style="font-size:12.8px"><span style="font-size:12.8px"><b>system.h</b></span><br style="font-size:12.8px"><span style="font-size:12.8px">void ast_system_get_address(struct ast_sockaddr *us);</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"><b>system.c</b></span><br style="font-size:12.8px"></span><span class="m_9102587054871105639gmail-im" style="font-size:12.8px"><span style="font-size:12.8px">#include "asterisk/system.h"</span></span></div><div><span class="m_9102587054871105639gmail-im" style="font-size:12.8px"><br style="font-size:12.8px"></span><span class="m_9102587054871105639gmail-im"><div><span style="font-size:12.8px">void ast_system_get_address(struct ast_sockaddr *us)</span></div><div><span style="font-size:12.8px">{</span></div><div> ...</div><div><span style="font-size:12.8px">}</span></div><br style="font-size:12.8px"></span><span class="m_9102587054871105639gmail-im" style="font-size:12.8px"><span style="font-size:12.8px"><b>chan_sip.c</b></span><br style="font-size:12.8px"><span style="font-size:12.8px">#include "asterisk/system.h"</span><br style="font-size:12.8px"><br style="font-size:12.8px"></span><span style="font-size:12.8px">ast_system_get_address(us);</span></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-12-09 18:42 GMT+01:00 Corey Farrell <span dir="ltr"><<a href="mailto:git@cfware.com" target="_blank">git@cfware.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I'm not sure what you're trying to accomplish but this is not the approach I'd take for expanding chan_sip. My advice is to simply put your system.c into channels/sip. This will automatically link it into the binary chan_sip module, but allow you to keep your source code in a separate file. I believe MODULEINFO (for any added dependencies) and possibly a call to your init/cleanup would be the only changes you'd need to make in chan_sip.c. All non-static symbols in chan_sip.c and channels/sip/*.c are available across all sources of chan_sip.so without needing <a href="http://chan_sip.exports.in" target="_blank">chan_sip.exports.in</a> or AST_MODFLAG_GLOBAL_SYMBOLS.<br></div><div><br></div><div>The only exception is if you need to call chan_sip functions from another existing module, then you will have to export the symbols. To do this you have to tell the linker (via <a href="http://chan_sip.exports.in" target="_blank">chan_sip.exports.in</a>) and you have to tell the module loader. AST_MODULE_INFO at the very end of chan_sip.c would need AST_MODFLAG_GLOBAL_SYMBOLS so the module loader knows to share the globals:</div><div><div><br></div><div>AST_MODULE_INFO(ASTERISK_GPL_<wbr>KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Session Initiation Protocol (SIP)",</div></div><div><br></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 9, 2016 at 10:50 AM, Julian Fleischhauer <span dir="ltr"><<a href="mailto:julian.fleischhauer@stud.uni-due.de" target="_blank">julian.fleischhauer@stud.uni-<wbr>due.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I could resolve the XML and pcap issues, but still have problems concerning "sip_get_header()". I don't want to rename the function since it's a frequently used function in chan_sip.c, I therefore defined an .<a href="http://exports.in" target="_blank">exports.in</a> file. I don't know if Mr. Michelson understood me correctly, but I think chan_sip.c exports "sip_get_header()" (doesn't it?) so I modified <i><a href="http://chan_sip.exports.in" target="_blank">chan_sip.exports.in</a></i> so it looks like</div><div><div>{<br></div><div><span class="m_-7176898891572435163m_2881934891775271036gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>global:</div><div><span class="m_-7176898891572435163m_2881934891775271036gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>LINKER_SYMBOL_PREFIXsip_get_he<wbr>ader; // I also tried LINKER_SYMBOL_PREFIXsip_*;</div><div><span class="m_-7176898891572435163m_2881934891775271036gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>LINKER_SYMBOL_PREFIX_IO_stdin_<wbr>used;</div><div><span class="m_-7176898891572435163m_2881934891775271036gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>local:</div><div><span class="m_-7176898891572435163m_2881934891775271036gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>*;</div><div>};</div></div><div>But it doesn't work. I did the same with <i><a href="http://system.exports.in" target="_blank">system.exports.in</a></i>, without success.</div><div><br></div><div><br></div><div>Sorry for the badly formatted last mail. I will post the updated file structure again below.<br></div><div><br></div><div><span style="font-size:12.8px"><b>sip.h</b></span><br style="font-size:12.8px"><span style="font-size:12.8px">const char *sip_get_header(const struct sip_request *req, const char *name);</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"><b>system.h</b></span><br style="font-size:12.8px"><span style="font-size:12.8px">#include "asterisk/netsock2.h"</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">void ast_some_function(struct sip_pvt *p, struct ast_sockaddr *addr);</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px"><b>system.c</b></span><br style="font-size:12.8px"><span style="font-size:12.8px">#include "asterisk/system.h"</span><br style="font-size:12.8px"><span style="font-size:12.8px">#include "asterisk/sip.h"</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">void ast_some_function(struct sip_pvt *p, struct ast_sockaddr *addr)</span><br style="font-size:12.8px"><span style="font-size:12.8px">{</span><br style="font-size:12.8px"><span style="font-size:12.8px"> ast_copy_string(touser, sip_get_header(req, "To"), strlen(sip_get_header(req, "To")) + 1);</span><br style="font-size:12.8px"><span style="font-size:12.8px">}</span><br><br style="font-size:12.8px"><span style="font-size:12.8px"><b>chan_sip.c</b></span><br style="font-size:12.8px"><span style="font-size:12.8px">#include "asterisk/system.h"</span><br style="font-size:12.8px"><span style="font-size:12.8px">#include "asterisk/sip.h"</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">ast_some_function(p, addr);</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Best regards,</span></div><div><span style="font-size:12.8px">Julian Fleischhauer</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-12-06 18:35 GMT+01:00 Mark Michelson <span dir="ltr"><<a href="mailto:mmichelson@digium.com" target="_blank">mmichelson@digium.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-7176898891572435163m_2881934891775271036HOEnZb"><div class="m_-7176898891572435163m_2881934891775271036h5">On 12/05/2016 04:53 PM, Julian Fleischhauer wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hey all,<br>
<br>
I have a problem using a custom C-file. The error ouput received when compiling is given below.<br>
<br>
error output<br>
.../system.c:1330: undefined reference to `XML_ParserCreate'<br>
...<br>
.../system.c:1465: undefined reference to `sip_get_header'<br>
...<br>
.../system.c:1608: undefined reference to `pcap_lookupnet'<br>
...<br>
<br>
<br>
Before, I had all code in chan_sip.c. I want to transfer the code into a separate file (system.c) now. The dependencies given below MODULEINFO are customly set and worked fine when used in chan_sip.c. Can anyone figure out if something else has to be added somewhere? The code is quoted below:<br>
<br>
sip.h<br>
const char *sip_get_header(const struct sip_request *req, const char *name);<br>
<br>
system.h<br>
#include "asterisk/netsock2.h"<br>
<br>
void ast_some_function(struct sip_pvt *p, struct ast_sockaddr *addr);<br>
<br>
system.c<br>
/*** MODULEINFO<br>
<depend>sqlite3</depend><br>
<depend>expat</depend><br>
<depend>pcap</depend><br>
<support_level>extended</suppo<wbr>rt_level><br>
***/<br>
<br>
#include "asterisk/system.h"<br>
#include "asterisk/sip.h"<br>
<br>
void ast_some_function(struct sip_pvt *p, struct ast_sockaddr *addr)<br>
{<br>
xmlParser = XML_ParserCreate(NULL);<br>
...<br>
ast_copy_string(touser, sip_get_header(req, "To"), strlen(sip_get_header(req, "To"))+1);<br>
...<br>
pcap_lookupnet(pcapDev, &netp, &maskp, errbuf);<br>
}<br>
<br>
chan_sip.c<br>
#include "asterisk/system.h"<br>
#include "asterisk/sip.h"<br>
<br>
ast_some_function(p, addr);<br>
<br>
<br>
Thank you for any help!<br>
<br>
Regards,<br>
Juliannn<br>
<br>
</blockquote></div></div>
I can explain why sip_get_header() is causing a problem. In order for functions to be callable from other modules, they need to be explicitly exported. This is why you'll see files like res/<a href="http://res_agi.exports.in" rel="noreferrer" target="_blank">res_agi.exports.in</a>, which define functions that can be called globally from that module. You have a couple of options here:<br>
<br>
* Define a .<a href="http://exports.in" rel="noreferrer" target="_blank">exports.in</a> file for your system.c file that exports the sip_get_header() function.<br>
* Change "sip_get_header()" to "ast_sip_get_header()". Assuming that system.c is in the main/ directory, there is a project-wide exports file that makes it so any function starting with "ast" can be called externally.<br>
<br>
Regarding the XML and pcap issues, the issues are either that<br>
* You're not #including the necessary files.<br>
* The libraries are not being linked during compilation.<br>
<br>
The first problem is easy to fix: just #include the right files :). The second problem is a bit more tricky because you'll need to dig into Makefiles and try to figure out how libraries get linked when Asterisk is built.<div class="m_-7176898891572435163m_2881934891775271036HOEnZb"><div class="m_-7176898891572435163m_2881934891775271036h5"><br><span class="m_-7176898891572435163HOEnZb"><font color="#888888">
<br>
-- <br>
______________________________<wbr>______________________________<wbr>_________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" rel="noreferrer" target="_blank">http://www.api-digital.com</a> --<br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" rel="noreferrer" target="_blank">http://lists.digium.com/mailma<wbr>n/listinfo/asterisk-dev</a><br>
<br>
</font></span></div></div></blockquote></div><br></div>
<br>--<br>
______________________________<wbr>______________________________<wbr>_________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" rel="noreferrer" target="_blank">http://www.api-digital.com</a> --<br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" rel="noreferrer" target="_blank">http://lists.digium.com/mailm<wbr>an/listinfo/asterisk-dev</a><br></blockquote></div><br></div>
</div></div><br>--<br>
______________________________<wbr>______________________________<wbr>_________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" rel="noreferrer" target="_blank">http://www.api-digital.com</a> --<br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" rel="noreferrer" target="_blank">http://lists.digium.com/<wbr>mailman/listinfo/asterisk-dev</a><br></blockquote></div><br></div>