[svn-commits] oej: branch oej/codename-pineapple r46373 - in /team/oej/codename-pineapple: ...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Oct 27 14:35:28 MST 2006


Author: oej
Date: Fri Oct 27 16:35:27 2006
New Revision: 46373

URL: http://svn.digium.com/view/asterisk?rev=46373&view=rev
Log:
Ooops. Where did that user go?

- Well, we can compile cleanly again.
- Starting to define states for dialogs and transactions
- Need to update to trunk, include Luigi's  auth fixes
- New file for dialog stuff

Added:
    team/oej/codename-pineapple/channels/sip3/sip3_dialog.c   (with props)
Modified:
    team/oej/codename-pineapple/channels/Makefile
    team/oej/codename-pineapple/channels/chan_sip3.c
    team/oej/codename-pineapple/channels/sip3/Makefile
    team/oej/codename-pineapple/channels/sip3/sip3.h
    team/oej/codename-pineapple/channels/sip3/sip3_auth.c
    team/oej/codename-pineapple/channels/sip3/sip3_callerid.c
    team/oej/codename-pineapple/channels/sip3/sip3_cliami.c
    team/oej/codename-pineapple/channels/sip3/sip3_config.c
    team/oej/codename-pineapple/channels/sip3/sip3_domain.c
    team/oej/codename-pineapple/channels/sip3/sip3_network.c
    team/oej/codename-pineapple/channels/sip3/sip3_parse.c
    team/oej/codename-pineapple/channels/sip3/sip3_refer.c
    team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c
    team/oej/codename-pineapple/channels/sip3/sip3funcs.h
    team/oej/codename-pineapple/contrib/asterisk-ng-doxygen

Modified: team/oej/codename-pineapple/channels/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/Makefile?rev=46373&r1=46372&r2=46373&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/Makefile (original)
+++ team/oej/codename-pineapple/channels/Makefile Fri Oct 27 16:35:27 2006
@@ -14,7 +14,8 @@
 C_MODS:=$(filter-out $(MENUSELECT_CHANNELS),$(patsubst %.c,%,$(wildcard chan_*.c)))
 CC_MODS:=$(filter-out $(MENUSELECT_CHANNELS),$(patsubst %.cc,%,$(wildcard chan_*.cc)))
 SIP3_MODULES=chan_sip3.o sip3/sip3_network.o sip3/sip3_subscribe.o sip3/sip3_refer.o sip3/sip3_domain.o \
-	sip3/sip3_callerid.o sip3/sip3_auth.o sip3/sip3_sdprtp.o sip3/sip3_config.o
+	sip3/sip3_callerid.o sip3/sip3_auth.o sip3/sip3_sdprtp.o sip3/sip3_config.o \
+	sip3/sip3_cliami.o sip3/sip3_dialog.o
 
 ifeq ($(OSARCH),OpenBSD)
   PTLIB=-lpt_OpenBSD_x86_r
@@ -119,6 +120,6 @@
 sip3:	
 	$(MAKE) -C sip3 
 
-chan_sip3.so: $(SIP3_MODULES) sip3/sip3.h sip3/sip3core.h sip3/sip3funcs.h
+chan_sip3.so: $(SIP3_MODULES) sip3/sip3.h  sip3/sip3funcs.h
 	$(ECHO_PREFIX) echo "   [LD] $^ -> $@"
 	$(CMD_PREFIX) $(CXX) $(SOLINK) -o $@ $< 

Modified: team/oej/codename-pineapple/channels/chan_sip3.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/chan_sip3.c?rev=46373&r1=46372&r2=46373&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/chan_sip3.c (original)
+++ team/oej/codename-pineapple/channels/chan_sip3.c Fri Oct 27 16:35:27 2006
@@ -93,15 +93,20 @@
  * the sip_hangup() function
  */
 
-/*! Chan_sip3 changes
-
+/*! 
+	\page chan_sip3_start Welcome to Codename Pineapple :: chan_sip3 !
+
+	\title What's this?
+	This is a re-work of the SIP channel in Asterisk. 
 	This channel will not be backwards compatible with the old 
 	sip channel. In order to be more SIP compatible, I will have
 	to break the backwards compatibility. That's why the old channel
-	will still be around.
+	will still be around for a while.
 
 	** This work is sponsored by voop.com - the Internet Dialtone.
-
+	   I am open for more sponsors - contact me on oej at edvina.net
+
+	\page chan_sip3_todo Things to do
 	Done
 	- removed userconf support (in favour of astum)
 	- added the peermatch branch
@@ -135,6 +140,33 @@
 	- change "sip nodebug" to "sip debug off" and "sip debug" to "sip debug on"
 
 	- ... And much more
+
+	\page chan_sip3_objects	Chan_sip3: Devices, trunks and services
+	- \b phones are devices that connect to Asterisk. They register with  
+	Asterisk acting as a SIP location server/registrar and use Asterisk 
+	as the outbound SIP  proxy. They get calls from Asterisk and place 
+	calls to Asterisk. The phone use one of  the SIP domains that are hosted 
+	within your Asterisk server. (this is like the  
+	current "friend")
+
+	- \b service is when Asterisk is the UA, acting as a phone towards  
+	another SIP server - we register with a SIP location server/registrar 
+	to get incoming  calls. We place
+	calls, masquerading as a phone (using the registrars domain).
+	Currently, this is a mixture between a peer (matched on IP for  
+	incoming calls) and a register= statement. In some cases, two 
+	peers and a register= statement.  Very confusing.
+
+	- \b trunk is when we exchange traffic with another server. We send  
+	calls to their SIP domain and receive calls to our SIP domain. We may 
+	use realm based authentication for the incoming part of the trunk 
+	(not based on caller ID/From: header) and a combination of SIP domain and ACLs.
+	This is currently handled by defining sip peers for outbound calls and
+	separate SIP peers for inbound calls - where we match on IP. The
+	problem with the IP matching is when a trunking partner use several
+	SIP servers to connect to us, we need to define one peer per server
+	instead of just matching on domain and then authenticate.
+
 */
 
 #define CHAN_SIP3_MAIN
@@ -227,9 +259,6 @@
 /* Object counters */
 struct channel_counters sipcounters = { 0, 0, 0, 0, 0, 0 };
 
-/*! \brief Protect the SIP dialog list (of sip_pvt's) */
-AST_MUTEX_DEFINE_STATIC(iflock);
-
 /*! \brief Protect the monitoring thread, so only one process can kill or start it, and not
    when it's doing something critical. */
 
@@ -247,19 +276,13 @@
 struct sched_context *sched;     /*!< The scheduling context */
 struct io_context *io;           /*!< The IO context */
 
-AST_LIST_HEAD_NOLOCK(sip_history_head, sip_history); /*!< history list, entry in sip_pvt */
-
-
 /* --- Linked lists of various objects --------*/
 
 /*! \brief List of concurrent SIP dialogs */
-static struct sip_pvt *dialoglist = NULL;
-
-/*! \brief The user list: Users and friends */
-struct sip_user_list userl;
+struct sip_dialog *dialoglist = NULL;
 
 /*! \brief The peer list: Peers and Friends */
-struct sip_device_list peerl;
+struct sip_device_list devicelist;
 
 /*! \brief  The register list: Other SIP proxys we register with and place calls to */
 struct sip_register_list regl;
@@ -296,82 +319,77 @@
 static int sip_senddigit_end(struct ast_channel *ast, char digit);
 
 /*--- Transmitting responses and requests */
-static int __transmit_response(struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable);
-static int transmit_sip_request(struct sip_pvt *p, struct sip_request *req);
+static int __transmit_response(struct sip_dialog *p, const char *msg, const struct sip_request *req, enum xmittype reliable);
+static int transmit_sip_request(struct sip_dialog *p, struct sip_request *req);
 static int transmit_response_using_temp(ast_string_field callid, struct sockaddr_in *sin, int useglobal_nat, const int intended_method, const struct sip_request *req, const char *msg);
-static int transmit_response(struct sip_pvt *p, const char *msg, const struct sip_request *req);
-static int transmit_response_reliable(struct sip_pvt *p, const char *msg, const struct sip_request *req);
-static int transmit_response_with_date(struct sip_pvt *p, const char *msg, const struct sip_request *req);
-static int transmit_response_with_sdp(struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable);
-static int transmit_response_with_unsupported(struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *unsupported);
-static int transmit_response_with_auth(struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *rand, enum xmittype reliable, const char *header, int stale);
-static int transmit_response_with_allow(struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable);
-static void transmit_fake_auth_response(struct sip_pvt *p, struct sip_request *req, int reliable);
-static int transmit_request(struct sip_pvt *p, int sipmethod, int inc, enum xmittype reliable, int newbranch);
-static int transmit_request_with_auth(struct sip_pvt *p, int sipmethod, int seqno, enum xmittype reliable, int newbranch);
-static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init);
-static int transmit_info_with_digit(struct sip_pvt *p, const char digit);
-static int transmit_info_with_vidupdate(struct sip_pvt *p);
-static int transmit_message_with_text(struct sip_pvt *p, const char *text);
-static int transmit_refer(struct sip_pvt *p, const char *dest);
-static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs, char *vmexten);
-static int transmit_notify_with_sipfrag(struct sip_pvt *p, int cseq, char *message, int terminate);
-static int transmit_state_notify(struct sip_pvt *p, int state, int full);
-static int transmit_register(struct sip_registry *r, int sipmethod, const char *auth, const char *authheader);
+static int transmit_response_reliable(struct sip_dialog *p, const char *msg, const struct sip_request *req);
+static int transmit_response_with_date(struct sip_dialog *p, const char *msg, const struct sip_request *req);
+static int transmit_response_with_sdp(struct sip_dialog *p, const char *msg, const struct sip_request *req, enum xmittype reliable);
+static int transmit_response_with_unsupported(struct sip_dialog *p, const char *msg, const struct sip_request *req, const char *unsupported);
+static int transmit_response_with_allow(struct sip_dialog *p, const char *msg, const struct sip_request *req, enum xmittype reliable);
+static void transmit_fake_auth_response(struct sip_dialog *p, struct sip_request *req, int reliable);
+static int transmit_request(struct sip_dialog *p, int sipmethod, int inc, enum xmittype reliable, int newbranch);
+static int transmit_request_with_auth(struct sip_dialog *p, int sipmethod, int seqno, enum xmittype reliable, int newbranch);
+static int transmit_info_with_digit(struct sip_dialog *p, const char digit);
+static int transmit_info_with_vidupdate(struct sip_dialog *p);
+static int transmit_message_with_text(struct sip_dialog *p, const char *text);
+static int transmit_refer(struct sip_dialog *p, const char *dest);
+static int transmit_notify_with_mwi(struct sip_dialog *p, int newmsgs, int oldmsgs, char *vmexten);
+static int transmit_notify_with_sipfrag(struct sip_dialog *p, int cseq, char *message, int terminate);
+static int transmit_state_notify(struct sip_dialog *p, int state, int full);
 static void copy_request(struct sip_request *dst, const struct sip_request *src);
-static void receive_message(struct sip_pvt *p, struct sip_request *req);
-static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req);
+static void receive_message(struct sip_dialog *p, struct sip_request *req);
+static void parse_moved_contact(struct sip_dialog *p, struct sip_request *req);
 static int sip_send_mwi_to_peer(struct sip_peer *peer);
 static int does_peer_need_mwi(struct sip_peer *peer);
 
 /*--- Dialog management */
-static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *sin,
+static struct sip_dialog *sip_alloc(ast_string_field callid, struct sockaddr_in *sin,
 				 int useglobal_nat, const int intended_method);
 static int __sip_autodestruct(void *data);
-static void sip_scheddestroy(struct sip_pvt *p, int ms);
-static void sip_cancel_destroy(struct sip_pvt *p);
-static void sip_destroy(struct sip_pvt *p);
-static void __sip_destroy(struct sip_pvt *p, int lockowner);
-static void __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod, int reset);
-static void __sip_pretend_ack(struct sip_pvt *p);
-static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod);
+static void sip_cancel_destroy(struct sip_dialog *p);
+static void sip_destroy(struct sip_dialog *p);
+static void __sip_destroy(struct sip_dialog *p, int lockowner);
+static void __sip_ack(struct sip_dialog *p, int seqno, int resp, int sipmethod, int reset);
+static void __sip_pretend_ack(struct sip_dialog *p);
+static int __sip_semi_ack(struct sip_dialog *p, int seqno, int resp, int sipmethod);
 static int auto_congest(void *nothing);
-static int update_call_counter(struct sip_pvt *fup, int event);
+static int update_call_counter(struct sip_dialog *fup, int event);
 static int hangup_sip2cause(int cause);
 static const char *hangup_cause2sip(int cause);
 static void free_old_route(struct sip_route *route);
 static void list_route(struct sip_route *route);
-static void build_route(struct sip_pvt *p, struct sip_request *req, int backwards);
-static enum check_auth_result register_verify(struct sip_pvt *p, struct sockaddr_in *sin,
+static void build_route(struct sip_dialog *p, struct sip_request *req, int backwards);
+static enum check_auth_result register_verify(struct sip_dialog *p, struct sockaddr_in *sin,
 					      struct sip_request *req, char *uri);
-static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *totag, const char *fromtag);
-static void check_pendings(struct sip_pvt *p);
+static struct sip_dialog *get_sip_dialog_byid_locked(const char *callid, const char *totag, const char *fromtag);
+static void check_pendings(struct sip_dialog *p);
 static void *sip_park_thread(void *stuff);
 static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct sip_request *req, int seqno);
-static int sip_sipredirect(struct sip_pvt *p, const char *dest);
+static int sip_sipredirect(struct sip_dialog *p, const char *dest);
 
 /*--- Codec handling / SDP */
-static void try_suggested_sip_codec(struct sip_pvt *p);
+static void try_suggested_sip_codec(struct sip_dialog *p);
 
 /*--- Authentication stuff */
 static int clear_realm_authentication(struct sip_auth *authlist);	/* Clear realm authentication list (at reload) */
-static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_request *req,
+static enum check_auth_result check_user_full(struct sip_dialog *p, struct sip_request *req,
 					      int sipmethod, char *uri, enum xmittype reliable,
 					      struct sockaddr_in *sin, struct sip_peer **authpeer);
-static int check_user(struct sip_pvt *p, struct sip_request *req, int sipmethod, char *uri, enum xmittype reliable, struct sockaddr_in *sin);
+static int check_user(struct sip_dialog *p, struct sip_request *req, int sipmethod, char *uri, enum xmittype reliable, struct sockaddr_in *sin);
 
 /*--- Misc functions */
 static int sip_do_reload(enum channelreloadreason reason);
-static int sip_sipredirect(struct sip_pvt *p, const char *dest);
+static int sip_sipredirect(struct sip_dialog *p, const char *dest);
 static void *do_monitor(void *data);
 static int restart_monitor(void);
 static int sip_send_mwi_to_peer(struct sip_peer *peer);
-static void sip_destroy(struct sip_pvt *p);
+static void sip_destroy(struct sip_dialog *p);
 static int sip_addrcmp(char *name, struct sockaddr_in *sin);	/* Support for peer matching */
-static int sip_refer_allocate(struct sip_pvt *p);
+static int sip_refer_allocate(struct sip_dialog *p);
 static void ast_quiet_chan(struct ast_channel *chan);
 static int attempt_transfer(struct sip_dual *transferer, struct sip_dual *target);
-static void do_setnat(struct sip_pvt *p, int natflags);
+static void do_setnat(struct sip_dialog *p, int natflags);
 
 /*--- Device monitoring and Device/extension state handling */
 static int cb_extensionstate(char *context, char* exten, int state, void *data);
@@ -381,86 +399,50 @@
 static void sip_poke_all_peers(void);
 
 /*--- Applications, functions, CLI and manager command helpers */
-static const char *sip_nat_mode(const struct sip_pvt *p);
-static int sip_show_inuse(int fd, int argc, char *argv[]);
-static char *transfermode2str(enum transfermodes mode) attribute_const;
-static char *nat2str(int nat) attribute_const;
-static int peer_status(struct sip_peer *peer, char *status, int statuslen);
-static int sip_show_users(int fd, int argc, char *argv[]);
-static int _sip_show_peers(int fd, int *total, struct mansession *s, struct message *m, int argc, char *argv[]);
-static int manager_sip_show_peers( struct mansession *s, struct message *m );
-static int sip_show_peers(int fd, int argc, char *argv[]);
-static int sip_show_objects(int fd, int argc, char *argv[]);
-static void  print_group(int fd, ast_group_t group, int crlf);
-static const char *dtmfmode2str(int mode) attribute_const;
-static const char *insecure2str(int port, int invite) attribute_const;
-static void print_codec_to_cli(int fd, struct ast_codec_pref *pref);
-static int _sip_show_peer(int type, int fd, struct mansession *s, struct message *m, int argc, char *argv[]);
-static int manager_sip_show_peer( struct mansession *s, struct message *m);
-static int sip_show_peer(int fd, int argc, char *argv[]);
-static int _sip_show_peer(int type, int fd, struct mansession *s, struct message *m, int argc, char *argv[]);
-static int sip_show_user(int fd, int argc, char *argv[]);
-static int sip_show_registry(int fd, int argc, char *argv[]);
-static int sip_show_settings(int fd, int argc, char *argv[]);
-static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions);
-static int sip_show_channels(int fd, int argc, char *argv[]);
-static int sip_show_subscriptions(int fd, int argc, char *argv[]);
-static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions);
-static char *complete_sipch(const char *line, const char *word, int pos, int state);
-static char *complete_sip_peer(const char *word, int state, int flags2);
-static char *complete_sip_show_peer(const char *line, const char *word, int pos, int state);
-static char *complete_sip_debug_peer(const char *line, const char *word, int pos, int state);
-static char *complete_sip_user(const char *word, int state, int flags2);
-static char *complete_sip_show_user(const char *line, const char *word, int pos, int state);
-static char *complete_sipnotify(const char *line, const char *word, int pos, int state);
-static char *complete_sip_prune_realtime_peer(const char *line, const char *word, int pos, int state);
-static char *complete_sip_prune_realtime_user(const char *line, const char *word, int pos, int state);
-static int sip_show_channel(int fd, int argc, char *argv[]);
-static int sip_show_history(int fd, int argc, char *argv[]);
-static int sip_do_debug_ip(int fd, int argc, char *argv[]);
-static int sip_do_debug_peer(int fd, int argc, char *argv[]);
-static int sip_do_debug(int fd, int argc, char *argv[]);
-static int sip_no_debug(int fd, int argc, char *argv[]);
-static int sip_notify(int fd, int argc, char *argv[]);
-static int sip_do_history(int fd, int argc, char *argv[]);
-static int sip_no_history(int fd, int argc, char *argv[]);
+//static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions);
+//static int sip_show_channels(int fd, int argc, char *argv[]);
+//static int sip_show_subscriptions(int fd, int argc, char *argv[]);
+//static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions);
+//static int sip_show_channel(int fd, int argc, char *argv[]);
+//static int sip_show_history(int fd, int argc, char *argv[]);
+//static int sip_do_debug_ip(int fd, int argc, char *argv[]);
+//static int sip_do_debug_peer(int fd, int argc, char *argv[]);
+//static int sip_do_debug(int fd, int argc, char *argv[]);
+//static int sip_no_debug(int fd, int argc, char *argv[]);
+GNURK int sip_notify(int fd, int argc, char *argv[]);
+//static int sip_do_history(int fd, int argc, char *argv[]);
+//static int sip_no_history(int fd, int argc, char *argv[]);
 static int func_header_read(struct ast_channel *chan, char *function, char *data, char *buf, size_t len);
 static int function_sippeer(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len);
 static int function_sipchaninfo_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len);
 static int sip_dtmfmode(struct ast_channel *chan, void *data);
 static int sip_addheader(struct ast_channel *chan, void *data);
 static int sip_do_reload(enum channelreloadreason reason);
-static int sip_reload(int fd, int argc, char *argv[]);
 
 /*--- Debugging 
 	Functions for enabling debug per IP or fully, or enabling history logging for
 	a SIP dialog
 */
-static void sip_dump_history(struct sip_pvt *dialog);	/* Dump history to LOG_DEBUG at end of dialog, before destroying data */
-static inline int sip_debug_test_addr(const struct sockaddr_in *addr);
-static inline int sip_debug_test_pvt(struct sip_pvt *p);
-static void sip_dump_history(struct sip_pvt *dialog);
+static void sip_dump_history(struct sip_dialog *dialog);	/* Dump history to LOG_DEBUG at end of dialog, before destroying data */
+static inline int sip_debug_test_pvt(struct sip_dialog *p);
+static void sip_dump_history(struct sip_dialog *dialog);
 
 /*--- Device object handling */
 static struct sip_peer *temp_peer(const char *name);
-static int update_call_counter(struct sip_pvt *fup, int event);
+static int update_call_counter(struct sip_dialog *fup, int event);
 static int sip_poke_peer(struct sip_peer *peer);
 static struct sip_peer *temp_peer(const char *name);
 static void register_peer_exten(struct sip_peer *peer, int onoff);
-static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int realtime);
-static struct sip_peer *find_user(const char *name, int realtime);
 static int sip_poke_peer_s(void *data);
-static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_request *req);
+static enum parse_register_result parse_register_contact(struct sip_dialog *pvt, struct sip_peer *p, struct sip_request *req);
 
 /* Realtime device support */
 static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey);
 static void update_peer(struct sip_peer *p, int expiry);
-static int sip_prune_realtime(int fd, int argc, char *argv[]);
 
 /*--- Internal UA client handling (outbound registrations) */
 static int ast_sip_ouraddrfor(struct in_addr *them, struct in_addr *us);
 static void sip_registry_destroy(struct sip_registry *reg);
-static char *regstate2str(enum sipregistrystate regstate) attribute_const;
 static int sip_reregister(void *data);
 static int __sip_do_register(struct sip_registry *r);
 static int sip_reg_timeout(void *data);
@@ -470,36 +452,33 @@
 static void append_date(struct sip_request *req);	/* Append date to SIP packet */
 static int determine_firstline_parts(struct sip_request *req);
 static const char *gettag(const struct sip_request *req, const char *header, char *tagbuf, int tagbufsize);
-static void parse_request(struct sip_request *req);
 static char *get_in_brackets(char *tmp);
 static const char *find_alias(const char *name, const char *_default);
 static const char *__get_header(const struct sip_request *req, const char *name, int *start);
-static void extract_uri(struct sip_pvt *p, struct sip_request *req);
-static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoing_req);
-static int get_also_info(struct sip_pvt *p, struct sip_request *oreq);
-static int parse_ok_contact(struct sip_pvt *pvt, struct sip_request *req);
-static int set_address_from_contact(struct sip_pvt *pvt);
-static void check_via(struct sip_pvt *p, struct sip_request *req);
-static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq);
-static int get_destination(struct sip_pvt *p, struct sip_request *oreq);
+static void extract_uri(struct sip_dialog *p, struct sip_request *req);
+static int get_refer_info(struct sip_dialog *transferer, struct sip_request *outgoing_req);
+static int get_also_info(struct sip_dialog *p, struct sip_request *oreq);
+static int parse_ok_contact(struct sip_dialog *pvt, struct sip_request *req);
+static int set_address_from_contact(struct sip_dialog *pvt);
+static void check_via(struct sip_dialog *p, struct sip_request *req);
+static int get_rdnis(struct sip_dialog *p, struct sip_request *oreq);
+static int get_destination(struct sip_dialog *p, struct sip_request *oreq);
 static int get_msg_text(char *buf, int len, struct sip_request *req);
 static const char *gettag(const struct sip_request *req, const char *header, char *tagbuf, int tagbufsize);
 static void free_old_route(struct sip_route *route);
-GNURK void parse_copy(struct sip_request *dst, const struct sip_request *src);
 
 /*--- Constructing requests and responses */
-static void initialize_initreq(struct sip_pvt *p, struct sip_request *req);
+static void initialize_initreq(struct sip_dialog *p, struct sip_request *req);
 static int init_req(struct sip_request *req, int sipmethod, const char *recip);
-static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, int seqno, int newbranch);
-static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod);
+static int reqprep(struct sip_request *req, struct sip_dialog *p, int sipmethod, int seqno, int newbranch);
+static void initreqprep(struct sip_request *req, struct sip_dialog *p, int sipmethod);
 static int init_resp(struct sip_request *resp, const char *msg);
-static int respprep(struct sip_request *resp, struct sip_pvt *p, const char *msg, const struct sip_request *req);
-static const struct sockaddr_in *sip_real_dst(const struct sip_pvt *p);
-static void build_via(struct sip_pvt *p);
-static int create_addr_from_peer(struct sip_pvt *r, struct sip_peer *peer);
-static int create_addr(struct sip_pvt *dialog, const char *opeer);
+static int respprep(struct sip_request *resp, struct sip_dialog *p, const char *msg, const struct sip_request *req);
+static void build_via(struct sip_dialog *p);
+static int create_addr_from_peer(struct sip_dialog *r, struct sip_peer *peer);
+static int create_addr(struct sip_dialog *dialog, const char *opeer);
 static char *generate_random_string(char *buf, size_t size);
-static void build_callid_pvt(struct sip_pvt *pvt);
+static void build_callid_pvt(struct sip_dialog *pvt);
 static void build_callid_registry(struct sip_registry *reg, struct in_addr ourip, const char *fromdomain);
 static void make_our_tag(char *tagbuf, size_t len);
 static int add_text(struct sip_request *req, const char *text);
@@ -508,43 +487,43 @@
 static void add_route(struct sip_request *req, struct sip_route *route);
 static int copy_header(struct sip_request *req, const struct sip_request *orig, const char *field);
 static int copy_all_header(struct sip_request *req, const struct sip_request *orig, const char *field);
-static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, const struct sip_request *orig, const char *field);
-static void set_destination(struct sip_pvt *p, char *uri);
+static int copy_via_headers(struct sip_dialog *p, struct sip_request *req, const struct sip_request *orig, const char *field);
+static void set_destination(struct sip_dialog *p, char *uri);
 static void append_date(struct sip_request *req);
-static void build_contact(struct sip_pvt *p);
-static void build_rpid(struct sip_pvt *p);
+static void build_contact(struct sip_dialog *p);
+static void build_rpid(struct sip_dialog *p);
 
 /*------Request handling functions */
-static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int debug, int seqno, struct sockaddr_in *sin, int *recount, char *e);
-static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int debug, int seqno, int *nounlock);
-static int handle_request_bye(struct sip_pvt *p, struct sip_request *req);
-static int handle_request_register(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, char *e);
-static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req);
-static int handle_request_message(struct sip_pvt *p, struct sip_request *req);
-static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int seqno, char *e);
-static void handle_request_info(struct sip_pvt *p, struct sip_request *req);
-static int handle_request_options(struct sip_pvt *p, struct sip_request *req);
-static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, int debug, int ignore, int seqno, struct sockaddr_in *sin);
-static int handle_request_notify(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int seqno, char *e);
-static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, int debug, int ignore, int seqno, struct sockaddr_in *sin);
-static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *current, struct sip_request *req, int seqno);
+static int handle_request_invite(struct sip_dialog *p, struct sip_request *req, int debug, int seqno, struct sockaddr_in *sin, int *recount, char *e);
+static int handle_request_refer(struct sip_dialog *p, struct sip_request *req, int debug, int seqno, int *nounlock);
+static int handle_request_bye(struct sip_dialog *p, struct sip_request *req);
+static int handle_request_register(struct sip_dialog *p, struct sip_request *req, struct sockaddr_in *sin, char *e);
+static int handle_request_cancel(struct sip_dialog *p, struct sip_request *req);
+static int handle_request_message(struct sip_dialog *p, struct sip_request *req);
+static int handle_request_subscribe(struct sip_dialog *p, struct sip_request *req, struct sockaddr_in *sin, int seqno, char *e);
+static void handle_request_info(struct sip_dialog *p, struct sip_request *req);
+static int handle_request_options(struct sip_dialog *p, struct sip_request *req);
+static int handle_invite_replaces(struct sip_dialog *p, struct sip_request *req, int debug, int ignore, int seqno, struct sockaddr_in *sin);
+static int handle_request_notify(struct sip_dialog *p, struct sip_request *req, struct sockaddr_in *sin, int seqno, char *e);
+static int handle_invite_replaces(struct sip_dialog *p, struct sip_request *req, int debug, int ignore, int seqno, struct sockaddr_in *sin);
+static int local_attended_transfer(struct sip_dialog *transferer, struct sip_dual *current, struct sip_request *req, int seqno);
 
 /*------Response handling functions */
-static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
-static void handle_response_refer(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
-static void handle_response_peerpoke(struct sip_pvt *p, int resp, struct sip_request *req);
-static int handle_response_register(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
-static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
+static void handle_response_invite(struct sip_dialog *p, int resp, char *rest, struct sip_request *req, int seqno);
+static void handle_response_refer(struct sip_dialog *p, int resp, char *rest, struct sip_request *req, int seqno);
+static void handle_response_peerpoke(struct sip_dialog *p, int resp, struct sip_request *req);
+static int handle_response_register(struct sip_dialog *p, int resp, char *rest, struct sip_request *req, int seqno);
+static void handle_response(struct sip_dialog *p, int resp, char *rest, struct sip_request *req, int seqno);
 
 /*----- RTP interface functions */
 static int sip_get_codec(struct ast_channel *chan);
-static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p, int *faxdetect);
-static void stop_media_flows(struct sip_pvt *p);
+static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_dialog *p, int *faxdetect);
+static void stop_media_flows(struct sip_dialog *p);
 
 /*------ T38 Support --------- */
-static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_pvt *pvt, int reinvite); /*!< T38 negotiation helper function */
-static int transmit_response_with_t38_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans);
-static int transmit_reinvite_with_t38_sdp(struct sip_pvt *p);
+static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_dialog *pvt, int reinvite); /*!< T38 negotiation helper function */
+static int transmit_response_with_t38_sdp(struct sip_dialog *p, char *msg, struct sip_request *req, int retrans);
+static int transmit_reinvite_with_t38_sdp(struct sip_dialog *p);
 static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan);
 static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl);
 
@@ -592,7 +571,7 @@
 /*! \brief Initialize the initital request packet in the pvt structure.
  	This packet is used for creating replies and future requests in
 	a dialog */
-static void initialize_initreq(struct sip_pvt *p, struct sip_request *req)
+static void initialize_initreq(struct sip_dialog *p, struct sip_request *req)
 {
 	if (p->initreq.headers && option_debug) {
 		ast_log(LOG_DEBUG, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
@@ -605,7 +584,7 @@
 }
 
 /*! \brief See if we pass debug IP filter */
-static inline int sip_debug_test_addr(const struct sockaddr_in *addr) 
+GNURK inline int sip_debug_test_addr(const struct sockaddr_in *addr) 
 {
 	if (!sipdebug)
 		return 0;
@@ -619,19 +598,13 @@
 }
 
 /*! \brief The real destination address for a write */
-static const struct sockaddr_in *sip_real_dst(const struct sip_pvt *p)
+GNURK const struct sockaddr_in *sip_real_dst(const struct sip_dialog *p)
 {
 	return ast_test_flag(&p->flags[0], SIP_NAT) & SIP_NAT_ROUTE ? &p->recv : &p->sa;
 }
 
-/*! \brief Display SIP nat mode */
-static const char *sip_nat_mode(const struct sip_pvt *p)
-{
-	return ast_test_flag(&p->flags[0], SIP_NAT) & SIP_NAT_ROUTE ? "NAT" : "no NAT";
-}
-
 /*! \brief Test PVT for debugging output */
-inline int sip_debug_test_pvt(struct sip_pvt *p) 
+inline int sip_debug_test_pvt(struct sip_dialog *p) 
 {
 	if (!sipdebug)
 		return 0;
@@ -639,7 +612,7 @@
 }
 
 /*! \brief Build a Via header for a request */
-static void build_via(struct sip_pvt *p)
+static void build_via(struct sip_dialog *p)
 {
 	/* Work around buggy UNIDEN UIP200 firmware */
 	const char *rport = ast_test_flag(&p->flags[0], SIP_NAT) & SIP_NAT_RFC3581 ? ";rport" : "";
@@ -687,11 +660,11 @@
 	return AST_SUCCESS;
 }
 
-GNURK void append_history_full(struct sip_pvt *p, const char *fmt, ...)
+GNURK void append_history_full(struct sip_dialog *p, const char *fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
 
 /*! \brief Append to SIP dialog history with arg list  */
-GNURK void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
+GNURK void append_history_va(struct sip_dialog *p, const char *fmt, va_list ap)
 {
 	char buf[80], *c = buf; /* max history length */
 	struct sip_history *hist;
@@ -711,7 +684,7 @@
 }
 
 /*! \brief Append to SIP dialog history with arg list  */
-GNURK void append_history_full(struct sip_pvt *p, const char *fmt, ...)
+GNURK void append_history_full(struct sip_dialog *p, const char *fmt, ...)
 {
 	va_list ap;
 
@@ -727,7 +700,7 @@
 /*! \brief Kill a SIP dialog (called by scheduler) */
 static int __sip_autodestruct(void *data)
 {
-	struct sip_pvt *p = data;
+	struct sip_dialog *p = data;
 
 	/* If this is a subscription, tell the phone that we got a timeout */
 	if (p->subscribed) {
@@ -757,7 +730,7 @@
 }
 
 /*! \brief Schedule destruction of SIP dialog */
-static void sip_scheddestroy(struct sip_pvt *p, int ms)
+GNURK void sip_scheddestroy(struct sip_dialog *p, int ms)
 {
 	if (ms < 0) {
 		if (p->timer_t1 == 0)
@@ -775,7 +748,7 @@
 }
 
 /*! \brief Cancel destruction of SIP dialog */
-static void sip_cancel_destroy(struct sip_pvt *p)
+static void sip_cancel_destroy(struct sip_dialog *p)
 {
 	if (p->autokillid > -1) {
 		ast_sched_del(sched, p->autokillid);
@@ -785,7 +758,7 @@
 }
 
 /*! \brief Acknowledges receipt of a packet and stops retransmission */
-static void __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod, int reset)
+static void __sip_ack(struct sip_dialog *p, int seqno, int resp, int sipmethod, int reset)
 {
 	struct sip_pkt *cur, *prev = NULL;
 
@@ -825,7 +798,7 @@
 
 /*! \brief Pretend to ack all packets
  * maybe the lock on p is not strictly necessary but there might be a race */
-static void __sip_pretend_ack(struct sip_pvt *p)
+static void __sip_pretend_ack(struct sip_dialog *p)
 {
 	struct sip_pkt *cur = NULL;
 
@@ -842,7 +815,7 @@
 }
 
 /*! \brief Acks receipt of packet, keep it around (used for provisional responses) */
-static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
+static int __sip_semi_ack(struct sip_dialog *p, int seqno, int resp, int sipmethod)
 {
 	struct sip_pkt *cur;
 	int res = -1;
@@ -951,7 +924,7 @@
 	Called from PBX core sendtext() application */
 static int sip_sendtext(struct ast_channel *ast, const char *text)
 {
-	struct sip_pvt *p = ast->tech_pvt;
+	struct sip_dialog *p = ast->tech_pvt;
 	int debug = sip_debug_test_pvt(p);
 
 	if (debug)
@@ -1103,14 +1076,14 @@
 /*! \brief Locate peer by name or ip address 
  *	This is used on incoming SIP message to find matching peer on ip
 	or outgoing message to find matching peer on name */
-static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int realtime)
+GNURK struct sip_peer *find_device(const char *peer, struct sockaddr_in *sin, int realtime)
 {
 	struct sip_peer *p = NULL;
 
 	if (peer)
-		p = ASTOBJ_CONTAINER_FIND(&peerl, peer);
+		p = ASTOBJ_CONTAINER_FIND(&devicelist, peer);
 	else
-		p = ASTOBJ_CONTAINER_FIND_FULL(&peerl, sin, name, sip_addr_hashfunc, 1, sip_addrcmp);
+		p = ASTOBJ_CONTAINER_FIND_FULL(&devicelist, sin, name, sip_addr_hashfunc, 1, sip_addrcmp);
 
 	if (!p && realtime)
 		p = realtime_peer(peer, sin);
@@ -1118,20 +1091,8 @@
 	return p;
 }
 
-/*! \brief Locate user by name 
- * Locates user by name (From: sip uri user name part) first
- * from in-memory list (static configuration) then from 
- * realtime storage (defined in extconfig.conf) */
-static struct sip_peer *find_user(const char *name, int realtime)
-{
-	struct sip_peer *u = ASTOBJ_CONTAINER_FIND(&userl,name);
-	if (!u && realtime)
-		u = realtime_user(name);
-	return u;
-}
-
 /*! \brief Set nat mode on the various data sockets */
-static void do_setnat(struct sip_pvt *p, int natflags)
+static void do_setnat(struct sip_dialog *p, int natflags)
 {
 	const char *mode = natflags ? "On" : "Off";
 
@@ -1155,7 +1116,7 @@
 /*! \brief Create address structure from peer reference.
  *  return -1 on error, 0 on success.
  */
-static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
+static int create_addr_from_peer(struct sip_dialog *dialog, struct sip_peer *peer)
 {
 	if ((peer->addr.sin_addr.s_addr || peer->defaddr.sin_addr.s_addr) &&
 	    (!peer->maxms || ((peer->lastms >= 0)  && (peer->lastms <= peer->maxms)))) {
@@ -1256,7 +1217,7 @@
 /*! \brief create address structure from peer name
  *      Or, if peer not found, find it in the global DNS 
  *      returns TRUE (-1) on failure, FALSE on success */
-static int create_addr(struct sip_pvt *dialog, const char *opeer)
+static int create_addr(struct sip_dialog *dialog, const char *opeer)
 {
 	struct hostent *hp;
 	struct ast_hostent ahp;
@@ -1272,7 +1233,7 @@
 		*port++ = '\0';
 	dialog->sa.sin_family = AF_INET;
 	dialog->timer_t1 = 500; /* Default SIP retransmission timer T1 (RFC 3261) */
-	p = find_peer(peer, NULL, 1);
+	p = find_device(peer, NULL, 1);
 
 	if (p) {
 		int res = create_addr_from_peer(dialog, p);
@@ -1322,7 +1283,7 @@
 /*! \brief Scheduled congestion on a call */
 static int auto_congest(void *nothing)
 {
-	struct sip_pvt *p = nothing;
+	struct sip_dialog *p = nothing;
 
 	ast_mutex_lock(&p->lock);
 	p->initid = -1;
@@ -1345,7 +1306,7 @@

[... 5261 lines stripped ...]


More information about the svn-commits mailing list