chan_sip: Isolate code that manages struct sip_route.

* Move route code to sip/route.c + sip/include/route.h
* Rename functions to sip_route_*
* Replace ad-hoc list code with macro's from linkedlists.h
* Create sip_route_process_header() to processes Path and Record-Route headers
  (previously done with different code in build_route and build_path)
* Add use of const where possible
* Move struct uriparams, struct contact and contactliststruct from sip.h to
  reqresp_parser.h.  sip/route.c uses reqresp_parser.h but not sip.h, this was
  a problem.  These moved declares are not used outside of reqresp_parser.
* While modifying reqprep() the lack of {} caused me trouble.  I added them.
* Code outside route.c treats sip_route as an opaque structure, using macro's
  or procedures for all access.

(closes issue ASTERISK-22582)
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/3173/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407926 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Corey Farrell
2014-02-10 18:28:35 +00:00
parent 72bf9b1315
commit cb4e210773
5 changed files with 448 additions and 351 deletions

View File

@@ -39,6 +39,8 @@
#include "asterisk/netsock2.h"
#include "asterisk/features_config.h"
#include "route.h"
#ifndef FALSE
#define FALSE 0
#endif
@@ -847,12 +849,6 @@ struct sip_invite_param {
struct sip_proxy *outboundproxy; /*!< Outbound proxy URI */
};
/*! \brief Structure to save routing information for a SIP session */
struct sip_route {
struct sip_route *next;
char hop[0];
};
/*! \brief Structure to store Via information */
struct sip_via {
char *via;
@@ -1119,7 +1115,7 @@ struct sip_pvt {
struct ast_sockaddr ourip; /*!< Our IP (as seen from the outside) */
enum transfermodes allowtransfer; /*!< REFER: restriction scheme */
struct ast_channel *owner; /*!< Who owns us (if we have an owner) */
struct sip_route *route; /*!< Head of linked list of routing steps (fm Record-Route) */
struct sip_route route; /*!< List of routing steps (fm Record-Route) */
struct sip_notify *notify; /*!< Custom notify type */
struct sip_auth_container *peerauth;/*!< Realm authentication credentials */
int noncecount; /*!< Nonce-count */
@@ -1346,7 +1342,7 @@ struct sip_peer {
int timer_t1; /*!< The maximum T1 value for the peer */
int timer_b; /*!< The maximum timer B (transaction timeouts) */
int fromdomainport; /*!< The From: domain port */
struct sip_route *path; /*!< Head of linked list of out-of-dialog outgoing routing steps (fm Path headers) */
struct sip_route path; /*!< List of out-of-dialog outgoing routing steps (fm Path headers) */
/*XXX Seems like we suddenly have two flags with the same content. Why? To be continued... */
enum sip_peer_type type; /*!< Distinguish between "user" and "peer" types. This is used solely for CLI and manager commands */
@@ -1804,34 +1800,6 @@ struct sip_monitor_instance {
struct sip_epa_entry *suspension_entry;
};
/*!
* \brief uri parameters
*
*/
struct uriparams {
char *transport;
char *user;
char *method;
char *ttl;
char *maddr;
int lr;
};
struct contact {
AST_LIST_ENTRY(contact) list;
char *name;
char *user;
char *pass;
char *hostport;
struct uriparams params;
char *headers;
char *expires;
char *q;
};
AST_LIST_HEAD_NOLOCK(contactliststruct, contact);
/*! \brief List of well-known SIP options. If we get this in a require,
we should check the list and answer accordingly. */
static const struct cfsip_options {