[asterisk-commits] rizzo: branch rizzo/astobj2 r48533 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sat Dec 16 23:55:24 MST 2006
Author: rizzo
Date: Sun Dec 17 00:55:23 2006
New Revision: 48533
URL: http://svn.digium.com/view/asterisk?view=rev&rev=48533
Log:
replace a sizeof(struct sip_request) with sizeof(*req);
introduce a new struct to store outgoing packets.
First, because the internal format for incoming and outgoing packets
is different, it is very confusing (and dangerous) to store
them in the same struct, as it prevents the compiler from
helping us.
Second, by using a different structure we can optimize them
for the two situations.
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=48533&r1=48532&r2=48533
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Sun Dec 17 00:55:23 2006
@@ -595,7 +595,7 @@
#define SIP_PKT_PARSED (1 << 3) /*!< lines are NUL-separated */
/*!
- * Incoming packet, or outgoing one.
+ * Incoming packet, or outgoing one (for the time being)
* For incoming packets, we first store the data from the socket in data[],
* adding a trailing \0 to make string parsing routines happy.
* Then call parse_request() and req.method = find_sip_method();
@@ -623,6 +623,27 @@
*/
struct sip_request {
+ char *rlPart1; /*!< SIP Method Name or "SIP/2.0" protocol version */
+ char *rlPart2; /*!< The Request URI or Response Status */
+ int len; /*!< Length */
+ int headers; /*!< # of SIP Headers */
+ int method; /*!< Method of this request */
+ int lines; /*!< Body Content */
+ unsigned int flags; /*!< SIP_PKT Flags for this packet */
+ unsigned int sdp_start; /*!< the line number where the SDP begins */
+ unsigned int sdp_end; /*!< the line number where the SDP ends */
+ char *header[SIP_MAX_HEADERS];
+ char *line[SIP_MAX_LINES];
+ char data[SIP_MAX_PACKET];
+};
+
+/*!
+ * Storage for outgoing packets.
+ * It makes sense to use a different data structure than the one for incoming
+ * packets as the internal format is not the same (e.g. no '\0' between
+ * the various lines).
+ */
+struct sip_msg_out {
char *rlPart1; /*!< SIP Method Name or "SIP/2.0" protocol version */
char *rlPart2; /*!< The Request URI or Response Status */
int len; /*!< Length */
@@ -5998,7 +6019,7 @@
int is_strict = FALSE; /*!< Strict routing flag */
int is_outbound = ast_test_flag(&p->flags[0], SIP_OUTGOING); /* Session direction */
- memset(req, 0, sizeof(struct sip_request));
+ memset(req, 0, sizeof(*req));
snprintf(p->lastmsg, sizeof(p->lastmsg), "Tx: %s", sip_methods[sipmethod].text);
More information about the asterisk-commits
mailing list