[asterisk-commits] rizzo: branch rizzo/astobj2 r47993 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Nov 24 10:27:38 MST 2006
Author: rizzo
Date: Fri Nov 24 11:27:38 2006
New Revision: 47993
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47993
Log:
document the way sip_request is used, and add a flag, SIP_PKT_PARSED,
to help debugging improper usage.
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47993&r1=47992&r2=47993
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Fri Nov 24 11:27:38 2006
@@ -592,8 +592,24 @@
#define SIP_PKT_DEBUG (1 << 0) /*!< Debug this packet */
#define SIP_PKT_WITH_TOTAG (1 << 1) /*!< This packet has a to-tag */
#define SIP_PKT_IGNORE (1 << 2) /*!< This is a re-transmit, ignore it */
-
-/*! \brief sip_request: The data grabbed from the UDP socket */
+#define SIP_PKT_PARSED (1 << 3) /*!< lines are NUL-separated */
+
+/*!
+ * Incoming packet, or outgoing one.
+ * For incoming packets, we first store the data from the socket in data[],
+ * then call parse_request() and req.method = find_sip_method();
+ * to initialize the other fields. The \r\n at the end of line is
+ * replaced by \0, so that data[] is not a conforming one anymore.
+ * flags has SIP_PKT_PARSED set to remember that we can run get_header()
+ * on this kind of packet.
+ *
+ * For outgoing packets, we initialize the fields with init_req() or init_resp()
+ * (which fills the first line to "METHOD uri SIP/2.0" or "SIP/2.0 code text"),
+ * and then fill the rest with add_header() and add_line().
+ * The \r\n at the end of the line are still there, so the get_header()
+ * and so on functions don't work on these packets.
+ */
+
struct sip_request {
char *rlPart1; /*!< SIP Method Name or "SIP/2.0" protocol version */
char *rlPart2; /*!< The Request URI or Response Status */
@@ -4283,6 +4299,10 @@
{
int pass;
+ if (!(req->flags & SIP_PKT_PARSED)) {
+ ast_log(LOG_WARNING, "packet not parsed, cannot extract field %s\n", name);
+ return "";
+ }
/*
* Technically you can place arbitrary whitespace both before and after the ':' in
* a header, although RFC3261 clearly says you shouldn't before, and place just
@@ -4982,6 +5002,7 @@
ast_log(LOG_WARNING, "Too many lines, skipping <%s>\n", c);
/* Split up the first line parts */
determine_firstline_parts(req);
+ req->flags |= SIP_PKT_PARSED;
}
/*!
More information about the asterisk-commits
mailing list