[Home]

Summary:ASTERISK-00229: [patch] Move common DNS resolver code to separate module
Reporter:Thorsten Lockert (tholo)Labels:
Date Opened:2003-09-06 16:30:00Date Closed:2004-09-25 02:46:18
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) resolver.diff
( 1) resolver.diff
Description:There is a fair amount of code duplication between enum.c and srv.c

****** ADDITIONAL INFORMATION ******

The attached diff moves the common code out to a dns.c module, and changes enum.c and srv.c to call this.  In addition, it also makes allowances for other systems having reentrant resolvers, where Linux has a separate API for this.
Comments:By: Mark Spencer (markster) 2003-09-10 00:27:01

Someone needs to confirm this doesn't break ENUM.

By: John Todd (jtodd) 2003-09-10 19:45:27

I was unable to get this patch to work correctly, but that could be due to my inept patching.  Advice?

The patching seemed to not quite work for srv.h, but that doesn't seem to be the problem since the patch looks like it's already installed in that file.  I found the reference in dns.h but it doesn't seem to be picked up... what am I doing incorrectly?

The following done with a completely "fresh" CVS checkout from around 13:00 PDT 2003-09-10

[root@ms1 asterisk]# pwd
/usr/src/asterisk
[root@ms1 asterisk]# patch -p0 < /tmp/resolver.diff
patching file dns.c
patching file enum.c
patching file srv.c
patching file include/asterisk/dns.h
patching file include/asterisk/srv.h
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file include/asterisk/srv.h.rej
[root@ms1 asterisk]#
[root@ms1 asterisk]# more include/asterisk/srv.h.rej
***************
*** 13,19 ****
 
 #ifndef _ASTERISK_SRV_H
 #define _ASTERISK_SRV_H
- #include <asterisk/channel.h>
 /* Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup */
 extern int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *s
ervice);
 
--- 13,21 ----
 
 #ifndef _ASTERISK_SRV_H
 #define _ASTERISK_SRV_H
+
+ struct ast_channel;
+
 /* Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup */
 extern int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *s
ervice);
 
[root@ms1 asterisk]# make
.
.
[blah blah]
.
.
gcc -g  -o asterisk -rdynamic io.o sched.o logger.o frame.o loader.o config.o channel.o translate.o file.o say.o pbx.o cli.o md5.o term.o ulaw.o alaw.o callerid.o fskmodem.o image.o app.o cdr.o tdd.o acl.o rtp.o manager.o asterisk.o ast_expr.o dsp.o chanvars.o indications.o autoservice.o db.o privacy.o astmm.o enum.o srv.o -ldl -lpthread -lncurses -lm -lresolv   editline/libedit.a db1-ast/libdb1.a
enum.o: In function `ast_get_enum':
/usr/src/asterisk/enum.c:281: undefined reference to `ast_search_dns'
srv.o: In function `ast_get_srv':
/usr/src/asterisk/srv.c:111: undefined reference to `ast_search_dns'
collect2: ld returned 1 exit status
make: *** [asterisk] Error 1
[root@ms1 asterisk]#

By: Thorsten Lockert (tholo) 2003-09-10 20:00:24

It appears a patch to the main Makefile was missed -- you need to add dns.o to the list of objects there.  That should take care of the undefined reference.

By: John Todd (jtodd) 2003-09-10 22:44:27

OK, added and re-built.  Compiles without warnings, but doesn't seem to work with enum.

Here's my test:

exten => 2214,1,Enumlookup(411)
exten => 2214,2,NoOp(${ENUM})
exten => 2214,52,NoOp(${ENUM}-fiftytwo)
exten => 2214,53,Hangup
exten => 2214,3,Hangup

   -- Executing EnumLookup("SIP/2203-24f3", "411") in new stack
   -- Executing NoOp("SIP/2203-24f3", "") in new stack
   -- Executing Hangup("SIP/2203-24f3", "") in new stack

That enum is known to work - I have enum.loligo.com in my enum.conf file as the first zone searched, and previous trials with that number immediately before testing with the patched code seem to give the correct results.  So, I will conclude it's the patch that caused the error.  Feel free to use my enum entries to test with; they should work from anywhere.  (correct response should be "sip:411@fwd")

By: Brian West (bkw918) 2003-09-10 23:16:30

Yep breaks enum

By: Thorsten Lockert (tholo) 2003-09-11 13:11:41

I found the problem.  Now I just don't understand why SRV lookups worked when I tested them -- this problem should have affected both.  A new version of the patch (now also including the Makefile diff) has been uploaded; this one actually succeeds with ENUM lookups...

By: John Todd (jtodd) 2003-09-11 13:43:26

Tested with ENUM - works fine.  Patch applies cleanly.

By: Mark Spencer (markster) 2003-09-26 19:21:47

Applied to CVS