soa_tag.c 14.2 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

/**@CFILE soa_tag.c  Tags and tag lists for Offer/Answer Engine
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 *
 * @date Created: Wed Aug  3 20:28:17 EEST 2005
 */

#include "config.h"

34
#include <sofia-sip/su.h>
Pekka Pessi's avatar
Pekka Pessi committed
35 36 37

#define TAG_NAMESPACE "soa"

38 39 40
#include <sofia-sip/soa.h>
#include <sofia-sip/su_tag_class.h>
#include <sofia-sip/sdp_tag.h>
Pekka Pessi's avatar
Pekka Pessi committed
41

42 43 44 45 46 47
/**@def SOATAG_ANY()
 * 
 * Filter tag matching any SOATAG_*() item.
 */
tag_typedef_t soatag_any = NSTAG_TYPEDEF(*);

Pekka Pessi's avatar
Pekka Pessi committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
/**@def SOATAG_CAPS_SDP(x)
 *  Pass parsed capability description to soa session object.
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_create()
 *
 * @par Parameter type
 *    char const *
 *
 * @par Values
 *    NULL terminated character string
 *
 * Corresponding tag taking reference parameter is SOATAG_CAPS_SDP_REF()
 */
64
tag_typedef_t soatag_caps_sdp = SDPTAG_TYPEDEF(caps_sdp);
Pekka Pessi's avatar
Pekka Pessi committed
65

Pekka Pessi's avatar
Pekka Pessi committed
66
/**@def SOATAG_CAPS_SDP_STR(x)
Pekka Pessi's avatar
Pekka Pessi committed
67
 *  Pass capability description to soa session object.
Pekka Pessi's avatar
Pekka Pessi committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
 *
 * Pass name of media description file that contains media templates
 * (normally mss.sdp) to the NUA stack.
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_create()
 *
 * @par Parameter type
 *    char const *
 *
 * @par Values
 *    NULL terminated character string
 *
 * Corresponding tag taking reference parameter is SOATAG_CAPS_SDP_STR_REF()
 */
tag_typedef_t soatag_caps_sdp_str = STRTAG_TYPEDEF(caps_sdp_str);

87
/**@def SOATAG_LOCAL_SDP(x)
Pekka Pessi's avatar
Pekka Pessi committed
88
 *  Get parsed local session description from soa session object.
89 90 91 92 93 94 95 96 97 98 99 100
 *
 * @par Used with
 *    soa_set_params(), soa_get_params(), soa_get_paramlist() \n
 *
 * @par Parameter type
 *    char const *
 *
 * @par Values
 *    pointer to #sdp_session_t.
 *
 * Corresponding tag taking reference parameter is SOATAG_LOCAL_SDP_REF()
 */
101
tag_typedef_t soatag_local_sdp = SDPTAG_TYPEDEF(local_sdp);
102

Pekka Pessi's avatar
Pekka Pessi committed
103
/**@def SOATAG_LOCAL_SDP_STR(x)
Pekka Pessi's avatar
Pekka Pessi committed
104
 * Get local session description as a string from soa session object.
Pekka Pessi's avatar
Pekka Pessi committed
105 106
 *
 * @par Used with
Pekka Pessi's avatar
Pekka Pessi committed
107
 * soa_set_paramas(), soa_get_params(), soa_get_paramlist().
Pekka Pessi's avatar
Pekka Pessi committed
108 109
 *
 * @par Parameter type
Pekka Pessi's avatar
Pekka Pessi committed
110
 * char const *
Pekka Pessi's avatar
Pekka Pessi committed
111 112
 *
 * @par Values
Pekka Pessi's avatar
Pekka Pessi committed
113
 * NULL terminated character string
Pekka Pessi's avatar
Pekka Pessi committed
114 115 116 117 118
 *
 * Corresponding tag taking reference parameter is SOATAG_LOCAL_SDP_STR_REF()
 */
tag_typedef_t soatag_local_sdp_str = STRTAG_TYPEDEF(local_sdp_str);

119 120 121 122 123 124 125 126 127 128 129 130 131 132
/**@def SOATAG_REMOTE_SDP(x)
 *  Pass parsed remote session description to soa session object.
 *
 * @par Used with
 *    soa_set_params(), soa_get_params(), soa_get_paramlist() \n
 *
 * @par Parameter type
 *    char const *
 *
 * @par Values
 *    pointer to #sdp_session_t.
 *
 * Corresponding tag taking reference parameter is SOATAG_REMOTE_SDP_REF()
 */
133
tag_typedef_t soatag_remote_sdp = SDPTAG_TYPEDEF(remote_sdp);
134

Pekka Pessi's avatar
Pekka Pessi committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
/**@def SOATAG_REMOTE_SDP_STR(x)
 *  Pass media description file name to the NUA stack.
 *
 * Pass name of media description file that contains media templates
 * (normally mss.sdp) to the NUA stack.
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_create()
 *
 * @par Parameter type
 *    char const *
 *
 * @par Values
 *    NULL terminated character string
 *
 * Corresponding tag taking reference parameter is SOATAG_REMOTE_SDP_STR_REF()
 */
tag_typedef_t soatag_remote_sdp_str = STRTAG_TYPEDEF(remote_sdp_str);

Pekka Pessi's avatar
Pekka Pessi committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169
/**@def SOATAG_USER_SDP(x)
 *  Pass parsed user session description to soa session object.
 *
 * @par Used with
 *    soa_set_params(), soa_get_params(), soa_get_paramlist() \n
 *
 * @par Parameter type
 *    char const *
 *
 * @par Values
 *    pointer to #sdp_session_t.
 *
 * Corresponding tag taking reference parameter is SOATAG_USER_SDP_REF()
 */
170
tag_typedef_t soatag_user_sdp = SDPTAG_TYPEDEF(user_sdp);
Pekka Pessi's avatar
Pekka Pessi committed
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192

/**@def SOATAG_USER_SDP_STR(x)
 *  Pass media description file name to the NUA stack.
 *
 * Pass name of media description file that contains media templates
 * (normally mss.sdp) to the NUA stack.
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_create()
 *
 * @par Parameter type
 *    char const *
 *
 * @par Values
 *    NULL terminated character string
 *
 * Corresponding tag taking reference parameter is SOATAG_USER_SDP_STR_REF()
 */
tag_typedef_t soatag_user_sdp_str = STRTAG_TYPEDEF(user_sdp_str);

Pekka Pessi's avatar
Pekka Pessi committed
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
/**@def SOATAG_AF(x)
 *
 * Preferred address family for media.
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_invite() \n
 *    nua_respond()
 *
 * @par Parameter type
 *    unsigned int
 *
 * @par Values
 *    @c SOATAG_AF_ANY (default) (0) any address family \n
 *    @c SOATAG_AF_IP4_ONLY      (1) only IP version 4 \n
 *    @c SOATAG_AF_IP6_ONLY      (2) only IP version 6 \n
 *    @c SOATAG_AF_IP4_IP6       (3) either IP version 4 or 6,
 *                                  version 4 preferred \n
 *    @c SOATAG_AF_IP6_IP4       (4) either IP version 4 or 6,
 *                                  version 6 preferred
 *
 * Corresponding tag taking reference parameter is SOATAG_AF_REF()
 */
tag_typedef_t soatag_af = INTTAG_TYPEDEF(af);


Pekka Pessi's avatar
Pekka Pessi committed
220
/**@def SOATAG_ADDRESS(x)
Pekka Pessi's avatar
Pekka Pessi committed
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
 *
 * Pass media address.
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_invite() \n
 *    nua_respond()
 *
 * @par Parameter type
 *    char const *
 *
 * @par Values
 *    NULL terminated character string containing a domain name,
 *    IPv4 address, or IPv6 address.
 *
 * Corresponding tag taking reference parameter is SOATAG_ADDRESS_REF()
238
 */
Pekka Pessi's avatar
Pekka Pessi committed
239 240
tag_typedef_t soatag_address = STRTAG_TYPEDEF(address);

241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268

/**@def SOATAG_RTP_SELECT(x)
 *
 * When generating answer or second offer, soa can include all the supported
 * codec, only one codec, or only the codecs supported by both ends in the
 * list of payload types on the m= line.
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_invite() \n
 *    nua_update() \n
 *    nua_respond() \n
 *
 * @par Parameter type
 *    integer in range 0..2
 *
 * @par Values
 *    0 - select the best common codec        \n
 *    1 - select all common codecs            \n
 *    2 - select all local codecs             \n
 *
 * The default value is 0, only one RTP codec is selected. Note, however,
 * that if there is no common codec (no local codec is supported by remote
 * end), all the codecs are included in the list. In that case the media
 * line is rejected, too, unless SOATAG_RTP_MISMATCH(1) has been used.
 *
 * Corresponding tag taking a reference parameter is SOATAG_RTP_SELECT_REF()
269
 */
270 271 272
tag_typedef_t soatag_rtp_select = UINTTAG_TYPEDEF(rtp_select);


273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
/**@def SOATAG_AUDIO_AUX(x)
 *
 * The named audio codecs are considered auxiliary, that is, they are
 * considered as common codec only when they are the only codec listed on
 * the media line.
 * 
 * When generating answer or second offer soa includes auxiliary audio codecs in
 * the list of codecs even if it is selecting only one codec or common
 * codecs.
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_invite() \n
 *    nua_update() \n
 *    nua_respond() \n
 *
 * @par Parameter type
 *    A string with whitespace separated list of codec names.
 *
 * @par Values
 *    E.g., "telephone-event cn".
 *
 * By default, there are no auxiliary audio codecs.
 *
 * Corresponding tag taking a reference parameter is
 * SOATAG_AUDIO_AUX_REF()
 */
tag_typedef_t soatag_audio_aux = STRTAG_TYPEDEF(audio_aux);

303 304 305 306 307 308
/**@def SOATAG_RTP_SORT(x)
 *
 * When selecting the common codecs, soa can either select first local codec
 * supported by remote end, or first remote codec supported by local codecs. 
 * The preference is indicated with ordering: the preferred codec is
 * first and so on.
309
 *
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_invite() \n
 *    nua_update() \n
 *    nua_respond() \n
 *
 * @par Parameter type
 *    Boolean (int)
 *
 * @par Values
 *    0 - select by local preference if media is recvonly, 
 *        remote preference othewise \n
 *    1 - always select by local preference \n
 *    2 - always select by remote preference \n
 *
 * The default value is 0.
 *
 * Corresponding tag taking reference parameter is SOATAG_RTP_SORT_REF()
*/
tag_typedef_t soatag_rtp_sort = UINTTAG_TYPEDEF(rtp_sort);


/**@def SOATAG_RTP_MISMATCH(x)
 *
 * Accept media line even if the SDP negotation code determines that there
 * are no common codecs between local and remote media. Normally, if the soa
 * determines there are no common codecs, the media line is rejected.
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_invite() \n
 *    nua_update() \n
 *    nua_respond() \n
 *
 * @par Parameter type
 *    Boolean (int)
 *
 * @par Values
 *    0 - reject media if there are no common codecs \n
 *    1 (!= 0) - accept media even if there are no common codecs \n
 *
 * Default value is 0.
 *
 * Corresponding tag taking reference parameter is SOATAG_RTP_MISMATCH_REF()
*/
tag_typedef_t soatag_rtp_mismatch = BOOLTAG_TYPEDEF(rtp_mismatch);


Pekka Pessi's avatar
Pekka Pessi committed
360 361 362 363 364 365 366
/**@def SOATAG_ACTIVE_AUDIO(x)
 * 
 * Audio session status
 *
 * @par Used with
 *
 * @par Parameter type
Pekka Pessi's avatar
Pekka Pessi committed
367 368 369
 *    enum { #SOA_ACTIVE_DISABLED, #SOA_ACTIVE_REJECTED, 
 *           #SOA_ACTIVE_INACTIVE, #SOA_ACTIVE_SENDONLY, 
 *           #SOA_ACTIVE_RECVONLY, #SOA_ACTIVE_SENDRECV }
Pekka Pessi's avatar
Pekka Pessi committed
370 371
 *
 * @par Values
Pekka Pessi's avatar
Pekka Pessi committed
372 373 374 375 376
 *    @c #SOA_ACTIVE_REJECTED  (-8) \n
 *    @c #SOA_ACTIVE_INACTIVE  (0) \n
 *    @c #SOA_ACTIVE_SENDONLY  (1) \n
 *    @c #SOA_ACTIVE_RECVONLY  (2) \n
 *    @c #SOA_ACTIVE_SENDRECV  (3) \n
Pekka Pessi's avatar
Pekka Pessi committed
377 378 379 380 381 382 383 384 385 386 387 388 389
 *
 *  Corresponding tag taking reference parameter is SOATAG_ACTIVE_AUDIO_REF()
 *
 */
tag_typedef_t soatag_active_audio = INTTAG_TYPEDEF(active_audio);

/**@def SOATAG_ACTIVE_VIDEO(x)
 * 
 * Video session status
 *
 * @par Used with
 *
 * @par Parameter type
Pekka Pessi's avatar
Pekka Pessi committed
390 391 392
 *    enum { #SOA_ACTIVE_DISABLED, #SOA_ACTIVE_REJECTED, 
 *           #SOA_ACTIVE_INACTIVE, #SOA_ACTIVE_SENDONLY, 
 *           #SOA_ACTIVE_RECVONLY, #SOA_ACTIVE_SENDRECV }
Pekka Pessi's avatar
Pekka Pessi committed
393 394
 *
 * @par Values
Pekka Pessi's avatar
Pekka Pessi committed
395 396 397 398 399
 *    @c #SOA_ACTIVE_REJECTED  (-8) \n
 *    @c #SOA_ACTIVE_INACTIVE  (0) \n
 *    @c #SOA_ACTIVE_SENDONLY  (1) \n
 *    @c #SOA_ACTIVE_RECVONLY  (2) \n
 *    @c #SOA_ACTIVE_SENDRECV  (3) \n
Pekka Pessi's avatar
Pekka Pessi committed
400 401 402 403 404 405 406 407 408 409 410 411 412 413
 *
 * Corresponding tag taking reference parameter is SOATAG_ACTIVE_VIDEO_REF()
 */
tag_typedef_t soatag_active_video = INTTAG_TYPEDEF(active_video);

/**@def SOATAG_ACTIVE_IMAGE(x)
 * 
 * Active image session status
 *
 * @par Used with
 *    #nua_i_active \n
 *    #nua_i_state \n
 *
 * @par Parameter type
Pekka Pessi's avatar
Pekka Pessi committed
414 415 416
 *    enum { #SOA_ACTIVE_DISABLED, #SOA_ACTIVE_REJECTED, 
 *           #SOA_ACTIVE_INACTIVE, #SOA_ACTIVE_SENDONLY, 
 *           #SOA_ACTIVE_RECVONLY, #SOA_ACTIVE_SENDRECV }
Pekka Pessi's avatar
Pekka Pessi committed
417 418
 *
 * @par Values
Pekka Pessi's avatar
Pekka Pessi committed
419 420 421 422 423
 *    @c #SOA_ACTIVE_REJECTED  (-8) \n
 *    @c #SOA_ACTIVE_INACTIVE  (0) \n
 *    @c #SOA_ACTIVE_SENDONLY  (1) \n
 *    @c #SOA_ACTIVE_RECVONLY  (2) \n
 *    @c #SOA_ACTIVE_SENDRECV  (3) \n
Pekka Pessi's avatar
Pekka Pessi committed
424 425
 *
 * @par Parameter type
Pekka Pessi's avatar
Pekka Pessi committed
426 427 428
 *    enum { #SOA_ACTIVE_DISABLED, #SOA_ACTIVE_REJECTED, 
 *           #SOA_ACTIVE_INACTIVE, #SOA_ACTIVE_SENDONLY, 
 *           #SOA_ACTIVE_RECVONLY, #SOA_ACTIVE_SENDRECV }
Pekka Pessi's avatar
Pekka Pessi committed
429 430
 *
 * @par Values
Pekka Pessi's avatar
Pekka Pessi committed
431 432 433 434 435
 *    @c #SOA_ACTIVE_REJECTED  (-8) \n
 *    @c #SOA_ACTIVE_INACTIVE  (0) \n
 *    @c #SOA_ACTIVE_SENDONLY  (1) \n
 *    @c #SOA_ACTIVE_RECVONLY  (2) \n
 *    @c #SOA_ACTIVE_SENDRECV  (3) \n
Pekka Pessi's avatar
Pekka Pessi committed
436 437 438 439 440 441 442 443 444 445 446 447
 *
 * Corresponding tag taking reference parameter is SOATAG_ACTIVE_IMAGE_REF()
 */
tag_typedef_t soatag_active_image = INTTAG_TYPEDEF(active_image);

/**@def SOATAG_ACTIVE_CHAT(x)
 * 
 *  Active chat session status
 *
 * @par Used with
 *
 * @par Parameter type
Pekka Pessi's avatar
Pekka Pessi committed
448 449 450
 *    enum { #SOA_ACTIVE_DISABLED, #SOA_ACTIVE_REJECTED, 
 *           #SOA_ACTIVE_INACTIVE, #SOA_ACTIVE_SENDONLY, 
 *           #SOA_ACTIVE_RECVONLY, #SOA_ACTIVE_SENDRECV }
Pekka Pessi's avatar
Pekka Pessi committed
451 452
 *
 * @par Values
Pekka Pessi's avatar
Pekka Pessi committed
453 454 455 456 457
 *    @c #SOA_ACTIVE_REJECTED  (-8) \n
 *    @c #SOA_ACTIVE_INACTIVE  (0) \n
 *    @c #SOA_ACTIVE_SENDONLY  (1) \n
 *    @c #SOA_ACTIVE_RECVONLY  (2) \n
 *    @c #SOA_ACTIVE_SENDRECV  (3) \n
Pekka Pessi's avatar
Pekka Pessi committed
458 459 460 461 462
 *
 * Corresponding tag taking reference parameter is SOATAG_ACTIVE_CHAT_REF()
 */
tag_typedef_t soatag_active_chat = INTTAG_TYPEDEF(active_chat);

Pekka Pessi's avatar
Pekka Pessi committed
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
/**@def SOATAG_SRTP_ENABLE(x)
 *  
 * Enable SRTP
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_invite() \n
 *    nua_respond()
 *
 * @par Parameter type
 *    unsigned int
 *
 * @par Values
 *    @c 1 hold call \n
 *    @c 0 unhold call
 *
 * Corresponding tag taking reference parameter is 
 * SOATAG_SRTP_ENABLE_REF()
 */
tag_typedef_t soatag_srtp_enable = BOOLTAG_TYPEDEF(srtp_enable);

/**@def SOATAG_SRTP_CONFIDENTIALITY(x)
 *  
 * Enable SRTP confidentiality
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_invite() \n
 *    nua_respond()
 *
 * @par Parameter type
 *    int
 *
 * @par Values
 *    @c 1 hold call \n
 *    @c 0 unhold call
 *
 * Corresponding tag taking reference parameter is 
 * SOATAG_SRTP_CONFIDENTIALITY_REF()
 */
tag_typedef_t soatag_srtp_confidentiality = 
  BOOLTAG_TYPEDEF(srtp_confidentiality);

/**@def SOATAG_SRTP_INTEGRITY(x)
 *  
 * Enable SRTP integrity protection
 *
 * @par Used with
 *    nua_set_params() \n
 *    nua_get_params() \n
 *    nua_invite() \n
 *    nua_respond()
 *
 * @par Parameter type
 *    int
 *
 * @par Values
 *    @c !=0 enable
 *    @c 0 disable
 *
 * Corresponding tag taking reference parameter is 
 * SOATAG_SRTP_INTEGRITY_REF()
 */
tag_typedef_t soatag_srtp_integrity = BOOLTAG_TYPEDEF(srtp_integrity);

/**@def SOATAG_HOLD(x)
 *  Hold & unhold
 *
 * @par Used with
 *    nua_invite() \n
 *    nua_update()
 *
 * @par Parameter type
 *    unsigned int
 *
 * @par Values
 *    @c 1 hold call \n
 *    @c 0 unhold call
 *
 * Corresponding tag taking reference parameter is SOATAG_HOLD_REF()
 */
Pekka Pessi's avatar
Pekka Pessi committed
546
tag_typedef_t soatag_hold = STRTAG_TYPEDEF(hold);