Codename Pineapple

Home page | Mailing list | Docs

Last updated: Sat Feb 3 05:01:54 2007

Asterisk developer's documentation :: Codename Pineapple


sip3funcs.h File Reference


Detailed Description

Definitions of functions in the sip3 library files used by chan_sip3.c.

Version 3 of chan_sip

Author:
Mark Spencer <markster@digium.com>

Olle E. Johansson <oej@edvina.net> (all the chan_sip3 changes)

See Also:

Definition in file sip3funcs.h.

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define GNURK

Functions

GNURK const char * __get_header (struct sip_request *req, const char *name, int *start)
GNURK void __sip_ack (struct sip_dialog *dialog, int seqno, int resp, int sipmethod, int reset)
 For a reliable transmission, we need to get an reply to stop retransmission. Acknowledges receipt of a packet and stops retransmission.
GNURK void __sip_destroy (struct sip_dialog *p, int lockowner, int lockdialoglist)
 Execute destruction of SIP dialog structure, release memory.
GNURK void __sip_pretend_ack (struct sip_dialog *p)
 Pretend to ack all packets - nothing to do with SIP_ACK (the method) maybe the lock on p is not strictly necessary but there might be a race.
GNURK int __sip_semi_ack (struct sip_dialog *p, int seqno, int resp, int sipmethod)
 Acks receipt of packet, keep it around (used for provisional responses).
GNURK int __transmit_response (struct sip_dialog *p, const char *msg, struct sip_request *req, enum xmittype reliable)
 Base transmit response function.
GNURK void add_blank (struct sip_request *req)
 add a blank line if no body
GNURK int add_digit (struct sip_request *req, char digit, unsigned int duration)
 Add DTMF INFO tone to sip message.
GNURK int add_header (struct sip_request *req, const char *var, const char *value)
 Add header to SIP message.
GNURK int add_header_contentLength (struct sip_request *req, int len)
 Add 'Content-Length' header to SIP message.
GNURK int add_line (struct sip_request *req, const char *line)
 Add content (not header) to SIP message.
GNURK struct sip_authadd_realm_authentication (struct sip_auth *authlist, char *configuration, int lineno)
 Add realm authentication in list.
GNURK void add_route (struct sip_request *req, struct sip_route *route)
 Add route header into request per learned route.
GNURK int add_sdp (struct sip_request *resp, struct sip_dialog *p)
 Add Session Description Protocol message.
GNURK int add_sip_domain (const char *domain, const enum domain_mode mode, const char *context)
 Add SIP domain to list of domains we are responsible for.
GNURK int add_t38_sdp (struct sip_request *resp, struct sip_dialog *p)
 Add T.38 Session Description Protocol message.
GNURK int add_text (struct sip_request *req, const char *text)
 Add text body to SIP message.
GNURK void append_date (struct sip_request *req)
 Append date to SIP message.
GNURK void append_history_full (struct sip_dialog *p, const char *fmt,...)
 Append to SIP dialog history with arg list.
GNURK void append_history_va (struct sip_dialog *p, const char *fmt, va_list ap)
 Append to SIP dialog history with arg list.
GNURK void append_maxforwards (struct sip_request *req)
 Append Max-Forwards header to request.
GNURK void ast_quiet_chan (struct ast_channel *chan)
 Turn off generator data XXX Does this function belong in the SIP channel?
GNURK void auth_headers (enum sip_auth_type code, char **header, char **respheader)
 return the request and response heade for a 401 or 407 code
GNURK void build_callid_pvt (struct sip_dialog *pvt)
 Build SIP Call-ID value for a non-REGISTER transaction.
GNURK void build_contact (struct sip_dialog *p)
 Build contact header - the contact header we send out.
GNURK int build_reply_digest (struct sip_dialog *p, int method, char *digest, int digest_len)
 Build reply digest.
GNURK void build_rpid (struct sip_dialog *p)
 Build the Remote Party-ID & From using callingpres options.
GNURK void build_via (struct sip_dialog *p, int forcenewbranch)
 Build a Via header for a request.
GNURK enum check_auth_result check_auth (struct sip_dialog *p, struct sip_request *req, const char *username, const char *secret, const char *md5secret, int sipmethod, char *uri, enum xmittype reliable, int ignore)
 Check user authorization from peer definition Some actions, like REGISTER and INVITEs from peers require authentication (if peer have secret set).
GNURK int check_sip_domain (const char *domain, char *context, size_t len)
 check_sip_domain: Check if domain part of uri is local to our server
GNURK int clear_realm_authentication (struct sip_auth *authlist)
 Clear realm authentication list (at reload).
GNURK void clear_sip_domains (void)
 Clear our domain list (at reload).
GNURK int close_sip_sockets (void)
 Close all open network sockets.
GNURK char * complete_sip_device (const char *word, int state, int flags2)
 Do completion on peer name.
GNURK char * complete_sip_show_device (const char *line, const char *word, int pos, int state)
 Support routine for 'sip show peer' CLI.
GNURK int copy_all_header (struct sip_request *req, struct sip_request *orig, const char *field)
 Copy all headers from one request to another.
GNURK int copy_header (struct sip_request *req, struct sip_request *orig, const char *field)
 Copy one header field from one request to another.
GNURK void copy_request (struct sip_request *dst, const struct sip_request *src)
 copy SIP request (mostly used to save request for responses)
GNURK int copy_via_headers (struct sip_dialog *p, struct sip_request *req, struct sip_request *orig, const char *field)
 Copy SIP VIA Headers from the request to the response.
GNURK int create_addr (struct sip_dialog *dialog, const char *username, char *domain, const char *device)
 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
GNURK void destroy_association (struct sip_device *peer)
 Remove registration data from realtime database or AST/DB when registration expires.
GNURK int determine_firstline_parts (struct sip_request *req)
 Parse first line of incoming SIP request.
GNURK struct sip_devicedevice_ref (struct sip_device *device)
 Add reference for device.
GNURK int device_status (struct sip_device *peer, char *status, int statuslen)
 Report Device status in character string.
GNURK void device_unref (struct sip_device *device)
 Remove reference for device. When we reach 0, device is removed from memory.
GNURK void dialog_lock (struct sip_dialog *dialog, int state)
 Helper function to lock and unlock, hiding the underlying locking mechanism.
GNURK void dialoglist_lock (void)
 Lock list of active SIP dialogs.
GNURK void dialoglist_unlock (void)
 Unlock list of active SIP dialogs.
GNURK const char * dialogstate2str (const enum dialogstate state)
 Convert SIP dialog states to string.
GNURK void dialogstatechange (struct sip_dialog *dialog, enum dialogstate newstate)
 Change dialog state for a SIP dialog and output to debug.
GNURK int do_proxy_auth (struct sip_dialog *p, struct sip_request *req, enum sip_auth_type code, int sipmethod, int init)
 Add authentication on outbound SIP packet.
GNURK int do_register_auth (struct sip_dialog *p, struct sip_request *req, enum sip_auth_type code)
 Authenticate for outbound registration.
GNURK void do_setnat (struct sip_dialog *p, int natflags)
 Set nat mode on the various media streams.
void * do_sip_monitor (void *data)
 The SIP monitoring thread.
GNURK const char * domain_mode_to_text (const enum domain_mode mode)
 Print domain mode to cli.
GNURK int domains_configured (void)
 return TRUE if any domains are configured for this server
GNURK int expire_register (void *data)
 Expire registration of SIP peer.
GNURK void extract_uri (struct sip_dialog *p, struct sip_request *req)
 Check Contact: URI of SIP message.
GNURK const char * find_alias (const char *name, const char *_default)
 Find compressed SIP alias Structure for conversion between compressed SIP and "normal" SIP.
GNURK struct sip_devicefind_device (const char *peer, struct sockaddr_in *sin, int realtime)
 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.
GNURK struct sip_authfind_realm_authentication (struct sip_auth *authlist, const char *realm)
 Find authentication for a specific realm.
GNURK int find_sdp (struct sip_request *req)
 Determine whether a SIP message contains an SDP in its body.
GNURK int find_sip_method (const char *msg)
 find_sip_method: Find SIP method from header
GNURK const struct cfsubscription_typesfind_subscription_type (enum subscriptiontype subtype)
 Find subscription type in array.
GNURK void find_via_branch (struct sip_request *req, char *viabuf, size_t vialen)
 Find via branch parameter.
GNURK void free_old_route (struct sip_route *route)
 Remove route from route list.
GNURK int func_check_sipdomain (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 Dial plan function to check if domain is local.
GNURK char * generate_random_string (char *buf, size_t size)
 Generate 32 byte random string for callid's etc.
GNURK char * get_body (struct sip_request *req, char *name)
 Get the message body part identified by name=.
GNURK char * get_calleridname (const char *input, char *output, size_t outputsize)
 Get caller id name from SIP headers.
GNURK int get_destination (struct sip_dialog *p, struct sip_request *oreq)
 Find out who the call is for We use the INVITE request uri to find out Runs a dialplan lookup.
GNURK const char * get_header (struct sip_request *req, const char *name)
 Get header from SIP request.
GNURK char * get_in_brackets (char *tmp)
 Pick out text in brackets from character string.
GNURK int get_rdnis (struct sip_dialog *p, struct sip_request *oreq)
 Get referring dnis.
GNURK int get_rpid_num (const char *input, char *output, int maxlen)
 Get caller id number from Remote-Party-ID header field Returns true if number should be restricted (privacy setting found) output is set to NULL if no number found.
GNURK struct sip_dialogget_sip_dialog_byid_locked (const char *callid, const char *totag, const char *fromtag)
 Lock dialog list lock and find matching pvt lock
  • Their tag is fromtag, our tag is to-tag
  • This means that in some transactions, totag needs to be their tag :-) depending upon the direction.

GNURK const char * gettag (const char *header, char *tagbuf, int tagbufsize)
 Get tag from packet.
GNURK int handle_request (struct sip_dialog *p, struct sip_request *req, struct sockaddr_in *sin, int *recount, int *nounlock)
 Handle incoming SIP requests (methods).
GNURK int handle_request_refer (struct sip_dialog *p, struct sip_request *req, int debug, int seqno, int *nounlock)
void handle_response_peerpoke (struct sip_dialog *p, int resp, struct sip_request *req)
 Handle qualification responses (OPTIONS).
GNURK int handle_response_register (struct sip_dialog *p, int resp, char *rest, struct sip_request *req, int seqno)
 Handle responses on REGISTER to services.
GNURK const char * hangup_cause2sip (int cause)
 Convert Asterisk hangup causes to SIP codes.
GNURK int hangup_sip2cause (int cause)
 Convert SIP hangup causes to Asterisk hangup causes.
GNURK int init_req (struct sip_request *req, int sipmethod, const char *recip)
 Initialize SIP request.
GNURK int init_resp (struct sip_request *resp, const char *msg)
 Initialize SIP response, based on SIP request.
GNURK void initialize_initreq (struct sip_dialog *p, struct sip_request *req)
 Initialize the initital request packet in the pvt structure. This packet is used for creating replies and future requests in a dialog.
GNURK void initreqprep (struct sip_request *req, struct sip_dialog *p, int sipmethod)
 Initiate new SIP request to peer/user.
void kill_monitor (void)
 kill monitor thread (only at module unload)
GNURK void logdebug (int level, const char *fmt,...)
 Append to SIP dialog history with arg list.
GNURK int lws2sws (char *msgbuf, int len)
 Parse multiline SIP headers into one header This is enabled if pedanticsipchecking is enabled.
GNURK void make_our_tag (char *tagbuf, size_t len)
 Make our SIP dialog tag.
GNURK int manager_sip_show_device (struct mansession *s, const struct message *m)
 Show SIP peers in the manager API.
GNURK int manager_sip_show_devices (struct mansession *s, const struct message *m)
 Show SIP peers in the manager API.
GNURK struct sip_dialogmatch_or_create_dialog (struct sip_request *req, struct sockaddr_in *sin, const int intended_method)
GNURK int method_match (enum sipmethod id, const char *name)
 returns true if 'name' (with optional trailing whitespace) matches the sip method 'id'. Strictly speaking, SIP methods are case SENSITIVE, but we do a case-insensitive comparison to be more tolerant. following Jon Postel's rule: Be gentle in what you accept, strict with what you send
GNURK void parse_moved_contact (struct sip_dialog *p, struct sip_request *req)
 Parse 302 Moved temporalily response.
GNURK void parse_request (struct sip_request *req)
 Parse a SIP message.
GNURK unsigned int parse_sip_options (struct sip_dialog *pvt, const char *supported)
 Parse supported header in incoming packet.
GNURK void print_group (int fd, ast_group_t group, int crlf)
 Print call group and pickup group.
GNURK int process_sdp (struct sip_dialog *p, struct sip_request *req)
 Process SIP SDP offer, select formats and activate RTP channels If offer is rejected, we will not change any properties of the call.
GNURK struct sip_devicerealtime_peer (const char *newpeername, struct sockaddr_in *sin)
 realtime_peer: Get peer from realtime storage Checks the "sippeers" realtime family from extconfig.conf
GNURK void realtime_update_peer (const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expiry)
 Update peer object in realtime storage If the Asterisk system name is set in asterisk.conf, we will use that name and store that in the "regserver" field in the sippeers table to facilitate multi-server setups.
GNURK const char * referstatus2str (enum referstatus rstatus) attribute_pure
 Convert transfer status to string.
GNURK void reg_source_db (struct sip_device *peer)
GNURK void register_peer_exten (struct sip_device *device, int onoff)
 Automatically add peer extension to dial plan.
GNURK void register_rtp_and_udptl (void)
 Register RTP and UDPTL to the subsystems.
GNURK char * regstate2str (enum sipregistrystate regstate) attribute_const
 Convert registration state status to string.
GNURK int reload_config (enum channelreloadreason reason)
 Re-read SIP.conf config file.
GNURK void replace_cid (struct sip_dialog *p, const char *rpid_num, const char *calleridname)
 helper function for check_{user|peer}_ok()
GNURK int reply_digest (struct sip_dialog *p, struct sip_request *req, char *header, int sipmethod, char *digest, int digest_len)
 reply to authentication for outbound registrations
GNURK int reqprep (struct sip_request *req, struct sip_dialog *p, int sipmethod, int seqno, int newbranch)
 Initialize a SIP request message (not the initial one in a dialog).
GNURK void reset_ip_interface (struct sip_network *sipsock)
 clear IP interfaces
GNURK int respprep (struct sip_request *resp, struct sip_dialog *p, const char *msg, struct sip_request *req)
 Prepare SIP response packet.
int restart_monitor (void)
 Start the channel monitor thread.
GNURK int send_request (struct sip_dialog *p, struct sip_request *req, enum xmittype reliable)
 Send SIP Request to the other part of the dialogue.
GNURK int send_response (struct sip_dialog *p, struct sip_request *req, enum xmittype reliable)
 Transmit response on SIP request.
GNURK void set_device_defaults (struct sip_device *device)
 Set peer defaults before configuring specific configurations.
GNURK void set_initreq (struct sip_dialog *dialog, struct sip_request *req)
 Set packet to initreq status. Set flag to avoid de-allocation until dialog is destroyed.
GNURK struct sip_dialogsip_alloc (ast_string_field callid, struct sockaddr_in *sin, int useglobal_nat, const int intended_method)
 Allocate SIP_PVT structure and set defaults.
GNURK void sip_cancel_destroy (struct sip_dialog *p)
 Cancel destruction of SIP dialog.
GNURK void sip_cli_and_manager_commands_register (void)
 Register cli and manager commands.
GNURK void sip_cli_and_manager_commands_unregister (void)
 Unregister cli and manager commands.
GNURK int sip_debug_test_addr (const struct sockaddr_in *addr)
 See if we pass debug IP filter.
GNURK int sip_debug_test_pvt (struct sip_dialog *p)
 Test PVT for debugging output.
GNURK void sip_destroy (struct sip_dialog *p)
 Destroy SIP call structure.
GNURK void sip_destroy_device (struct sip_device *peer)
 Destroy device object from memory.
GNURK int sip_do_reload (void)
 Reload module.
GNURK void sip_dump_history (struct sip_dialog *dialog)
 Dump SIP history to debug log file at end of lifespan for SIP dialog.
GNURK enum ast_rtp_get_result sip_get_rtp_peer (struct ast_channel *chan, struct ast_rtp **rtp)
 Returns null if we can't reinvite audio (part of RTP interface).
GNURK enum ast_rtp_get_result sip_get_vrtp_peer (struct ast_channel *chan, struct ast_rtp **rtp)
 Returns null if we can't reinvite video (part of RTP interface).
GNURK int sip_listconfigs (int fd)
 List all configuration options in sip.conf.
GNURK char * sip_method2txt (int method)
 return text string for sip method
GNURK int sip_method_needrtp (int method)
 Check whether method needs RTP.
GNURK const char * sip_nat_mode (const struct sip_dialog *p)
 Display SIP nat mode.
GNURK int sip_notify (int fd, int argc, char *argv[])
GNURK char * sip_option2text (int option)
 Return text representation of SIP option.
GNURK int sip_option_lookup (const char *optionlabel)
 Check if sip option is known to us, avoid x- options (non-standard).
GNURK void sip_options_print (int options, int fd)
 Print options to cli.
GNURK int sip_ouraddrfor (struct in_addr *them, struct in_addr *us)
 NAT fix - decide which IP address to use for Asterisk server?
GNURK void sip_peer_hold (struct sip_dialog *p, int hold)
 Change onhold state of a peer using a pvt structure.
void sip_poke_all_peers (void)
 Send a poke to all known peers Space them out 100 ms apart XXX We might have a cool algorithm for this or use random - any suggestions?
int sip_poke_noanswer (void *data)
 React to lack of answer to Qualify poke.
int sip_poke_peer (struct sip_device *peer)
 Check availability of peer, also keep NAT open.
int sip_poke_peer_s (void *data)
 Poke peer (send qualify to check if peer is alive and well).
GNURK int sip_prune_realtime (int fd, int argc, char *argv[])
 Remove temporary realtime objects from memory (CLI).
GNURK struct ast_framesip_read (struct ast_channel *ast)
 Read SIP RTP from channel.
GNURK const struct sockaddr_in * sip_real_dst (const struct sip_dialog *p)
 The real destination address for a write.
GNURK int sip_refer_allocate (struct sip_dialog *p)
 Allocate SIP refer structure.
GNURK int sip_register (char *value, int lineno, struct sip_device *peer)
 Parse register=> line in sip.conf and add to registry.
GNURK void sip_registry_destroy (struct sip_registry *reg)
 Destroy registry object Objects created with the register= statement in static configuration.
GNURK int sip_reload (int fd)
 Force reload of module from cli.
GNURK int sip_reload_check (void)
GNURK void sip_scheddestroy (struct sip_dialog *p, int ms)
 Schedule destruction of SIP dialog.
GNURK void sip_send_all_registers (void)
 Send all known registrations.
GNURK int sip_send_mwi_to_peer (struct sip_device *peer)
 Send message waiting indication to alert peer that they've got voicemail.
GNURK int sip_set_rtp_peer (struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active)
 Set the RTP peer for this call.
GNURK int sip_show_domains (int fd, int argc, char *argv[])
 CLI command to list local domains.
GNURK void sipnet_lock (struct sip_network *sipnet)
 Lock netlock.
GNURK int sipnet_ourport (struct sip_network *sipnet)
 read our port number
GNURK void sipnet_ourport_set (struct sip_network *sipnet, int port)
 Set our port number.
GNURK void sipnet_unlock (struct sip_network *sipnet)
 Unlock netlock.
GNURK struct sip_requestsiprequest_alloc (size_t len, struct sip_network *sipnet)
 Allocate SIP request structure.
GNURK void siprequest_free (struct sip_request *req)
 Free SIP request.
GNURK int sipsock_init (struct sip_network *sipsock, struct sockaddr_in *old_bindappr)
 Initialize IP socket on configured address - the bind address.
GNURK int sipsock_read (int *id, int fd, short events, void *ignore)
 Read data from SIP socket.
GNURK int sipsocket_initialized (struct sip_network *sipnet)
 Check if network socket is open.
GNURK int sipsocket_open (struct sip_network *sipnet)
 Open network socket, bind to address and set options (TOS).
GNURK void stop_media_flows (struct sip_dialog *dialog)
 Immediately stop RTP, VRTP and UDPTL as applicable.
GNURK const char * subscription_type2str (enum subscriptiontype subtype) attribute_pure
 Show subscription type in string format.
GNURK struct sip_devicetemp_device (const char *name)
 Create temporary peer (used in autocreatepeer mode).
GNURK void transmit_fake_auth_response (struct sip_dialog *p, struct sip_request *req, int reliable)
 Send a fake 401 Unauthorized response when the administrator wants to hide the names of local users/peers from fishers.
GNURK int transmit_final_response (struct sip_dialog *dialog, const char *msg, struct sip_request *req, enum xmittype reliable)
 Transmit final response to a request and close dialog Set dialog state to TERMINATED to avoid problems At some point, after debugging, we can remove the reliable flag. Only responses to INVITEs are sent reliably.
GNURK int transmit_info_with_digit (struct sip_dialog *p, const char digit, unsigned int duration)
 Send SIP INFO dtmf message, see Cisco documentation on cisco.com.
GNURK int transmit_info_with_vidupdate (struct sip_dialog *p)
 Send SIP INFO with video update request.
GNURK int transmit_invite (struct sip_dialog *p, int sipmethod, int sdp, int init)
 Build REFER/INVITE/OPTIONS message and transmit it.
GNURK int transmit_message_with_text (struct sip_dialog *p, const char *text)
 Transmit text with SIP MESSAGE method.
GNURK int transmit_notify_with_mwi (struct sip_dialog *p, int newmsgs, int oldmsgs, char *vmexten)
 Notify user of messages waiting in voicemail.
GNURK int transmit_notify_with_sipfrag (struct sip_dialog *p, int cseq, char *message, int terminate)
 Notify a transferring party of the status of transfer.
GNURK int transmit_refer (struct sip_dialog *p, const char *dest)
 Transmit SIP REFER message (initiated by the transfer() dialplan application.
GNURK int transmit_register (struct sip_registry *r, int sipmethod, const char *auth, const char *authheader)
 Transmit register to SIP proxy or UA.
GNURK int transmit_reinvite_with_sdp (struct sip_dialog *p, int t38version)
 Transmit reinvite with SDP.
GNURK int transmit_request (struct sip_dialog *p, int sipmethod, int inc, enum xmittype reliable, int newbranch)
 Transmit generic SIP request.
GNURK int transmit_request_with_auth (struct sip_dialog *p, int sipmethod, int seqno, enum xmittype reliable, int newbranch)
 Transmit SIP request, auth added.
GNURK int transmit_response (struct sip_dialog *p, const char *msg, struct sip_request *req)
 Transmit response, no retransmits.
GNURK int transmit_response_reliable (struct sip_dialog *p, const char *msg, struct sip_request *req)
 Transmit response, Make sure you get an ACK This is only used for responses to INVITEs, where we need to make sure we get an ACK.
GNURK int transmit_response_with_attachment (enum responseattach attach, struct sip_dialog *p, const char *msg, struct sip_request *req, enum xmittype reliable)
 Transmit responses with various attachments.
GNURK int transmit_response_with_auth (struct sip_dialog *p, const char *msg, struct sip_request *req, const char *rand, enum xmittype reliable, const char *header, int stale)
 Respond with authorization request.
GNURK int transmit_response_with_unsupported (struct sip_dialog *p, const char *msg, struct sip_request *req, const char *unsupported)
 Transmit response, no retransmits.
GNURK int transmit_sip_request (struct sip_dialog *p, struct sip_request *req)
 Transmit SIP request unreliably (only used in sip_notify subsystem).
GNURK int transmit_state_notify (struct sip_dialog *p, int state, int full, int timeout)
 Used in the SUBSCRIBE notification subsystem.
GNURK void try_suggested_sip_codec (struct sip_dialog *p)
GNURK void unregister_rtp_and_udptl (void)
 UNRegister RTP and UDPTL to the subsystems.
GNURK int update_call_counter (struct sip_dialog *fup, int event)
 update_call_counter: Handle call_limit for SIP users Setting a call-limit will cause calls above the limit not to be accepted.
GNURK void update_peer (struct sip_device *device, int expiry)
 Update peer data in database (if used).

Variables

GNURK struct ast_custom_function checksipdomain_function


Define Documentation

#define GNURK
 

Definition at line 40 of file sip3funcs.h.


Function Documentation

GNURK const char* __get_header struct sip_request req,
const char *  name,
int *  start
 

Definition at line 587 of file sip3_parse.c.

References ast_log(), ast_test_flag, sip_request::header, sip_request::headers, len, LOG_ERROR, parse_request(), SIP_PKT_CONNECTED, and SIP_PKT_PARSED.

00588 {
00589    int pass;
00590 
00591    if (!ast_test_flag(req, SIP_PKT_PARSED)) {
00592       /* Ok, so this req is not parse by parse_request yet. */
00593       /* Parsing it before we have finished re-transmit may be bad. */
00594       if (!ast_test_flag(req, SIP_PKT_CONNECTED))
00595          parse_request(req);
00596       else {
00597          ast_log(LOG_ERROR, "Can't get header %s from request before parsing. Hang in for a jumpy ride!\n", name);
00598          return "";
00599       }
00600          
00601    }
00602    /*
00603     * Technically you can place arbitrary whitespace both before and after the ':' in
00604     * a header, although RFC3261 clearly says you shouldn't before, and place just
00605     * one afterwards.  If you shouldn't do it, what absolute idiot decided it was 
00606     * a good idea to say you can do it, and if you can do it, why in the hell would.
00607     * you say you shouldn't.
00608     */
00609    for (pass = 0; name && pass < 2;pass++) {
00610       int x, len = strlen(name);
00611       for (x=*start; x<req->headers; x++) {
00612          if (!strncasecmp(req->header[x], name, len)) {
00613             char *r = req->header[x] + len;  /* skip name */
00614             r = ast_skip_blanks(r);
00615 
00616             if (*r == ':') {
00617                *start = x+1;
00618                return ast_skip_blanks(r+1);
00619             }
00620          }
00621       }
00622       if (pass == 0) /* Try aliases */
00623          name = find_alias(name, NULL);
00624    }
00625 
00626    /* Don't return NULL, so get_header is always a valid pointer */
00627    return "";
00628 }

GNURK void __sip_ack struct sip_dialog dialog,
int  seqno,
int  resp,
int  sipmethod,
int  reset
 

For a reliable transmission, we need to get an reply to stop retransmission. Acknowledges receipt of a packet and stops retransmission.

Note:
Assume that the dialog is locked.

Definition at line 261 of file sip3_dialog.c.

References ast_clear_flag, ast_log(), ast_sched_del(), ast_test_flag, sip_request::dialog, dialog_lock(), FALSE, LOG_DEBUG, sip_request::method, sip_request::next, option_debug, sip_dialog::packets, parse_request(), sip_dialog::pendinginvite, sip_request::retransid, sip_request::seqno, SIP_PKT_CONNECTED, SIP_PKT_INITREQ, SIP_PKT_PARSED, SIP_PKT_RESPONSE, sipdebug, siprequest_free(), TRUE, and UNLINK.

00262 {
00263    struct sip_request *cur, *prev = NULL;
00264    int res = FALSE;
00265 
00266    if (option_debug) {
00267       if (!resp)
00268          ast_log(LOG_DEBUG, "Trying to confirm pending invite %d Call ID %s\n", dialog->pendinginvite, dialog->callid);
00269       else
00270          ast_log(LOG_DEBUG, "Trying to confirm pending response on Call ID %s\n", dialog->callid);
00271    }
00272 
00273    dialog_lock(dialog, TRUE);
00274 
00275    /* Find proper transaction */
00276    for (cur = dialog->packets; cur; prev = cur, cur = cur->next) {
00277       if (option_debug > 2)
00278          ast_log(LOG_DEBUG, "--Checking packet with seqno %d against response with seqno %d\n", cur->seqno, seqno);
00279       /* Match on seqno AND req/resp AND method? */
00280       if ((cur->seqno == seqno) && ((ast_test_flag(cur, SIP_PKT_RESPONSE)) == resp) &&
00281          ((ast_test_flag(cur, SIP_PKT_RESPONSE)) || (cur->method == sipmethod))) {
00282          if (!resp && (seqno == dialog->pendinginvite)) {
00283             if (sipdebug && option_debug && !reset)
00284                ast_log(LOG_DEBUG, "Got reply to pending invite %d - Call Id %s\n", dialog->pendinginvite, dialog->callid);
00285             dialog->pendinginvite = 0;
00286          } else {
00287             if (sipdebug && option_debug && !reset)
00288                ast_log(LOG_DEBUG, "Got ACK on INVITE response Cseq %d Call Id %s\n", cur->seqno, dialog->callid);
00289          }
00290          /* this is our baby */
00291          res = TRUE;
00292          UNLINK(cur, dialog->packets, prev);
00293          if (cur->retransid > -1) {
00294             if (sipdebug && option_debug > 3 && !reset)
00295                ast_log(LOG_DEBUG, "Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
00296             ast_sched_del(sched, cur->retransid);
00297             cur->retransid = -1;
00298          }
00299          if (!reset) {
00300             if (!ast_test_flag(cur, SIP_PKT_INITREQ)) 
00301                siprequest_free(cur);   /* We might want to keep this somewhere else */
00302             else {
00303                if (sipdebug && option_debug > 3 && !reset)
00304                   ast_log(LOG_DEBUG, "This is the initial request, keeping it in memory - Cseq %d\n", cur->seqno);
00305                ast_clear_flag(cur, SIP_PKT_CONNECTED);
00306                if (!ast_test_flag(cur, SIP_PKT_PARSED))
00307                   parse_request(cur);  /* Parse initreq now, after we have answer */
00308             }
00309          }
00310          break;
00311       }
00312    }
00313    dialog_lock(dialog, FALSE);
00314    if (option_debug && sipdebug)
00315       ast_log(LOG_DEBUG, "Stopping retransmission on '%s' of %s %d: Match %s\n", dialog->callid, resp ? "Response" : "Request", seqno, res ? "Found" : "Not Found");
00316 }