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.
27 #pragma ident "%Z%%M% %I% %E% SMI"
37 #include "sip_miscdefs.h"
38 #include "sip_xaction.h"
44 sip_hold_trans(sip_transaction_t sip_trans
)
46 sip_xaction_t
*_trans
;
48 if (sip_trans
== NULL
)
50 _trans
= (sip_xaction_t
*)sip_trans
;
51 (void) pthread_mutex_lock(&((_trans
)->sip_xaction_mutex
));
52 SIP_XACTION_REFCNT_INCR(_trans
);
53 (void) pthread_mutex_unlock(&((_trans
)->sip_xaction_mutex
));
60 sip_release_trans(sip_transaction_t sip_trans
)
62 sip_xaction_t
*_trans
;
64 if (sip_trans
== NULL
)
66 _trans
= (sip_xaction_t
*)sip_trans
;
67 SIP_XACTION_REFCNT_DECR(_trans
);
71 * Given a message get the client/server transaction. The caller is
72 * responsible for doing a sip_release_trans().
74 const struct sip_xaction
*
75 sip_get_trans(sip_msg_t sip_msg
, int which
, int *error
)
79 if (sip_msg
== NULL
) {
84 return ((sip_transaction_t
)sip_xaction_get(NULL
, sip_msg
, B_FALSE
,
89 * Get the last response sent for this transaction
91 const struct sip_message
*
92 sip_get_trans_resp_msg(sip_transaction_t sip_trans
, int *error
)
94 sip_xaction_t
*_trans
;
98 if (sip_trans
== NULL
) {
103 _trans
= (sip_xaction_t
*)sip_trans
;
104 if ((_trans
->sip_xaction_last_msg
!= NULL
) &&
105 !sip_msg_is_request((sip_msg_t
)_trans
->sip_xaction_last_msg
,
107 return (_trans
->sip_xaction_last_msg
);
108 } else if (!sip_msg_is_request((sip_msg_t
)
109 _trans
->sip_xaction_orig_msg
, error
)) {
110 return (_trans
->sip_xaction_orig_msg
);
116 * Get the SIP message that created this transaction
118 const struct sip_message
*
119 sip_get_trans_orig_msg(sip_transaction_t sip_trans
, int *error
)
123 if (sip_trans
== NULL
) {
128 return (((sip_xaction_t
*)sip_trans
)->sip_xaction_orig_msg
);
132 * Get the connection object that was used to send the last message for this
135 const struct sip_conn_object
*
136 sip_get_trans_conn_obj(sip_transaction_t sip_trans
, int *error
)
140 if (sip_trans
== NULL
) {
145 return (((sip_xaction_t
*)sip_trans
)->sip_xaction_conn_obj
);
149 * Get the transaction method
152 sip_get_trans_method(sip_transaction_t sip_trans
, int *error
)
157 if (sip_trans
== NULL
) {
162 return (((sip_xaction_t
*)sip_trans
)->sip_xaction_method
);
166 * Get the transaction id. Caller frees string
169 sip_get_trans_branchid(sip_transaction_t trans
, int *error
)
171 sip_xaction_t
*xaction
= (sip_xaction_t
*)trans
;
176 if (xaction
== NULL
|| xaction
->sip_xaction_branch_id
== NULL
) {
181 bid
= malloc(strlen(xaction
->sip_xaction_branch_id
) + 1);
187 (void) strncpy(bid
, xaction
->sip_xaction_branch_id
,
188 strlen(xaction
->sip_xaction_branch_id
));
189 bid
[strlen(xaction
->sip_xaction_branch_id
)] = '\0';
194 * Get the transaction state
197 sip_get_trans_state(sip_transaction_t trans
, int *error
)
199 sip_xaction_t
*xaction
= (sip_xaction_t
*)trans
;
203 if (xaction
== NULL
) {
208 return (xaction
->sip_xaction_state
);