2 * Copyright (c) 1996-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * Author: Hartmut Brandt <harti@freebsd.org>
29 * $Begemot: libunimsg/netnatm/sig/sig_party.c,v 1.18 2004/08/05 07:11:01 brandt Exp $
31 * Party instance handling
34 #include <netnatm/unimsg.h>
35 #include <netnatm/saal/sscfudef.h>
36 #include <netnatm/msg/unistruct.h>
37 #include <netnatm/msg/unimsglib.h>
38 #include <netnatm/sig/uni.h>
40 #include <netnatm/sig/unipriv.h>
41 #include <netnatm/sig/unimkmsg.h>
42 #include <netnatm/sig/unimsgcpy.h>
44 static void drop_partyE(struct party *p);
45 static int epstate_compat(struct party *, enum uni_epstate);
47 #define DEF_PRIV_SIG(NAME, FROM) [SIG##NAME] = "SIG"#NAME,
48 static const char *const party_sigs[] = {
53 TIMER_FUNC_PARTY(t397, t397_func)
54 TIMER_FUNC_PARTY(t398, t398_func)
55 TIMER_FUNC_PARTY(t399, t399_func)
58 set_party_state(struct party *p, enum uni_epstate state)
60 if (p->state != state) {
61 VERBOSE(p->call->uni, UNI_FAC_CALL, 1,
62 "party %u/%u %u/%u PU%u -> PU%u",
63 p->call->cref, p->call->mine,
64 p->epref, p->flags & PARTY_MINE, p->state, state);
70 * Create a party with a given endpoint reference.
71 * No check is done, that a party with this epref does not alreay exist.
74 uni_create_partyx(struct call *c, u_int epref, u_int mine, uint32_t cookie)
78 struct uniapi_party_created *ind;
80 mine = (mine ? PARTY_MINE : 0);
82 if ((p = PARTY_ALLOC()) == NULL)
85 if ((ind = ALLOC_API(struct uniapi_party_created, api)) == NULL) {
90 ind->cref.cref = c->cref;
91 ind->cref.flag = c->mine;
92 MK_IE_EPREF(ind->epref, epref, mine);
93 ind->epref.h.act = UNI_IEACT_DEFAULT;
98 p->state = UNI_EPSTATE_NULL;;
100 TIMER_INIT_PARTY(p, t397);
101 TIMER_INIT_PARTY(p, t398);
102 TIMER_INIT_PARTY(p, t399);
104 TAILQ_INSERT_HEAD(&c->parties, p, link);
106 c->uni->funcs->uni_output(c->uni, c->uni->arg,
107 UNIAPI_PARTY_CREATED, cookie, api);
109 VERBOSE(c->uni, UNI_FAC_CALL, 1, "created party %u/%s %u/%s",
110 p->call->cref, p->call->mine ? "mine" : "his",
111 p->epref, (p->flags & PARTY_MINE) ? "mine" : "his");
118 uni_create_party(struct call *c, struct uni_ie_epref *epref)
120 return (uni_create_partyx(c, epref->epref, epref->flag, 0));
124 uni_find_party(struct call *c, struct uni_ie_epref *epref)
128 TAILQ_FOREACH(p, &c->parties, link)
129 if (p->epref == epref->epref &&
130 (!(p->flags & PARTY_MINE) == !epref->flag))
135 uni_find_partyx(struct call *c, u_int epref, u_int mine)
139 TAILQ_FOREACH(p, &c->parties, link)
140 if (p->epref == epref && (!(p->flags & PARTY_MINE) == !mine))
147 * This function is assumed to remove the party from the parent's call
151 uni_destroy_party(struct party *p, int really)
154 struct uniapi_party_destroyed *ind;
156 TIMER_DESTROY_PARTY(p, t397);
157 TIMER_DESTROY_PARTY(p, t398);
158 TIMER_DESTROY_PARTY(p, t399);
160 TAILQ_REMOVE(&p->call->parties, p, link);
162 uni_delsig(p->call->uni, SIG_PARTY, p->call, p);
165 ind = ALLOC_API(struct uniapi_party_destroyed, api);
167 ind->cref.cref = p->call->cref;
168 ind->cref.flag = p->call->mine;
169 ind->epref.epref = p->epref;
170 ind->epref.flag = p->flags & PARTY_MINE;
171 ind->epref.h.act = UNI_IEACT_DEFAULT;
172 IE_SETPRESENT(ind->epref);
174 uni_enq_call(p->call, SIGC_PARTY_DESTROYED, 0, api, NULL);
177 uni_enq_party(p, SIGP_PARTY_DELETE, 0, NULL, NULL);
184 * Count number of parties in active states.
185 * If the argument is 0 only ACTIVE parties are counter
186 * If the argument is 1 only parties in establishing states are counted
187 * If the argument is 2 both are counted.
190 uni_party_act_count(struct call *c, int kind)
196 TAILQ_FOREACH(p, &c->parties, link) {
199 case UNI_EPSTATE_ACTIVE:
200 if (kind == 0 || kind == 2)
204 case UNI_EPSTATE_ALERT_RCVD:
205 case UNI_EPSTATE_ADD_INIT:
206 case UNI_EPSTATE_ALERT_DLVD:
207 case UNI_EPSTATE_ADD_RCVD:
208 if (kind == 1 || kind == 2)
220 stop_all_party_timers(struct party *p)
222 TIMER_STOP_PARTY(p, t397);
223 TIMER_STOP_PARTY(p, t398);
224 TIMER_STOP_PARTY(p, t399);
226 /************************************************************/
231 * Q.2971:Party-control-U 3 (PU0)
232 * Q.2971:Party-control-N 3 (PN0)
235 pun0_add_party_request(struct party *p, struct uni_msg *api, uint32_t cookie)
238 struct uniapi_add_party_request *req =
239 uni_msg_rptr(api, struct uniapi_add_party_request *);
241 if ((add = UNI_ALLOC()) == NULL) {
242 uni_msg_destroy(api);
243 uniapi_party_error(p, UNIAPI_ERROR_NOMEM, cookie);
247 add->u.add_party = req->add;
248 MK_MSG_ORIG(add, UNI_ADD_PARTY, p->call->cref, !p->call->mine);
249 uni_send_output(add, p->call->uni);
252 TIMER_START_PARTY(p, t399, p->call->uni->timer399);
254 set_party_state(p, UNI_EPSTATE_ADD_INIT);
256 uni_msg_destroy(api);
257 uniapi_party_error(p, UNIAPI_OK, cookie);
261 * Add-party-ack.request
263 * Q.2971:Party-Control-U 6 PU2
264 * Q.2971:Party-Control-U 7 PU3
265 * Q.2971:Party-Control-N 6 PN2
266 * Q.2971:Party-Control-N 7 PN3
269 punx_add_party_ack_request(struct party *p, struct uni_msg *m, uint32_t cookie)
272 struct uniapi_add_party_ack_request *req =
273 uni_msg_rptr(m, struct uniapi_add_party_ack_request *);
275 if ((ack = UNI_ALLOC()) == NULL) {
276 uniapi_party_error(p, UNIAPI_ERROR_NOMEM, cookie);
280 ack->u.add_party_ack = req->ack;
281 MK_MSG_ORIG(ack, UNI_ADD_PARTY_ACK, p->call->cref, !p->call->mine);
282 uni_send_output(ack, p->call->uni);
285 set_party_state(p, UNI_EPSTATE_ACTIVE);
288 uniapi_party_error(p, UNIAPI_OK, cookie);
292 * Add-party-rej.request
294 * Q.2971:Party-Control-U 6 PU2
295 * Q.2971:Party-Control-N 6 PN2
298 pun2_add_party_rej_request(struct party *p, struct uni_msg *m, uint32_t cookie)
301 struct uniapi_add_party_rej_request *req =
302 uni_msg_rptr(m, struct uniapi_add_party_rej_request *);
304 if ((rej = UNI_ALLOC()) == NULL) {
305 uniapi_party_error(p, UNIAPI_ERROR_NOMEM, cookie);
310 stop_all_party_timers(p);
312 rej->u.add_party_rej = req->rej;
313 MK_MSG_ORIG(rej, UNI_ADD_PARTY_REJ, p->call->cref, !p->call->mine);
314 uni_enq_call(p->call, SIGC_SEND_ADD_PARTY_REJ, cookie, NULL, rej);
317 p->state = UNI_EPSTATE_NULL;
318 uniapi_party_error(p, UNIAPI_OK, cookie);
320 uni_destroy_party(p, 0);
324 * ADD PARTY in PU0, PN0
326 * Q.2971:Party-Control-U 3/14 PU0
329 pun0_add_party(struct party *p, struct uni_msg *m, struct uni_all *u)
331 struct uniapi_add_party_indication *ind;
334 ind = ALLOC_API(struct uniapi_add_party_indication, api);
336 ind->add.hdr = u->u.hdr;
337 copy_msg_add_party(&u->u.add_party, &ind->add);
338 p->call->uni->funcs->uni_output(p->call->uni, p->call->uni->arg,
339 UNIAPI_ADD_PARTY_indication, 0, api);
341 set_party_state(p, UNI_EPSTATE_ADD_RCVD);
348 * PARTY-ALERTING.request
350 * Q.2971:Party-Control-U 6 (PU2)
351 * Q.2971:Party-Control-N 6 (PN2)
354 pun2_party_alerting_request(struct party *p, struct uni_msg *api,
357 struct uni_all *alert;
358 struct uniapi_party_alerting_request *req =
359 uni_msg_rptr(api, struct uniapi_party_alerting_request *);
361 if ((alert = UNI_ALLOC()) == NULL) {
362 uniapi_party_error(p, UNIAPI_ERROR_NOMEM, cookie);
363 uni_msg_destroy(api);
366 alert->u.party_alerting = req->alert;
367 MK_MSG_ORIG(alert, UNI_PARTY_ALERTING,
368 p->call->cref, !p->call->mine);
369 uni_send_output(alert, p->call->uni);
372 set_party_state(p, UNI_EPSTATE_ALERT_DLVD);
374 uni_msg_destroy(api);
375 uniapi_party_error(p, UNIAPI_OK, cookie);
379 * PARTY-ALERTING in state PU1/PN1
381 * Q.2971:Party-Control-U 14
382 * Q.2971:Party-Control-N 5
385 pun1_party_alerting(struct party *p, struct uni_msg *m, struct uni_all *u)
387 struct uniapi_party_alerting_indication *ind;
390 ind = ALLOC_API(struct uniapi_party_alerting_indication, api);
396 TIMER_STOP_PARTY(p, t399);
398 ind->alert.hdr = u->u.hdr;
399 copy_msg_party_alerting(&u->u.party_alerting, &ind->alert);
401 p->call->uni->funcs->uni_output(p->call->uni, p->call->uni->arg,
402 UNIAPI_PARTY_ALERTING_indication, 0, api);
404 TIMER_START_PARTY(p, t397, p->call->uni->timer397);
409 set_party_state(p, UNI_EPSTATE_ALERT_RCVD);
415 * Q.2971:Party-Control-U 4 (PU1)
416 * Q.2971:Party-Control-U 7 (PU4)
417 * Q.2971:Party-Control-N 4 (PN1)
418 * Q.2971:Party-Control-N 7 (PN4)
421 pun1pun4_add_party_ack(struct party *p, struct uni_msg *m, struct uni_all *u)
423 struct uniapi_add_party_ack_indication *ind;
426 ind = ALLOC_API(struct uniapi_add_party_ack_indication, api);
433 if (p->state == UNI_EPSTATE_ADD_INIT)
434 TIMER_STOP_PARTY(p, t399);
436 TIMER_STOP_PARTY(p, t397);
438 ind->ack.hdr = u->u.hdr;
439 copy_msg_add_party_ack(&u->u.add_party_ack, &ind->ack);
441 p->call->uni->funcs->uni_output(p->call->uni, p->call->uni->arg,
442 UNIAPI_ADD_PARTY_ACK_indication, 0, api);
447 set_party_state(p, UNI_EPSTATE_ACTIVE);
453 * Q.2971:Party-Control-U 4 (PU1)
454 * Q.2971:Party-Control-N 4 (PN1)
457 pun1_add_party_rej(struct party *p, struct uni_msg *m, struct uni_all *u)
459 struct uniapi_add_party_rej_indication *ind;
462 ind = ALLOC_API(struct uniapi_add_party_rej_indication, api);
469 TIMER_STOP_PARTY(p, t399);
471 ind->rej.hdr = u->u.hdr;
472 copy_msg_add_party_rej(&u->u.add_party_rej, &ind->rej);
473 uni_enq_call(p->call, SIGC_ADD_PARTY_REJ_indication, 0, api, NULL);
475 uni_destroy_party(p, 0);
484 * Q.2971:Party-Control-U 10 (PU5)
485 * Q.2971:Party-Control-N 10 (PN5)
488 pun5_add_party_rej(struct party *p, struct uni_msg *m, struct uni_all *u)
490 struct uniapi_drop_party_ack_indication *ind;
493 ind = ALLOC_API(struct uniapi_drop_party_ack_indication, api);
500 ind->drop.hdr = u->u.hdr;
501 COPY_FROM_ADD_REJ(u, &ind->drop);
502 if (IE_ISGOOD(u->u.add_party_rej.crankback))
503 ind->crankback = u->u.add_party_rej.crankback;
504 uni_enq_call(p->call, SIGC_DROP_PARTY_ACK_indication, 0, api, NULL);
506 TIMER_STOP_PARTY(p, t398);
508 uni_destroy_party(p, 0);
515 * DROP-PARTY-ACKNOWLEDGE
517 * Q.2971:Party-Control-U 8
518 * Q.2971:Party-Control-N 8
520 * Message already verified in Call-Control!
523 punx_drop_party_ack(struct party *p, struct uni_msg *m, struct uni_all *u)
525 struct uniapi_drop_party_ack_indication *ind;
528 stop_all_party_timers(p);
530 ind = ALLOC_API(struct uniapi_drop_party_ack_indication, api);
532 ind->drop.hdr = u->u.hdr;
533 COPY_FROM_DROP_ACK(u, &ind->drop);
534 uni_enq_call(p->call, SIGC_DROP_PARTY_ACK_indication,
538 uni_destroy_party(p, 0);
545 * DROP PARTY message in any state except PU5/PN5
547 * Q.2971:Party-Control-U 9
548 * Q.2971:Party-Control-N 9
551 punx_drop_party(struct party *p, struct uni_msg *m, struct uni_all *u)
553 struct uniapi_drop_party_indication *ind;
556 ind = ALLOC_API(struct uniapi_drop_party_indication, api);
563 ind->drop.hdr = u->u.hdr;
564 copy_msg_drop_party(&u->u.drop_party, &ind->drop);
566 /* need the cause even if it is bad */
567 if (IE_ISERROR(u->u.drop_party.cause))
568 ind->drop.cause = u->u.drop_party.cause;
570 ind->my_cause = p->call->uni->cause;
572 uni_enq_call(p->call, SIGC_DROP_PARTY_indication, 0, api, NULL);
574 TIMER_STOP_PARTY(p, t397);
575 TIMER_STOP_PARTY(p, t399);
580 set_party_state(p, UNI_EPSTATE_DROP_RCVD);
584 * DROP PARTY message in state PU5/PN5
586 * Q.2971:Party-Control-U 10
587 * Q.2971:Party-Control-N 10
590 pun5_drop_party(struct party *p, struct uni_msg *m, struct uni_all *u)
592 struct uniapi_drop_party_ack_indication *ind;
595 ind = ALLOC_API(struct uniapi_drop_party_ack_indication, api);
602 ind->drop.hdr = u->u.hdr;
603 copy_msg_drop_party(&u->u.drop_party, &ind->drop);
605 /* need the cause even if it is bad */
606 if (IE_ISERROR(u->u.drop_party.cause))
607 ind->drop.cause = u->u.drop_party.cause;
609 uni_enq_call(p->call, SIGC_DROP_PARTY_ACK_indication, 0, api, NULL);
611 TIMER_STOP_PARTY(p, t398);
616 set_party_state(p, UNI_EPSTATE_DROP_RCVD);
618 uni_destroy_party(p, 0);
621 /************************************************************/
626 * Q.2971:Party-Control-U 4 (PU1)
627 * Q.2971:Party-Control-N 4 (PN1)
630 pun1_t399(struct party *p)
632 if (p->call->uni->proto == UNIPROTO_UNI40N) {
633 MK_IE_CAUSE(p->call->uni->cause, UNI_CAUSE_LOC_USER,
634 UNI_CAUSE_NO_RESPONSE);
636 MK_IE_CAUSE(p->call->uni->cause, UNI_CAUSE_LOC_USER,
638 ADD_CAUSE_TIMER(p->call->uni->cause, "399");
647 * Q.2971:Party-Control-U 10 (PU5)
648 * Q.2971:Party-Control-N 10 (PN5)
651 pun5_t398(struct party *p)
653 struct uniapi_drop_party_ack_indication *ind;
654 struct uni_all *drop;
657 MK_IE_CAUSE(p->call->uni->cause,
658 UNI_CAUSE_LOC_USER, UNI_CAUSE_RECOVER);
659 ADD_CAUSE_TIMER(p->call->uni->cause, "398");
661 * Send indication to API
663 ind = ALLOC_API(struct uniapi_drop_party_ack_indication, api);
665 ind->drop.hdr.cref.cref = p->call->cref;
666 ind->drop.hdr.cref.flag = p->call->mine;
667 ind->drop.hdr.act = UNI_MSGACT_DEFAULT;
668 MK_IE_EPREF(ind->drop.epref, p->epref, p->flags & PARTY_MINE);
669 ind->drop.cause = p->call->uni->cause;
670 uni_enq_call(p->call, SIGC_DROP_PARTY_ACK_indication,
675 * Send DROP PARTY ACK
677 if ((drop = UNI_ALLOC()) != NULL) {
678 MK_MSG_ORIG(drop, UNI_DROP_PARTY_ACK,
679 p->call->cref, !p->call->mine);
680 MK_IE_EPREF(drop->u.drop_party_ack.epref,
681 p->epref, !(p->flags & PARTY_MINE));
682 drop->u.drop_party_ack.cause = p->call->uni->cause;
683 uni_enq_call(p->call, SIGC_SEND_DROP_PARTY_ACK, 0, NULL, drop);
686 uni_destroy_party(p, 0);
692 * Q.2971:Party-Control-U 7 (PU4)
693 * Q.2971:Party-Control-N 7 (PN4)
696 pun4_t397(struct party *p)
698 MK_IE_CAUSE(p->call->uni->cause, UNI_CAUSE_LOC_USER,
700 ADD_CAUSE_TIMER(p->call->uni->cause, "397");
705 /************************************************************/
708 * Drop a party because of an error condition.
709 * This is label E on page Party-Control-U 8/14.
711 * It is assumed, that the caller has constructed the cause in
712 * p->call->uni->cause.
715 drop_partyE(struct party *p)
718 struct uniapi_drop_party_indication *ind;
719 struct uni_all *drop;
722 * Send indication to API
724 if ((ind = ALLOC_API(struct uniapi_drop_party_indication, api)) != NULL) {
725 ind->drop.hdr.cref.cref = p->call->cref;
726 ind->drop.hdr.cref.flag = p->call->mine;
727 ind->drop.hdr.act = UNI_MSGACT_DEFAULT;
728 MK_IE_EPREF(ind->drop.epref, p->epref, p->flags & PARTY_MINE);
729 ind->drop.cause = p->call->uni->cause;
730 uni_enq_call(p->call, SIGC_DROP_PARTY_indication, 0, api, NULL);
732 TIMER_STOP_PARTY(p, t399);
733 TIMER_STOP_PARTY(p, t397);
734 TIMER_START_PARTY(p, t398, p->call->uni->timer398);
736 if ((drop = UNI_ALLOC()) != NULL) {
737 drop->u.drop_party.cause = p->call->uni->cause;
738 MK_MSG_ORIG(drop, UNI_DROP_PARTY, p->call->cref, !p->call->mine);
739 MK_IE_EPREF(drop->u.drop_party.epref, p->epref,
740 !(p->flags & PARTY_MINE));
741 uni_enq_call(p->call, SIGC_SEND_DROP_PARTY, 0, NULL, drop);
744 set_party_state(p, UNI_EPSTATE_DROP_INIT);
748 * Drop party request in Px1, Px3, Px4 or Px7
750 * Q.2971:Party-Control-U 8
751 * Q.2971:Party-Control-N 8
754 punx_drop_party_request(struct party *p, struct uni_msg *api, uint32_t cookie)
756 struct uniapi_drop_party_request *req =
757 uni_msg_rptr(api, struct uniapi_drop_party_request *);
758 struct uni_all *drop;
760 if ((drop = UNI_ALLOC()) == NULL) {
761 uniapi_party_error(p, UNIAPI_ERROR_NOMEM, cookie);
762 uni_msg_destroy(api);
766 TIMER_STOP_PARTY(p, t399);
767 TIMER_STOP_PARTY(p, t397);
768 TIMER_START_PARTY(p, t398, p->call->uni->timer398);
770 drop->u.drop_party = req->drop;
771 MK_MSG_ORIG(drop, UNI_DROP_PARTY, p->call->cref, !p->call->mine);
772 uni_enq_call(p->call, SIGC_SEND_DROP_PARTY, cookie, NULL, drop);
774 set_party_state(p, UNI_EPSTATE_DROP_INIT);
776 uni_msg_destroy(api);
777 uniapi_party_error(p, UNIAPI_OK, cookie);
781 * Drop-party-ack.request in Px6
783 * Q.2971:Party-Control-U 9
784 * Q.2971:Party-Control-N 9
787 pun6_drop_party_ack_request(struct party *p, struct uni_msg *api, uint32_t cookie)
789 struct uniapi_drop_party_ack_request *req =
790 uni_msg_rptr(api, struct uniapi_drop_party_ack_request *);
793 if ((ack = UNI_ALLOC()) == NULL) {
794 uni_msg_destroy(api);
795 uniapi_party_error(p, UNIAPI_ERROR_NOMEM, cookie);
798 ack->u.drop_party_ack = req->ack;
799 MK_MSG_ORIG(ack, UNI_DROP_PARTY_ACK, p->call->cref, !p->call->mine);
800 uni_enq_call(p->call, SIGC_SEND_DROP_PARTY_ACK, cookie, NULL, ack);
802 stop_all_party_timers(p);
804 uni_msg_destroy(api);
805 uniapi_party_error(p, UNIAPI_OK, cookie);
807 uni_destroy_party(p, 0);
809 /************************************************************/
811 * Party status enquiry request from API or call-control
813 * Q.2971:Party-Control-U 12
814 * Q.2971:Party-Control-N 12
817 punx_status_enquiry_request(struct party *p, uint32_t cookie)
821 if((enq = UNI_ALLOC()) == NULL) {
822 uniapi_party_error(p, UNIAPI_ERROR_NOMEM, cookie);
825 MK_IE_EPREF(enq->u.status_enq.epref, p->epref,
826 !(p->flags & PARTY_MINE));
827 MK_MSG_ORIG(enq, UNI_STATUS_ENQ, p->call->cref, !p->call->mine);
828 uni_enq_call(p->call, SIGC_SEND_STATUS_ENQ, cookie, NULL, enq);
830 uniapi_party_error(p, UNIAPI_OK, cookie);
834 * STATUS in any state except PU5/PN5
836 * Q.2971:Party-Control-U 12
837 * Q.2971:Party-Control-N 12
840 punx_status(struct party *p, struct uni_msg *m, struct uni_all *u)
842 struct uniapi_drop_party_ack_indication *ind;
845 if (u->u.status.epstate.state == UNI_EPSTATE_NULL) {
846 /* should not happend */
847 ind = ALLOC_API(struct uniapi_drop_party_ack_indication, api);
849 ind->drop.hdr = u->u.hdr;
850 ind->drop.cause = u->u.status.cause;
851 ind->drop.epref = u->u.status.epref;
852 uni_enq_call(p->call, SIGC_DROP_PARTY_ACK_indication,
855 stop_all_party_timers(p);
857 uni_destroy_party(p, 0);
859 if (epstate_compat(p, u->u.status.epstate.state)) {
860 if(u->u.status.cause.cause == UNI_CAUSE_MANDAT ||
861 u->u.status.cause.cause == UNI_CAUSE_MTYPE_NIMPL ||
862 u->u.status.cause.cause == UNI_CAUSE_IE_NIMPL ||
863 u->u.status.cause.cause == UNI_CAUSE_IE_INV) {
864 MK_IE_CAUSE(p->call->uni->cause,
870 MK_IE_CAUSE(p->call->uni->cause,
872 UNI_CAUSE_MSG_INCOMP);
884 * Q.2971:Party-Control-U 10
885 * Q.2971:Party-Control-N 10
888 pun5_status(struct party *p, struct uni_msg *m, struct uni_all *u)
890 struct uniapi_drop_party_ack_indication *ind;
893 if (u->u.status.epstate.state == UNI_EPSTATE_NULL) {
894 ind = ALLOC_API(struct uniapi_drop_party_ack_indication, api);
896 ind->drop.hdr = u->u.hdr;
897 ind->drop.cause = u->u.status.cause;
898 ind->drop.epref = u->u.status.epref;
899 uni_enq_call(p->call, SIGC_DROP_PARTY_ACK_indication,
902 TIMER_STOP_PARTY(p, t398);
904 uni_destroy_party(p, 0);
911 /************************************************************/
914 uni_sig_party(struct party *p, enum party_sig sig, uint32_t cookie,
915 struct uni_msg *msg, struct uni_all *u)
917 if (sig >= SIGP_END) {
918 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
919 "Signal %d outside of range to Party-Control", sig);
921 uni_msg_destroy(msg);
926 VERBOSE(p->call->uni, UNI_FAC_CALL, 1,
927 "Signal %s in state %u of party %u/%s (call %u/%s in state %s)"
928 "; cookie %u", party_sigs[sig], p->state, p->epref,
929 (p->flags & PARTY_MINE) ? "mine" : "his", p->call->cref,
930 p->call->mine ? "mine" : "his", callstates[p->call->cstate].name,
935 case SIGP_PARTY_DELETE:
943 if (p->state == UNI_EPSTATE_NULL) {
944 /* Q.2971:Call-Control-U 3/13 */
945 /* Q.2971:Call-Control-N 3/13 */
946 set_party_state(p, UNI_EPSTATE_ADD_RCVD);
949 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
950 "SETUP in ps=%u", p->state);
954 if (p->state == UNI_EPSTATE_ADD_INIT) {
955 /* Q.2971:Call-Control-U 14 */
956 /* Q.2971:Call-Control-N 5 */
957 TIMER_START_PARTY(p, t397, p->call->uni->timer397);
958 set_party_state(p, UNI_EPSTATE_ALERT_RCVD);
961 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
962 "ALERTING in ps=%u", p->state);
966 if (p->state == UNI_EPSTATE_ADD_INIT) {
967 /* Q.2971:Call-Control-U 4/13 */
968 TIMER_STOP_PARTY(p, t399);
969 set_party_state(p, UNI_EPSTATE_ACTIVE);
972 if (p->state == UNI_EPSTATE_ALERT_RCVD) {
973 /* Q.2971:Call-Control-U 7/13 */
974 TIMER_STOP_PARTY(p, t397);
975 set_party_state(p, UNI_EPSTATE_ACTIVE);
978 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
979 "CONNECT in ps=%u", p->state);
982 case SIGP_CONNECT_ACK:
983 if (p->state == UNI_EPSTATE_ADD_RCVD ||
984 p->state == UNI_EPSTATE_ALERT_DLVD) {
985 /* Q.2971:Call-Control-U 6/13 */
986 /* Q.2971:Call-Control-U 7/13 */
987 p->flags &= ~PARTY_CONNECT;
988 set_party_state(p, UNI_EPSTATE_ACTIVE);
991 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
992 "CONNECT in ps=%u", p->state);
996 if (p->state == UNI_EPSTATE_DROP_INIT) {
997 /* Q.2971:Party-Control-U 10/14 */
998 /* Q.2971:Party-Control-N 10/14 */
999 TIMER_STOP_PARTY(p, t398);
1000 uni_destroy_party(p, 0);
1003 /* Q.2971:Party-Control-U 11/14 */
1004 /* Q.2971:Party-Control-N 11/14 */
1005 TIMER_STOP_PARTY(p, t397);
1006 TIMER_STOP_PARTY(p, t399);
1007 uni_destroy_party(p, 0);
1010 case SIGP_RELEASE_COMPL:
1011 /* Q.2971:Party-Control-U 11/14 */
1012 /* Q.2971:Party-Control-N 11/14 */
1013 stop_all_party_timers(p);
1014 uni_destroy_party(p, 0);
1017 case SIGP_RELEASE_confirm:
1018 /* not in the SDLs */
1019 stop_all_party_timers(p);
1020 uni_destroy_party(p, 0);
1023 case SIGP_RELEASE_request:
1024 if (p->state == UNI_EPSTATE_DROP_INIT) {
1025 /* Q.2971:Party-Control-U 10 */
1026 /* Q.2971:Party-Control-N 10 */
1027 uni_destroy_party(p, 0);
1030 /* Q.2971:Party-Control-U 11 */
1031 /* Q.2971:Party-Control-N 11 */
1032 TIMER_STOP_PARTY(p, t397);
1033 TIMER_STOP_PARTY(p, t399);
1034 uni_destroy_party(p, 0);
1037 case SIGP_RELEASE_response:
1038 /* Q.2971:Party-Control-U 11 */
1039 /* Q.2971:Party-Control-N 11 */
1040 stop_all_party_timers(p);
1041 uni_destroy_party(p, 0);
1044 case SIGP_ADD_PARTY:
1045 if (p->state == UNI_EPSTATE_NULL) {
1046 /* Q.2971:Party-Control-U 3 PU0 */
1047 /* Q.2971:Party-Control-N 3 PN0 */
1048 pun0_add_party(p, msg, u);
1051 if (p->state == UNI_EPSTATE_ADD_RCVD) {
1052 /* Q.2971:Party-Control-U 6 PU2 */
1053 /* Q.2971:Party-Control-N 6 PN2 */
1054 uni_msg_destroy(msg);
1058 uni_bad_message(p->call, u, UNI_CAUSE_MSG_INCOMP,
1059 &u->u.add_party.epref, p->state);
1060 uni_msg_destroy(msg);
1064 case SIGP_PARTY_ALERTING:
1065 if (p->state == UNI_EPSTATE_ADD_INIT) {
1066 /* Q.2971:Party-Control-U 14 */
1067 /* Q.2971:Party-Control-N 5 */
1068 pun1_party_alerting(p, msg, u);
1071 uni_bad_message(p->call, u, UNI_CAUSE_MSG_INCOMP,
1072 &u->u.party_alerting.epref, p->state);
1073 uni_msg_destroy(msg);
1077 case SIGP_ADD_PARTY_ACK:
1078 if (p->state == UNI_EPSTATE_ADD_INIT ||
1079 p->state == UNI_EPSTATE_ALERT_RCVD) {
1080 /* Q.2971:Party-Control-U 4 (PU1) */
1081 /* Q.2971:Party-Control-U 7 (PU4) */
1082 /* Q.2971:Party-Control-N 4 (PN1) */
1083 /* Q.2971:Party-Control-N 7 (PN4) */
1084 pun1pun4_add_party_ack(p, msg, u);
1087 uni_bad_message(p->call, u, UNI_CAUSE_MSG_INCOMP,
1088 &u->u.add_party_ack.epref, p->state);
1089 uni_msg_destroy(msg);
1093 case SIGP_ADD_PARTY_REJ:
1094 if (p->state == UNI_EPSTATE_ADD_INIT) {
1095 /* Q.2971:Party-Control-U 4 (PU1) */
1096 /* Q.2971:Party-Control-N 4 (PN1) */
1097 pun1_add_party_rej(p, msg, u);
1100 if (p->state == UNI_EPSTATE_DROP_INIT) {
1101 /* Q.2971:Party-Control-U 10 (PU5) */
1102 /* Q.2971:Party-Control-N 10 (PN5) */
1103 pun5_add_party_rej(p, msg, u);
1106 uni_bad_message(p->call, u, UNI_CAUSE_MSG_INCOMP,
1107 &u->u.add_party_rej.epref, p->state);
1108 uni_msg_destroy(msg);
1112 case SIGP_DROP_PARTY_ACK:
1113 /* Q.2971:Party-Control-U 8 */
1114 /* Q.2971:Party-Control-N 8 */
1115 punx_drop_party_ack(p, msg, u);
1118 case SIGP_DROP_PARTY:
1119 if (p->state == UNI_EPSTATE_DROP_INIT)
1120 /* Q.2971:Party-Control-U 10 */
1121 /* Q.2971:Party-Control-N 10 */
1122 pun5_drop_party(p, msg, u);
1124 /* Q.2971:Party-Control-U 9 */
1125 /* Q.2971:Party-Control-N 9 */
1126 punx_drop_party(p, msg, u);
1130 if (p->state == UNI_EPSTATE_DROP_INIT)
1131 /* Q.2971:Party-Control-U 10 */
1132 /* Q.2971:Party-Control-N 10 */
1133 pun5_status(p, msg, u);
1135 /* Q.2971:Party-Control-U 12 */
1136 /* Q.2971:Party-Control-N 12 */
1137 punx_status(p, msg, u);
1143 case SIGP_SETUP_request:
1144 if (p->state == UNI_EPSTATE_NULL) {
1145 /* Q.2971:Party-Control-U 3 */
1146 /* Q.2971:Party-Control-N 3 */
1147 set_party_state(p, UNI_EPSTATE_ADD_INIT);
1150 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1151 "SETUP.request in ps=%u", p->state);
1152 uniapi_party_error(p, UNIAPI_ERROR_BAD_EPSTATE, cookie);
1155 case SIGP_SETUP_response:
1156 if (p->state == UNI_EPSTATE_ADD_RCVD ||
1157 p->state == UNI_EPSTATE_ALERT_DLVD) {
1158 /* Q.2971:Party-Control-N 6 (PN2) */
1159 /* Q.2971:Party-Control-N 7 (PN3) */
1160 set_party_state(p, UNI_EPSTATE_ACTIVE);
1163 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1164 "SETUP.response in ps=%u", p->state);
1165 uniapi_party_error(p, UNIAPI_ERROR_BAD_EPSTATE, cookie);
1168 case SIGP_SETUP_COMPL_request:
1169 if (p->state == UNI_EPSTATE_ADD_INIT) {
1170 /* Q.2971:Party-Control-N 4 */
1171 TIMER_STOP_PARTY(p, t399);
1172 set_party_state(p, UNI_EPSTATE_ACTIVE);
1175 if (p->state == UNI_EPSTATE_ALERT_RCVD) {
1176 /* Q.2971:Party-Control-N 7 */
1177 TIMER_STOP_PARTY(p, t397);
1178 set_party_state(p, UNI_EPSTATE_ACTIVE);
1181 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1182 "SETUP_COMPL.request in ps=%u", p->state);
1183 uniapi_party_error(p, UNIAPI_ERROR_BAD_EPSTATE, cookie);
1186 case SIGP_ADD_PARTY_request:
1187 if (p->state == UNI_EPSTATE_NULL) {
1188 /* Q.2971:Party-control-U 3 (PU0) */
1189 /* Q.2971:Party-control-N 3 (PN0) */
1190 pun0_add_party_request(p, msg, cookie);
1193 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1194 "Add-party.request in ps=%u", p->state);
1195 uniapi_party_error(p, UNIAPI_ERROR_BAD_EPSTATE, cookie);
1196 uni_msg_destroy(msg);
1199 case SIGP_ALERTING_request:
1200 /* Q.2971:Party-Control-U 6 (PU2) */
1201 /* Q.2971:Party-Control-N 6 (PN2) */
1202 set_party_state(p, UNI_EPSTATE_ALERT_DLVD);
1205 case SIGP_PARTY_ALERTING_request:
1206 if (p->state == UNI_EPSTATE_ADD_RCVD) {
1207 /* Q.2971:Party-Control-U 6 (PU2) */
1208 /* Q.2971:Party-Control-N 6 (PN2) */
1209 pun2_party_alerting_request(p, msg, cookie);
1212 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1213 "Party-alerting.request in ps=%u", p->state);
1214 uniapi_party_error(p, UNIAPI_ERROR_BAD_EPSTATE, cookie);
1215 uni_msg_destroy(msg);
1218 case SIGP_ADD_PARTY_ACK_request:
1219 if (p->state == UNI_EPSTATE_ADD_RCVD ||
1220 p->state == UNI_EPSTATE_ALERT_DLVD) {
1221 /* Q.2971:Party-Control-U 6 PU2 */
1222 /* Q.2971:Party-Control-U 7 PU3 */
1223 /* Q.2971:Party-Control-N 6 PN2 */
1224 /* Q.2971:Party-Control-N 7 PN3 */
1225 punx_add_party_ack_request(p, msg, cookie);
1228 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1229 "Add-party-ack.request in ps=%u", p->state);
1230 uniapi_party_error(p, UNIAPI_ERROR_BAD_EPSTATE, cookie);
1231 uni_msg_destroy(msg);
1234 case SIGP_ADD_PARTY_REJ_request:
1235 if (p->state == UNI_EPSTATE_ADD_RCVD) {
1236 /* Q.2971:Party-Control-U 6 PU2 */
1237 /* Q.2971:Party-Control-N 6 PN2 */
1238 pun2_add_party_rej_request(p, msg, cookie);
1241 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1242 "Add-party-rej.request in ps=%u", p->state);
1243 uniapi_party_error(p, UNIAPI_ERROR_BAD_EPSTATE, cookie);
1244 uni_msg_destroy(msg);
1247 case SIGP_DROP_PARTY_request:
1248 if (p->state == UNI_EPSTATE_ADD_INIT ||
1249 p->state == UNI_EPSTATE_ALERT_DLVD ||
1250 p->state == UNI_EPSTATE_ALERT_RCVD ||
1251 p->state == UNI_EPSTATE_ACTIVE) {
1252 /* Q.2971:Party-Control-U 8 */
1253 /* Q.2971:Party-Control-N 8 */
1254 punx_drop_party_request(p, msg, cookie);
1257 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1258 "Drop-party.request in ps=%u", p->state);
1259 uniapi_party_error(p, UNIAPI_ERROR_BAD_EPSTATE, cookie);
1260 uni_msg_destroy(msg);
1263 case SIGP_DROP_PARTY_ACK_request:
1264 if (p->state == UNI_EPSTATE_DROP_RCVD) {
1265 /* Q.2971:Party-Control-U 9 */
1266 /* Q.2971:Party-Control-N 9 */
1267 pun6_drop_party_ack_request(p, msg, cookie);
1270 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1271 "Drop-party-ack.request in ps=%u", p->state);
1272 uniapi_party_error(p, UNIAPI_ERROR_BAD_EPSTATE, cookie);
1273 uni_msg_destroy(msg);
1276 case SIGP_STATUS_ENQUIRY_request:
1277 /* Q.2971:Party-Control-U 12 */
1278 /* Q.2971:Party-Control-N 12 */
1279 punx_status_enquiry_request(p, cookie);
1286 if (p->state == UNI_EPSTATE_ALERT_RCVD) {
1287 /* Q.2971:Party-Control-U 7 (PU4) */
1288 /* Q.2971:Party-Control-N 7 (PN4) */
1292 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1293 "T397 in ps=%u", p->state);
1297 if (p->state == UNI_EPSTATE_DROP_INIT) {
1298 /* Q.2971:Party-Control-U 10 (PU5) */
1299 /* Q.2971:Party-Control-N 10 (PN5) */
1303 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1304 "T398 in ps=%u", p->state);
1308 if (p->state == UNI_EPSTATE_ADD_INIT) {
1309 /* Q.2971:Party-Control-U 4 (PU1) */
1310 /* Q.2971:Party-Control-N 4 (PN1) */
1314 VERBOSE(p->call->uni, UNI_FAC_ERR, 1,
1315 "T399 in ps=%u", p->state);
1324 t397_func(struct party *p)
1326 uni_enq_party(p, SIGP_T397, 0, NULL, NULL);
1329 t398_func(struct party *p)
1331 uni_enq_party(p, SIGP_T398, 0, NULL, NULL);
1334 t399_func(struct party *p)
1336 uni_enq_party(p, SIGP_T399, 0, NULL, NULL);
1340 epstate_compat(struct party *p, enum uni_epstate state)
1342 if (p->state == UNI_EPSTATE_ADD_INIT ||
1343 p->state == UNI_EPSTATE_ALERT_RCVD)
1344 if (state == UNI_EPSTATE_ADD_INIT ||
1345 state == UNI_EPSTATE_ALERT_RCVD)
1347 if (p->state == UNI_EPSTATE_ADD_RCVD ||
1348 p->state == UNI_EPSTATE_ALERT_DLVD)
1349 if (state == UNI_EPSTATE_ADD_RCVD ||
1350 state == UNI_EPSTATE_ALERT_DLVD)