4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
35 #include "sip_miscdefs.h"
36 #include "sip_xaction.h"
42 sip_hold_trans(sip_transaction_t sip_trans
)
44 sip_xaction_t
*_trans
;
46 if (sip_trans
== NULL
)
48 _trans
= (sip_xaction_t
*)sip_trans
;
49 (void) pthread_mutex_lock(&((_trans
)->sip_xaction_mutex
));
50 SIP_XACTION_REFCNT_INCR(_trans
);
51 (void) pthread_mutex_unlock(&((_trans
)->sip_xaction_mutex
));
58 sip_release_trans(sip_transaction_t sip_trans
)
60 sip_xaction_t
*_trans
;
62 if (sip_trans
== NULL
)
64 _trans
= (sip_xaction_t
*)sip_trans
;
65 SIP_XACTION_REFCNT_DECR(_trans
);
69 * Given a message get the client/server transaction. The caller is
70 * responsible for doing a sip_release_trans().
72 const struct sip_xaction
*
73 sip_get_trans(sip_msg_t sip_msg
, int which
, int *error
)
77 if (sip_msg
== NULL
) {
82 return ((sip_transaction_t
)sip_xaction_get(NULL
, sip_msg
, B_FALSE
,
87 * Get the last response sent for this transaction
89 const struct sip_message
*
90 sip_get_trans_resp_msg(sip_transaction_t sip_trans
, int *error
)
92 sip_xaction_t
*_trans
;
96 if (sip_trans
== NULL
) {
101 _trans
= (sip_xaction_t
*)sip_trans
;
102 if ((_trans
->sip_xaction_last_msg
!= NULL
) &&
103 !sip_msg_is_request((sip_msg_t
)_trans
->sip_xaction_last_msg
,
105 return (_trans
->sip_xaction_last_msg
);
106 } else if (!sip_msg_is_request((sip_msg_t
)
107 _trans
->sip_xaction_orig_msg
, error
)) {
108 return (_trans
->sip_xaction_orig_msg
);
114 * Get the SIP message that created this transaction
116 const struct sip_message
*
117 sip_get_trans_orig_msg(sip_transaction_t sip_trans
, int *error
)
121 if (sip_trans
== NULL
) {
126 return (((sip_xaction_t
*)sip_trans
)->sip_xaction_orig_msg
);
130 * Get the connection object that was used to send the last message for this
133 const struct sip_conn_object
*
134 sip_get_trans_conn_obj(sip_transaction_t sip_trans
, int *error
)
138 if (sip_trans
== NULL
) {
143 return (((sip_xaction_t
*)sip_trans
)->sip_xaction_conn_obj
);
147 * Get the transaction method
150 sip_get_trans_method(sip_transaction_t sip_trans
, int *error
)
155 if (sip_trans
== NULL
) {
160 return (((sip_xaction_t
*)sip_trans
)->sip_xaction_method
);
164 * Get the transaction id. Caller frees string
167 sip_get_trans_branchid(sip_transaction_t trans
, int *error
)
169 sip_xaction_t
*xaction
= (sip_xaction_t
*)trans
;
174 if (xaction
== NULL
|| xaction
->sip_xaction_branch_id
== NULL
) {
179 bid
= malloc(strlen(xaction
->sip_xaction_branch_id
) + 1);
185 (void) strncpy(bid
, xaction
->sip_xaction_branch_id
,
186 strlen(xaction
->sip_xaction_branch_id
));
187 bid
[strlen(xaction
->sip_xaction_branch_id
)] = SIP_NUL
;
192 * Get the transaction state
195 sip_get_trans_state(sip_transaction_t trans
, int *error
)
197 sip_xaction_t
*xaction
= (sip_xaction_t
*)trans
;
201 if (xaction
== NULL
) {
206 return (xaction
->sip_xaction_state
);