Commit Graph

1904 Commits

Author SHA1 Message Date
Luigi Rizzo b20ab775d5 minor code rearrangements:
+ place the link field at the beginning of struct sip_pvt, 
  and not somewhere in the middle;
 
+ in __sip_reliable_xmit, remove a duplicate assignment, and
  put the statements in a more logical order (i.e. first copy
  the payload and associated info, then copy arguments from the
  caller, then finish initializing the headers...)
 
nothing to backport.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77766 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-30 10:55:37 +00:00
Luigi Rizzo adc28d1e1c rename handle_request() to handle_incoming(), as the former
was misleading - the function deals with all incoming packets, be
them requests or responses.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77753 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-30 08:07:00 +00:00
Luigi Rizzo 6fe18e2403 move some dialog-only flags to proper variables, namely
SIP_NOVIDEO, SIP_DIALOG_ANSWEREDELSEWHERE, SIP_PAGE2_NOTEXT,
SIP_PAGE2_OUTGOING_CALL
These are seldom used so the diff is relatively small.

Note that 'OUTGOING_CALL' is dangerously similar to another
dialog flag, 'SIP_OUTGOING', so the description will need to
clarify the different meaning of the two.

Also note that the description of NOTEXT is a bit unclear - does
it mean we don't support it, or 'not requested or not supported' ?


On passing fix a comment referring to video instead of text.

Finally, mark with XXX a possibly misleading debugging message.
(maybe the latter is worth backporting).



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77739 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 21:24:56 +00:00
Luigi Rizzo 597421be86 use a function, cli_yesno(), to produce the output Yes or No for
CLI lines. This helps maintaining consistency on output, slightly
improves readability, and maybe one day will make it easier to
translate the output in other languages (though i have a hard time
believing that a CLI user who needs 'yes' and 'no' to be translated
can actually figure out what he/she is doing!)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77726 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 20:55:20 +00:00
Luigi Rizzo 89f44c573e move the two remaining peer flags to proper variables.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77725 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 20:28:02 +00:00
Luigi Rizzo db10bcc41a move RT_FROMCONTACT to a proper sip_peer field.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77712 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 20:13:32 +00:00
Luigi Rizzo fd2f3a20bc Move some global 'flags' to individual variables.
Start putting these variables in a single struct (called 'sip_cfg' for the time
being, but it could as well be 'global' or some other name) so it
is easy, when reading the code, to figure out what they are for.

The downside of using struct fields instead of individual global
variables is that the compiler cannot tell if there are unused fields.
But the advantage of not cluttering the namespace and manilpulating
all these variables at once certainly overcome the disadvantagess.

Nothing to backport, again.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77711 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 20:01:36 +00:00
Luigi Rizzo 5e35eab5a2 minor simplification of a conditional statement
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77697 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 10:49:32 +00:00
Luigi Rizzo c19549820e build the version of sip_tech with no send_digit_begin
at load time instead of duplicating the initializer.
This should remove the risk of forgetting fields in the
initializer.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77684 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 10:13:14 +00:00
Luigi Rizzo e5f3a6ccdb remove bit position from description of SIP_* flags.
use AST_FORMAT_AUDIO_MASK instead of playing with AST_FORMAT_MAX_AUDIO
to determine audio formats.
There is a dubious use of AST_FORMAT_MAX_AUDIO in sip_request_call()
which surely needs fixing, namely: 
 
        /* mask request with some set of allowed formats.
         * XXX this needs to be fixed.
         * The original code uses AST_FORMAT_AUDIO_MASK, but it is
         * unclear what to use here. We have global_capabilities, which is
         * configured from sip.conf, and sip_tech.capabilities, which is
         * hardwired to all audio formats.
         */
 
The latter is possibly something to backport when fixed.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77682 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 09:27:30 +00:00
Luigi Rizzo 692e1fe0c4 back on cleaning up the usage of flags.
Move together flags used in the same way (e.g. dialog only,
dialog-peer, ...) so it will become easier to deal with them
in a more systematic way.
This is being done in stages so it will be easier to detect
breakage, if any should occur.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77669 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 08:58:10 +00:00
Luigi Rizzo b5c5227804 more documentation on internal representation of incoming SIP messages.
Remove definitions for now-unused flags, and add references to print
routines for other flags.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77668 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 08:19:19 +00:00
Luigi Rizzo 5ca87effb7 make register_unref() return NULL so it is easy to cleanup
the original pointer while calling the function.

on passing add some comments on one of the places where it
is used, and explain why it is safe there.

again, a no-op for practical purposes.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77654 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-29 00:06:35 +00:00
Luigi Rizzo 9f165b444a add some documentation to auto_congest(), and some
dialog_ref/unref (they are a no-op at the moment).
Also clean a pointer after freeing memory to avoid
dangling references, and write a for() loop in canonical form.

In practice, everything in this commit is a no-op.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77653 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-28 23:43:35 +00:00
Luigi Rizzo a6e169c09a more dialog_ref()/dialog_unref() calls
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77650 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-28 17:16:24 +00:00
Luigi Rizzo 5dcfd811d7 more dialog_ref()/dialog_unref() calls
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77648 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-28 16:38:07 +00:00
Luigi Rizzo d480266797 start introducing hooks for reference counts on dialog descriptors.
This commit is, for all practical purposes, a no-op, as it only
introduces the dialog_ref() and dialog_unref() methods, and uses them
in a few places (not all the places where they would be needed).

The goal is to start annotating the code with these calls, so the transition
to a proper container will be easier.

Nothing to backport.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77647 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-28 16:25:25 +00:00
Luigi Rizzo df75ae2285 remove an unused string
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77631 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-28 09:32:10 +00:00
Luigi Rizzo 800e1a6a03 simplify a conditional expression using S_OR
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77630 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-28 09:29:22 +00:00
Luigi Rizzo 6d8c6a9961 make use of received= and rport= fields in sip replies.
In a nutshell, these fields are used to tell a sip entity
the address and port its request came from, and are extremely
useful in the presence of NATs, especially with symmetric NATs
where STUN is totally ineffective.

This patch stores the address and port in the 'ourip' field of
the dialog descriptor, so they can be reused in subsequent transactions.
As it is, it works well for things like REGISTER requiring authentication,
because the second REGISTER request (with auth credentials) will carry
the correct address. Maybe it can also be useful, in case of an address
change, to do one or both of the following:

+ propagate the new address to the parent user/peer descriptor so that new
  dialogs will use the correct address from the beginning.
  This is trivial to implement, I am just waiting for feedback on this.

+ re-issue a request in case of an address change. This a lot less trivial,
  maybe unnecessary, and probably covered by the previous item.

I would seriously consider this patch for addition to 1.4 and 1.2.
The code is very little intrusive, and it would solve in a correct
way the nat traversal problems for which externip/externaddr/stunaddr
are only a partial and expensive workaround.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77616 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-28 07:44:16 +00:00
Joshua Colp 111250f2ae Turn 4 lines of code into 1 line that does the same thing.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77538 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-27 16:31:55 +00:00
Joshua Colp f6498f16bb Merged revisions 77536 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r77536 | file | 2007-07-27 13:27:16 -0300 (Fri, 27 Jul 2007) | 6 lines

(closes issue #10323)
Reported by: julianjm
Patches:
      chan_sip_device_state_hold_fix.v1.diff.txt uploaded by julianjm (license 99)
Clear ONHOLD flag when decrementing the onHold peer count. If we did not do this the count may keep decreasing.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77537 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-27 16:29:40 +00:00
Mark Michelson d17d9c542b Merged revisions 77490 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r77490 | mmichelson | 2007-07-27 09:30:43 -0500 (Fri, 27 Jul 2007) | 3 lines

"re-invite" was misspelled


........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77491 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-27 14:31:35 +00:00
Russell Bryant f8483a0d04 Do a massive conversion for using the ast_verb() macro
(closes issue #10277, patches by mvanbaak)

Basically, this changes ...

if (option_verbose > 2)
   ast_verbose(VERBOSE_PREFIX_3, "Something\n");

to ...

ast_verb(3, "Something\n");


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77299 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-26 15:49:18 +00:00
Russell Bryant 70f140c1d2 Revert some changes to call abs() on the result of ast_random().
* random() is defined to return a positive result, and now ast_random()
   will always do so as well


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77269 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-26 13:26:44 +00:00
Tilghman Lesher 7a97d49914 Things expecting a positive result from ast_random() should not be surprised (closes #10308)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77267 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-26 13:19:07 +00:00
Luigi Rizzo 961165519e two small fixes when using stun (reported by Marta Carbone):
+ externexpire was not initialized properly;
+ stunaddr was not handled properly on a sip reload



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76770 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-24 14:49:49 +00:00
Luigi Rizzo 6a9270d879 add two missing entries in the replica of the sip_tech that
does not use  DTMF BEGIN frames.

1.4 seems correct (it does not have the two fields).

However, as this bug shows, the current way of creating the sip_tech
replica is too error-prone, one can easily forget to update one of
the two entries.  Perhaps it would be better to create sip_tech_info
expliclty at module load, by doing

	sip_tech_info = sip_tech;
	sip_tech_info.send_digit_begin = NULL

(in this case, this is something applicable to 1.4 as well).



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76564 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 14:45:22 +00:00
Joshua Colp 90dc0cfa85 Merged revisions 76561 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r76561 | file | 2007-07-23 11:34:21 -0300 (Mon, 23 Jul 2007) | 14 lines

Merged revisions 76560 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r76560 | file | 2007-07-23 11:32:07 -0300 (Mon, 23 Jul 2007) | 6 lines

(closes issue #10236)
Reported by: homesick
Patches:
      rpid_1.4_75840.patch uploaded by homesick (license 91)
Accept Remote Party ID on guest calls.

........

................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76563 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 14:38:35 +00:00
Russell Bryant 7a2772c151 Mark str2dtmfmode() as currently unused to resolve a compiler warning and
allow building under dev mode


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76562 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 14:37:26 +00:00
Russell Bryant eaebbdab61 (closes issue #10271)
Reported by: snuffy
Patches:
      doxygen-updates.diff uploaded by snuffy (license 35)

Another big batch of doxygen documentation updates


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76559 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 14:32:04 +00:00
Luigi Rizzo b1791d9349 introduce two functions, map_x_s() and map_s_x(), to map
between integers and strings using a single translation table,
and use them in a few places instead of ad-hoc routines
that duplicate the table.

On passing, note that REFER_CONFIRMED is never used, and add a
few comments.

Nothing to backport here.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76547 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 14:18:04 +00:00
Russell Bryant 83609770c1 Remove an unused function to resolve a compiler warning
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76524 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 14:02:21 +00:00
Luigi Rizzo ed1775bd10 move "sip prunte realtime ..." and "sip set debug ... " to NEW_CLI style.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76521 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 13:29:06 +00:00
Luigi Rizzo 1ee5480549 Add some documentation on the sipregistry states and the
handling of the sip_register structures.
This commit only changes comments and whitespace.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76467 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 03:10:31 +00:00
Luigi Rizzo 28cde9fee3 add a bit of comments on internal functions.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76458 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 02:46:10 +00:00
Luigi Rizzo 719dcef90d rewrite "sip show {channels|subscriptions}" CLI handler
using the new-style cli format.
No functional changes, nothing to backport.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76408 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-22 21:38:26 +00:00
Luigi Rizzo 930bf0402d Make sip_destroy() return NULL so the caller can do things like
foo = sip_destroy(foo);
and reduce the chance of bugs due to dangling pointers.

Also remove a duplicate prototype for the function.

nothing to backport.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76392 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-22 21:00:10 +00:00
Luigi Rizzo 97512a856f add two comment blocks, one on reusing nonces, and one on the handling
of an 'authpeer' local variable.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76390 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-22 20:44:06 +00:00
Luigi Rizzo db12b404fc comment and slightly restructure handle_request() in the part that handles
responses, so that there is a common exit point.
Mark two places where probably we could return -1 instead of 0 to report
an error to the caller.
(change triggered by investigations on how the 'SIP_PKT_IGNORE' field was used).

nothing to backport from this commit



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76371 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-22 19:08:37 +00:00
Luigi Rizzo 88f18dc9d7 remove unused argument from handle_invite_replaces(), and also leftover
SIP_PKT_* stuff from the previous commit.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76366 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-22 18:46:52 +00:00
Luigi Rizzo b7945cd78e Cleanup of flags used in struct sip_request, moving them to
individual variables. Apart from SIP_PKT_IGNORE which was used
a zillion times, the other two are used seldom.

On passing:
- move the arrays to the end of struct sip_request, so a (small)
  buffer overflow is less likely to overwrite the other fields;
- note that the 'ignore' argument to handle_invite_replaces() is not
  used and should be removed (will be done in a separate commit).

Nothing to backport in this change.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76365 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-22 18:41:57 +00:00
Luigi Rizzo aa110ad3fd move two per-packet flags to proper variables.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76349 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-22 18:03:07 +00:00
Luigi Rizzo e603d729a9 minor clarification on the usage of SIP_* flags.
Also correct some items that were misclassified.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76348 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-22 17:27:52 +00:00
Luigi Rizzo 0d5e33f2c3 document the way sipdebug works, and implement it through
variables and not flags.

NOTE:
The old behaviour (preserved in this commit) is that if sipdebug
is set in the config file, it can only be disabled by reloading the
config.  I am not sure if this is accidental or voluntary, but it
is really unconvenient and I think it should be handled in the same
way as other options i.e. consider requests from the config file
or the cli (or the command line) to be fully equivalent and act on
the same status variable.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76330 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-22 08:42:24 +00:00
Luigi Rizzo 063edd1953 move the SIP_REALTIME flag to a field in the user/peer structure.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76314 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-21 17:57:47 +00:00
Luigi Rizzo 1daf32e474 Add a note to document how the temporary 'pvt' should be initialized
before using it.
I am unclear on the details right now so i hope someone can comment
more. The obvious (and lazy) approach would be to bzero() all of it
(except for the string pool), but isn't that too much work ?
Feedback wanted here...



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76313 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-21 17:32:00 +00:00
Luigi Rizzo ed604a6df8 whoops... was setting needdestroy on the wrong dialog.
(spotted by a diff with my own branch)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76279 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-21 09:35:48 +00:00
Luigi Rizzo b11d587ab6 more two more flags to proper variables: ALREADYGONE and NEEDDESTROY.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76278 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-21 09:18:50 +00:00
Luigi Rizzo 4ce3ee94c3 use explicit variables for things that don't need to
be stored in ast_flags. First victim is 'SIP_NO_HISTORY'
replaced by a 'do_history' field in the sip_pvt structure.




git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76231 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-21 03:53:17 +00:00