<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">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">chan_sip.exports.in</a></i> so it looks like</div><div><div>{<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>global:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>LINKER_SYMBOL_PREFIXsip_get_header; // I also tried LINKER_SYMBOL_PREFIXsip_*;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>LINKER_SYMBOL_PREFIX_IO_stdin_used;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>local:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>*;</div><div>};</div></div><div>But it doesn't work. I did the same with <i><a href="http://system.exports.in">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="HOEnZb"><div class="h5">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="HOEnZb"><div class="h5"><br>
<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>
</div></div></blockquote></div><br></div>