This file is indexed.

/usr/include/osip2/osip.h is in libosip2-dev 4.0.0-3ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   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
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 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
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 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
 269
 270
 271
 272
 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
 303
 304
 305
 306
 307
 308
 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
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 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
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
/*
  The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
  Copyright (C) 2001-2012 Aymeric MOIZARD amoizard@antisip.com
  
  This library is free software; you can redistribute it and/or
  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/


#ifndef _OSIP_H_
#define _OSIP_H_

#if defined(HAVE_DICT_DICT_H)
#include <dict/dict.h>
#endif

#include <osipparser2/osip_const.h>

/* Time-related functions and data types */
#include <osip2/osip_time.h>

#ifdef __sun
#include <sys/types.h>
#endif

#include <osipparser2/osip_parser.h>
#include <osip2/osip_fifo.h>

/**
 * @file osip.h
 * @brief oSIP fsm Routines
 *
 */

/**
 * @defgroup oSIP_FSM oSIP fsm Handling
 * @ingroup osip2_fsm
 * @{
 */

#ifdef __cplusplus
extern "C" {
#endif


/**
 * Enumeration for transaction state.
 * Those states are extracted from the diagram found in rfc3261.txt
 *
 */
  typedef enum _state_t {
    /* STATES for invite client transaction */
    ICT_PRE_CALLING,
    ICT_CALLING,
    ICT_PROCEEDING,
    ICT_COMPLETED,
    ICT_TERMINATED,

    /* STATES for invite server transaction */
    IST_PRE_PROCEEDING,
    IST_PROCEEDING,
    IST_COMPLETED,
    IST_CONFIRMED,
    IST_TERMINATED,

    /* STATES for NON-invite client transaction */
    NICT_PRE_TRYING,
    NICT_TRYING,
    NICT_PROCEEDING,
    NICT_COMPLETED,
    NICT_TERMINATED,

    /* STATES for NON-invite server transaction */
    NIST_PRE_TRYING,
    NIST_TRYING,
    NIST_PROCEEDING,
    NIST_COMPLETED,
    NIST_TERMINATED,

#ifndef DOXYGEN
    DIALOG_EARLY,
    DIALOG_CONFIRMED,
    DIALOG_CLOSE                /* ?? */
#endif
  } state_t;

/**
 * Enumeration for event type.
 * <BR>The list of values that you need to know is reduced to this:
 * <BR> RCV_REQINVITE,
 * <BR> RCV_REQACK,
 * <BR> RCV_REQUEST,
 * <BR> RCV_STATUS_1XX,
 * <BR> RCV_STATUS_2XX,
 * <BR> RCV_STATUS_3456XX,
 *<BR>
 * <BR> SND_REQINVITE,
 * <BR> SND_REQACK,
 * <BR> SND_REQUEST,
 * <BR> SND_STATUS_1XX,
 * <BR> SND_STATUS_2XX,
 * <BR> SND_STATUS_3456XX,
 */
  typedef enum type_t {
    /* TIMEOUT EVENTS for ICT */
    TIMEOUT_A,                   /**< Timer A */
    TIMEOUT_B,                   /**< Timer B */
    TIMEOUT_D,                   /**< Timer D */

    /* TIMEOUT EVENTS for NICT */
    TIMEOUT_E,                   /**< Timer E */
    TIMEOUT_F,                   /**< Timer F */
    TIMEOUT_K,                   /**< Timer K */

    /* TIMEOUT EVENTS for IST */
    TIMEOUT_G,                   /**< Timer G */
    TIMEOUT_H,                   /**< Timer H */
    TIMEOUT_I,                   /**< Timer I */

    /* TIMEOUT EVENTS for NIST */
    TIMEOUT_J,                   /**< Timer J */

    /* FOR INCOMING MESSAGE */
    RCV_REQINVITE,               /**< Event is an incoming INVITE request */
    RCV_REQACK,                  /**< Event is an incoming ACK request */
    RCV_REQUEST,                 /**< Event is an incoming NON-INVITE and NON-ACK request */
    RCV_STATUS_1XX,              /**< Event is an incoming informational response */
    RCV_STATUS_2XX,              /**< Event is an incoming 2XX response */
    RCV_STATUS_3456XX,           /**< Event is an incoming final response (not 2XX) */

    /* FOR OUTGOING MESSAGE */
    SND_REQINVITE,               /**< Event is an outgoing INVITE request */
    SND_REQACK,                  /**< Event is an outgoing ACK request */
    SND_REQUEST,                 /**< Event is an outgoing NON-INVITE and NON-ACK request */
    SND_STATUS_1XX,              /**< Event is an outgoing informational response */
    SND_STATUS_2XX,              /**< Event is an outgoing 2XX response */
    SND_STATUS_3456XX,           /**< Event is an outgoing final response (not 2XX) */

    KILL_TRANSACTION,            /**< Event to 'kill' the transaction before termination */
    UNKNOWN_EVT                  /**< Max event */
  } type_t;

/**
 * Enumeration for transaction type.
 * A transaction can be either of:
 *  ICT,
 *  IST,
 *  NICT,
 *  NIST,
 */
  typedef enum osip_fsm_type_t {
    ICT,         /**< Invite Client (outgoing) Transaction */
    IST,         /**< Invite Server (incoming) Transaction */
    NICT,        /**< Non-Invite Client (outgoing) Transaction */
    NIST         /**< Non-Invite Server (incoming) Transaction */
  } osip_fsm_type_t;

#ifndef DEFAULT_T1
/**
 * You can re-define the default value for T1. (T1 is defined in rfcxxxx)
 * The default value is 500ms.
 */
#define DEFAULT_T1 500          /* 500 ms */
#endif
#ifndef DEFAULT_T2
/**
 * You can re-define the default value for T2. (T2 is defined in rfcxxxx)
 * The default value is 4000ms.
 */
#define DEFAULT_T2 4000         /* 4s */
#endif
#ifndef DEFAULT_T4
/**
 * You can re-define the default value for T4. (T1 is defined in rfcxxxx)
 * The default value is 5000ms.
 */
#define DEFAULT_T4 5000         /* 5s */
#endif


/**
 * Structure for INVITE CLIENT TRANSACTION (outgoing INVITE transaction).
 * @var osip_ict_t
 */
  typedef struct osip_ict osip_ict_t;

/**
 * Structure for INVITE CLIENT TRANSACTION.
 * @struct osip_ict
 */
  struct osip_ict {
    int timer_a_length;                           /**< Timer A A=T1, A=2xT1... (unreliable only) */
    struct timeval timer_a_start;                 /**< Timer A (retransmission) */
    int timer_b_length;                           /**< Timer B B = 64* T1 */
    struct timeval timer_b_start;                 /**< Timer B (fire when transaction timeout) */
    int timer_d_length;                           /**< Timer D D >= 32s for unreliable tr (or 0) */
    struct timeval timer_d_start;                 /**< Timer D */
    char *destination;                            /**< IP used to send requests */
    int port;                                     /**< port of next hop */
  };

/**
 * Structure for NON-INVITE CLIENT TRANSACTION (outgoing NON-INVITE transaction).
 * @var osip_nict_t
 */
  typedef struct osip_nict osip_nict_t;

/**
 * Structure for NON-INVITE CLIENT TRANSACTION.
 * @struct osip_nict
 */
  struct osip_nict {
    int timer_e_length;                           /**< Timer E A=T1, A=2xT1... (unreliable only) */
    struct timeval timer_e_start;                 /**< Timer E (retransmission) */
    int timer_f_length;                           /**< Timer F B = 64* T1 */
    struct timeval timer_f_start;                 /**< Timer F (fire when transaction timeout) */
    int timer_k_length;                           /**< Timer K K = T4 (else = 0) */
    struct timeval timer_k_start;                 /**< Timer K */
    char *destination;                            /**< IP used to send requests */
    int port;                                     /**< port of next hop */

  };

/**
 * Structure for INVITE SERVER TRANSACTION (incoming INVITE transaction).
 * @var osip_ist_t
 */
  typedef struct osip_ist osip_ist_t;

/**
 * Structure for INVITE SERVER TRANSACTION.
 * @struct osip_ist
 */
  struct osip_ist {
    int timer_g_length;                           /**< Timer G G=MIN(T1*2,T2) for unreliable trans. */
    struct timeval timer_g_start;                 /**< Timer G (0 when reliable transport is used) */
    int timer_h_length;                           /**< Timer H H = 64* T1 */
    struct timeval timer_h_start;                 /**< Timer H (fire if no ACK is received) */
    int timer_i_length;                           /**< Timer I I = T4 for unreliable (or 0) */
    struct timeval timer_i_start;                 /**< Timer I (absorb all ACK) */
  };

/**
 * Structure for NON-INVITE SERVER TRANSACTION (incoming SERVER transaction).
 * @var osip_nist_t
 */
  typedef struct osip_nist osip_nist_t;

/**
 * Structure for NON-INVITE SERVER TRANSACTION.
 * @struct osip_nist
 */
  struct osip_nist {
    int timer_j_length;                            /**< Timer J = 64*T1 (else 0) */
    struct timeval timer_j_start;                  /**< Timer J */
  };

/**
 * Structure for SRV record entry.
 * @var osip_srv_entry_t
 */
  typedef struct osip_srv_entry osip_srv_entry_t;

/**
 * Structure for SRV record entry.
 * @struct osip_srv_entry
 */

  struct osip_srv_entry {
    char srv[512];                   /**< srv */
    int priority;                    /**< priority */
    int weight;                      /**< weight  */
    int rweight;                     /**< rweight  */
    int port;                        /**< port  */
    char ipaddress[512];             /**< ipaddress result  */
  };

#define OSIP_SRV_STATE_UNKNOWN 0         /**< unknown */
#define OSIP_SRV_STATE_RETRYLATER 2      /**< retry later */
#define OSIP_SRV_STATE_COMPLETED 3       /**< completed */
#define OSIP_SRV_STATE_NOTSUPPORTED 4    /**< not supported */

/**
 * Structure for SRV record.
 * @var osip_srv_record_t
 */
  typedef struct osip_srv_record osip_srv_record_t;

/**
 * Structure for SRV record entry.
 * @struct osip_srv_record
 */
  struct osip_srv_record {
    char name[512];                  /**< name */
    int srv_state;                   /**< srv state */
    char protocol[64];               /**< transport protocol*/
    int order;                       /**< order */
    int preference;                  /**< preference */
    int index;                       /**< index */
    osip_srv_entry_t srventry[10];   /**< result table */
  };

#define OSIP_NAPTR_STATE_UNKNOWN 0         /**< unknown */
#define OSIP_NAPTR_STATE_INPROGRESS 1      /**< in progress */
#define OSIP_NAPTR_STATE_NAPTRDONE 2       /**< naptr done */
#define OSIP_NAPTR_STATE_SRVINPROGRESS 3   /**< srv in progress */
#define OSIP_NAPTR_STATE_SRVDONE 4         /**< srv done */
#define OSIP_NAPTR_STATE_RETRYLATER 5      /**< retry later */
#define OSIP_NAPTR_STATE_NOTSUPPORTED 6    /**< not supported */

/**
 * Structure for NAPTR record.
 * @var osip_naptr_t
 */
  typedef struct osip_naptr osip_naptr_t;

/**
 * Structure for NAPTR record entry.
 * @struct osip_naptr
 */
  struct osip_naptr {
    char domain[512];                       /**< domain */
    int naptr_state;                        /**< naptr state */
    void *arg;                              /**< arg */
    int keep_in_cache;                      /**< keep in cache value */
    struct osip_srv_record sipudp_record;   /**< udp SRV result */
    struct osip_srv_record siptcp_record;   /**< tcp SRV result */
    struct osip_srv_record siptls_record;   /**< tls SRV result */
    struct osip_srv_record sipdtls_record;  /**< dtls SRV result */
    struct osip_srv_record sipsctp_record;  /**< sctp SRV result */
  };

/**
 * Structure for transaction handling.
 * @var osip_transaction_t
 */
  typedef struct osip_transaction osip_transaction_t;

/**
 * Structure for transaction handling
 * @struct osip_transaction
 */
  struct osip_transaction {

    void *your_instance;                /**< User Defined Pointer. */
    int transactionid;                  /**< Internal Transaction Identifier. */
    osip_fifo_t *transactionff;         /**< events must be added in this fifo */

    osip_via_t *topvia;                 /**< CALL-LEG definition (Top Via) */
    osip_from_t *from;                  /**< CALL-LEG definition (From)    */
    osip_to_t *to;                      /**< CALL-LEG definition (To)      */
    osip_call_id_t *callid;             /**< CALL-LEG definition (Call-ID) */
    osip_cseq_t *cseq;                  /**< CALL-LEG definition (CSeq)    */

    osip_message_t *orig_request;       /**< Initial request            */
    osip_message_t *last_response;      /**< Last response              */
    osip_message_t *ack;                /**< ack request sent           */

    state_t state;                      /**< Current state of the transaction */

    time_t birth_time;                  /**< birth date of transaction        */
    time_t completed_time;              /**< end   date of transaction        */

    int in_socket;                      /**< Optional socket for incoming message */
    int out_socket;                     /**< Optional place for outgoing message */

    void *config;                       /**< (internal) transaction is managed by osip_t  */

    osip_fsm_type_t ctx_type;           /**< Type of the transaction */
    osip_ict_t *ict_context;            /**< internal ict context */
    osip_ist_t *ist_context;            /**< internal ist context */
    osip_nict_t *nict_context;          /**< internal nict context */
    osip_nist_t *nist_context;          /**< internal nist context */

    osip_srv_record_t record;           /**< memory space for SRV record */
    osip_naptr_t *naptr_record;         /**< memory space for NAPTR record */
    void *reserved1;                    /**< User Defined Pointer. */
    void *reserved2;                    /**< User Defined Pointer. */
    void *reserved3;                    /**< User Defined Pointer. */
    void *reserved4;                    /**< User Defined Pointer. */
    void *reserved5;                    /**< User Defined Pointer. */
    void *reserved6;                    /**< User Defined Pointer. */
  };


/**
 * Enumeration for callback type.
 */
  typedef enum osip_message_callback_type {
    OSIP_ICT_INVITE_SENT = 0,                           /**< INVITE MESSAGE SENT */
    OSIP_ICT_INVITE_SENT_AGAIN,                         /**< INVITE MESSAGE RETRANSMITTED */
    OSIP_ICT_ACK_SENT,                                  /**< ACK MESSAGE SENT */
    OSIP_ICT_ACK_SENT_AGAIN,                            /**< ACK MESSAGE RETRANSMITTED */
    OSIP_ICT_STATUS_1XX_RECEIVED,                       /**< 1XX FOR INVITE RECEIVED */
    OSIP_ICT_STATUS_2XX_RECEIVED,                       /**< 2XX FOR INVITE RECEIVED */
    OSIP_ICT_STATUS_2XX_RECEIVED_AGAIN,                 /**< 2XX FOR INVITE RECEIVED AGAIN */
    OSIP_ICT_STATUS_3XX_RECEIVED,                       /**< 3XX FOR INVITE RECEIVED */
    OSIP_ICT_STATUS_4XX_RECEIVED,                       /**< 4XX FOR INVITE RECEIVED */
    OSIP_ICT_STATUS_5XX_RECEIVED,                       /**< 5XX FOR INVITE RECEIVED */
    OSIP_ICT_STATUS_6XX_RECEIVED,                       /**< 6XX FOR INVITE RECEIVED */
    OSIP_ICT_STATUS_3456XX_RECEIVED_AGAIN,              /**< RESPONSE RECEIVED AGAIN */

    OSIP_IST_INVITE_RECEIVED,                           /**< INVITE MESSAGE RECEIVED */
    OSIP_IST_INVITE_RECEIVED_AGAIN,                     /**< INVITE MESSAGE RECEIVED AGAN */
    OSIP_IST_ACK_RECEIVED,                              /**< ACK MESSAGE RECEIVED */
    OSIP_IST_ACK_RECEIVED_AGAIN,                        /**< ACK MESSAGE RECEIVED AGAIN */
    OSIP_IST_STATUS_1XX_SENT,                           /**< 1XX FOR INVITE SENT */
    OSIP_IST_STATUS_2XX_SENT,                           /**< 2XX FOR INVITE SENT */
    OSIP_IST_STATUS_2XX_SENT_AGAIN,                     /**< 2XX FOR INVITE RETRANSMITTED */
    OSIP_IST_STATUS_3XX_SENT,                           /**< 3XX FOR INVITE SENT */
    OSIP_IST_STATUS_4XX_SENT,                           /**< 4XX FOR INVITE SENT */
    OSIP_IST_STATUS_5XX_SENT,                           /**< 5XX FOR INVITE SENT */
    OSIP_IST_STATUS_6XX_SENT,                           /**< 6XX FOR INVITE SENT */
    OSIP_IST_STATUS_3456XX_SENT_AGAIN,                  /**< RESPONSE RETRANSMITTED */

    OSIP_NICT_REGISTER_SENT,                            /**< REGISTER MESSAGE SENT */
    OSIP_NICT_BYE_SENT,                                 /**< BYE MESSAGE SENT */
    OSIP_NICT_OPTIONS_SENT,                             /**< OPTIONS MESSAGE SENT */
    OSIP_NICT_INFO_SENT,                                /**< INFO MESSAGE SENT */
    OSIP_NICT_CANCEL_SENT,                              /**< CANCEL MESSAGE SENT */
    OSIP_NICT_NOTIFY_SENT,                              /**< NOTIFY MESSAGE SENT */
    OSIP_NICT_SUBSCRIBE_SENT,                           /**< SUBSCRIBE MESSAGE SENT */
    OSIP_NICT_UNKNOWN_REQUEST_SENT,                     /**< UNKNOWN REQUEST MESSAGE SENT */
    OSIP_NICT_REQUEST_SENT_AGAIN,                       /**< REQUEST MESSAGE RETRANMITTED */
    OSIP_NICT_STATUS_1XX_RECEIVED,                      /**< 1XX FOR MESSAGE RECEIVED */
    OSIP_NICT_STATUS_2XX_RECEIVED,                      /**< 2XX FOR MESSAGE RECEIVED */
    OSIP_NICT_STATUS_2XX_RECEIVED_AGAIN,                /**< 2XX FOR MESSAGE RECEIVED AGAIN */
    OSIP_NICT_STATUS_3XX_RECEIVED,                      /**< 3XX FOR MESSAGE RECEIVED */
    OSIP_NICT_STATUS_4XX_RECEIVED,                      /**< 4XX FOR MESSAGE RECEIVED */
    OSIP_NICT_STATUS_5XX_RECEIVED,                      /**< 5XX FOR MESSAGE RECEIVED */
    OSIP_NICT_STATUS_6XX_RECEIVED,                      /**< 6XX FOR MESSAGE RECEIVED */
    OSIP_NICT_STATUS_3456XX_RECEIVED_AGAIN,             /**< RESPONSE RECEIVED AGAIN */

    OSIP_NIST_REGISTER_RECEIVED,                        /**< REGISTER RECEIVED */
    OSIP_NIST_BYE_RECEIVED,                             /**< BYE RECEIVED */
    OSIP_NIST_OPTIONS_RECEIVED,                         /**< OPTIONS RECEIVED */
    OSIP_NIST_INFO_RECEIVED,                            /**< INFO RECEIVED */
    OSIP_NIST_CANCEL_RECEIVED,                          /**< CANCEL RECEIVED */
    OSIP_NIST_NOTIFY_RECEIVED,                          /**< NOTIFY RECEIVED */
    OSIP_NIST_SUBSCRIBE_RECEIVED,                       /**< SUBSCRIBE RECEIVED */

    OSIP_NIST_UNKNOWN_REQUEST_RECEIVED,                 /**< UNKNWON REQUEST RECEIVED */
    OSIP_NIST_REQUEST_RECEIVED_AGAIN,                   /**< UNKNWON REQUEST RECEIVED AGAIN */
    OSIP_NIST_STATUS_1XX_SENT,                          /**< 1XX FOR MESSAGE SENT */
    OSIP_NIST_STATUS_2XX_SENT,                          /**< 2XX FOR MESSAGE SENT */
    OSIP_NIST_STATUS_2XX_SENT_AGAIN,                    /**< 2XX FOR MESSAGE RETRANSMITTED */
    OSIP_NIST_STATUS_3XX_SENT,                          /**< 3XX FOR MESSAGE SENT */
    OSIP_NIST_STATUS_4XX_SENT,                          /**< 4XX FOR MESSAGE SENT */
    OSIP_NIST_STATUS_5XX_SENT,                          /**< 5XX FOR MESSAGE SENT */
    OSIP_NIST_STATUS_6XX_SENT,                          /**< 6XX FOR MESSAGE SENT */
    OSIP_NIST_STATUS_3456XX_SENT_AGAIN,                 /**< RESPONSE RETRANSMITTED */

    OSIP_ICT_STATUS_TIMEOUT,                            /**< TIMER B EXPIRATION: NO REMOTE ANSWER  */
    OSIP_NICT_STATUS_TIMEOUT,                           /**< TIMER F EXPIRATION: NO REMOTE ANSWER  */

    OSIP_MESSAGE_CALLBACK_COUNT                         /**< END OF ENUM */
  } osip_message_callback_type_t;

/**
 * Enumeration for callback type used when transaction is over.
 */
  typedef enum osip_kill_callback_type {
    OSIP_ICT_KILL_TRANSACTION,                  /**< end of Client INVITE transaction */
    OSIP_IST_KILL_TRANSACTION,                  /**< end of Server INVITE transaction */
    OSIP_NICT_KILL_TRANSACTION,                 /**< end of Client Non-INVITE transaction */
    OSIP_NIST_KILL_TRANSACTION,                 /**< end of Server Non-INVITE transaction */

    OSIP_KILL_CALLBACK_COUNT                    /**< END OF ENUM */
  } osip_kill_callback_type_t;

/**
 * Enumeration for callback type used when a transport error is detected.
 */
  typedef enum osip_transport_error_callback_type {
    OSIP_ICT_TRANSPORT_ERROR,                             /**< transport error for ICT */
    OSIP_IST_TRANSPORT_ERROR,                             /**< transport error for IST */
    OSIP_NICT_TRANSPORT_ERROR,                            /**< transport error for NICT */
    OSIP_NIST_TRANSPORT_ERROR,                            /**< transport error for NIST */

    OSIP_TRANSPORT_ERROR_CALLBACK_COUNT                   /**< END OF ENUM */
  } osip_transport_error_callback_type_t;

/**
 * Callback definition for message announcements.
 * @var osip_message_cb_t
 */
  typedef void (*osip_message_cb_t) (int type, osip_transaction_t *, osip_message_t *);
/**
 * Callback definition for end of transaction announcements.
 * @var osip_kill_transaction_cb_t
 */
  typedef void (*osip_kill_transaction_cb_t) (int type, osip_transaction_t *);
/**
 * Callback definition for transport error announcements.
 * @var osip_transport_error_cb_t
 */
  typedef void (*osip_transport_error_cb_t) (int type, osip_transaction_t *, int error);


  struct osip_dialog;

/**
 * Structure for 2XX retransmission management.
 * @var ixt_t
 */
  typedef struct ixt ixt_t;

/**
 * Structure for 2XX retransmission management.
 * @struct ixt
 */
  struct ixt {
    /* any ACK received that match this context will set counter to -1 */
    struct osip_dialog *dialog;         /**< related dialog */
    osip_message_t *msg2xx;             /**< buffer to retransmit */
    osip_message_t *ack;                /**< ack message if needed */
    struct timeval start;               /**< Time of first retransmission */
    int interval;                       /**< delay between retransmission, in ms */
    char *dest;                         /**< destination host */
    int port;                           /**< destination port */
    int sock;                           /**< socket to use */
    int counter;                        /**< start at 7 */
  };


/**
 * Structure for osip handling.
 * In order to use osip, you have to manage at least one global instance
 * of an osip_t element. Then, you'll register a set of required callbacks
 * and a set of optional ones.
 * @var osip_t
 */
  typedef struct osip osip_t;

/**
 * Structure for osip handling.
 * @struct osip
 */
  struct osip {

    void *application_context;     /**< User defined Pointer */

    void *ict_fastmutex;           /**< mutex for ICT transaction */
    void *ist_fastmutex;           /**< mutex for IST transaction */
    void *nict_fastmutex;          /**< mutex for NICT transaction */
    void *nist_fastmutex;          /**< mutex for NIST transaction */
    void *ixt_fastmutex;           /**< mutex for IXT transaction */
    void *id_mutex;                /**< mutex for unique transaction id generation */
    int transactionid;             /**< previous unique transaction id generation */

    /* list of transactions for ict, ist, nict, nist */
    osip_list_t osip_ict_transactions;          /**< list of ict transactions */
    osip_list_t osip_ist_transactions;          /**< list of ist transactions */
    osip_list_t osip_nict_transactions;         /**< list of nict transactions */
    osip_list_t osip_nist_transactions;         /**< list of nist transactions */

    osip_list_t ixt_retransmissions;            /**< list of ixt elements */

    osip_message_cb_t msg_callbacks[OSIP_MESSAGE_CALLBACK_COUNT];                /**< message callbacks */
    osip_kill_transaction_cb_t kill_callbacks[OSIP_KILL_CALLBACK_COUNT];         /**< kill callbacks */
    osip_transport_error_cb_t tp_error_callbacks[OSIP_TRANSPORT_ERROR_CALLBACK_COUNT];     /**< transport error callback */

    int (*cb_send_message) (osip_transaction_t *, osip_message_t *, char *, int, int);     /**< callback to send message */

#if defined(HAVE_DICT_DICT_H)
    dict *osip_ict_hastable;                              /**< htable of ict transactions */
    dict *osip_ist_hastable;                              /**< htable of ist transactions */
    dict *osip_nict_hastable;                             /**< htable of nict transactions */
    dict *osip_nist_hastable;                             /**< htable of nist transactions */
#endif
  };

/**
 * Set a callback for each transaction operation. 
 * @param osip The element to work on.
 * @param type The event type to hook on.
 * @param cb The method to be called upon the event.
 */
  int osip_set_message_callback (osip_t * osip, int type, osip_message_cb_t cb);

/**
 * Set a callback for transaction operation related to the end of transactions. 
 * @param osip The element to work on.
 * @param type The event type to hook on.
 * @param cb The method to be called upon the event.
 */
  int osip_set_kill_transaction_callback (osip_t * osip, int type, osip_kill_transaction_cb_t cb);

/**
 * Set a callback for each transaction operation related to network error.
 * @param osip The element to work on.
 * @param type The event type to hook on.
 * @param cb The method to be called upon the event.
 */
  int osip_set_transport_error_callback (osip_t * osip, int type, osip_transport_error_cb_t cb);

/**
 * Structure for osip event handling.
 * A osip_event_t element will have a type and will be related
 * to a transaction. In the general case, it is used by the
 * application layer to give SIP messages to the oSIP finite
 * state machine.
 * @var osip_event_t
 */
  typedef struct osip_event osip_event_t;

/**
 * Structure for osip event handling.
 * @struct osip_event
 */
  struct osip_event {
    type_t type;                     /**< Event Type */
    int transactionid;               /**< identifier of the related osip transaction */
    osip_message_t *sip;             /**< SIP message (optional) */
  };



/**
 * Allocate an osip_transaction_t element.
 * @param transaction The element to allocate.
 * @param ctx_type The type of transaction. (ICT, IST, NICT, NIST)
 * @param osip The global instance of oSIP.
 * @param request The SIP request that initiate the transaction.
 */
  int osip_transaction_init (osip_transaction_t ** transaction, osip_fsm_type_t ctx_type, osip_t * osip, osip_message_t * request);
/**
 * Free all resource in a osip_transaction_t element.
 * @param transaction The element to free.
 */
  int osip_transaction_free (osip_transaction_t * transaction);
/**
 * Free all resource in a osip_transaction_t element.
 * This method does the same than osip_transaction_free() but it assumes
 * that the transaction is already removed from the list of transaction
 * in the osip stack. (to remove it use osip_xixt_remove(osip, transaction);
 * @param transaction The element to free.
 */
  int osip_transaction_free2 (osip_transaction_t * transaction);

/**
 * Search in a SIP response the destination where the message
 * should be sent.
 * @param response the message to work on.
 * @param address a pointer to receive the allocated host address.
 * @param portnum a pointer to receive the host port.
 */
  void osip_response_get_destination (osip_message_t * response, char **address, int *portnum);
/**
 * Set the host and port destination used for sending the SIP message.
 * This can be useful for an application with 'DIRECT ROOTING MODE'
 * NOTE: Instead, you should use the 'Route' header facility which
 * leads to the same behaviour.
 * @param ict The element to work on.
 * @param destination The destination host.
 * @param port The destination port.
 */
  int osip_ict_set_destination (osip_ict_t * ict, char *destination, int port);

/**
 * Set the host and port destination used for sending the SIP message.
 * This can be useful for an application with 'DIRECT ROOTING MODE'
 * NOTE: Instead, you should use the 'Route' header facility which
 * leads to the same behaviour.
 * @param nict The element to work on.
 * @param destination The destination host.
 * @param port The destination port.
 */
  int osip_nict_set_destination (osip_nict_t * nict, char *destination, int port);

/**
 * Add a SIP event in the fifo of a osip_transaction_t element.
 * @param transaction The element to work on.
 * @param evt The event to add.
 */
  int osip_transaction_add_event (osip_transaction_t * transaction, osip_event_t * evt);
/**
 * Consume one osip_event_t element previously added in the fifo.
 * NOTE: This method MUST NEVER be called within another call
 * of this method. (For example, you can't call osip_transaction_execute()
 * in a callback registered in the osip_t element.)
 * @param transaction The element to free.
 * @param evt The element to consume.
 */
  int osip_transaction_execute (osip_transaction_t * transaction, osip_event_t * evt);
/**
 * Set a pointer to your personal context associated with this transaction.
 * OBSOLETE: see osip_transaction_set_reserved1...
 * NOTE: this is a very useful method that allow you to avoid searching
 * for your personal context inside the registered callbacks.
 * You can initialise this pointer to your context right after
 * the creation of the osip_transaction_t element. Then, you'll be
 * able to get the address of your context by calling
 * osip_transaction_get_your_instance().
 * @param transaction The element to work on.
 * @param ptr The address of your context.
 */
  int osip_transaction_set_your_instance (osip_transaction_t * transaction, void *ptr);

/**
 * Set a pointer to your personal context associated with this transaction.
 * NOTE: this is a very useful method that allow you to avoid searching
 * for your personal context inside the registered callbacks.
 * You can initialise this pointer to your context right after
 * the creation of the osip_transaction_t element. Then, you'll be
 * able to get the address of your context by calling
 * osip_transaction_get_reserved1().
 * @param transaction The element to work on.
 * @param ptr The address of your context.
 */
  int osip_transaction_set_reserved1 (osip_transaction_t * transaction, void *ptr);
/**
 * Set a pointer to your personal context associated with this transaction.
 * NOTE: see osip_transaction_set_reserved1
 * @param transaction The element to work on.
 * @param ptr The address of your context.
 */
  int osip_transaction_set_reserved2 (osip_transaction_t * transaction, void *ptr);

/**
 * Set a pointer to your personal context associated with this transaction.
 * NOTE: see osip_transaction_set_reserved1
 * @param transaction The element to work on.
 * @param ptr The address of your context.
 */
  int osip_transaction_set_reserved3 (osip_transaction_t * transaction, void *ptr);

/**
 * Set a pointer to your personal context associated with this transaction.
 * NOTE: see osip_transaction_set_reserved1
 * @param transaction The element to work on.
 * @param ptr The address of your context.
 */
  int osip_transaction_set_reserved4 (osip_transaction_t * transaction, void *ptr);

/**
 * Set a pointer to your personal context associated with this transaction.
 * NOTE: see osip_transaction_set_reserved1
 * @param transaction The element to work on.
 * @param ptr The address of your context.
 */
  int osip_transaction_set_reserved5 (osip_transaction_t * transaction, void *ptr);

/**
 * Set a pointer to your personal context associated with this transaction.
 * NOTE: see osip_transaction_set_reserved1
 * @param transaction The element to work on.
 * @param ptr The address of your context.
 */
  int osip_transaction_set_reserved6 (osip_transaction_t * transaction, void *ptr);

/**
 * Get a pointer to your personal context associated with this transaction.
 * OBSOLETE: see osip_transaction_get_reserved1...
 * @param transaction The element to work on.
 */
  void *osip_transaction_get_your_instance (osip_transaction_t * transaction);

/**
 * Get a pointer to your personal context associated with this transaction.
 * @param transaction The element to work on.
 */
  void *osip_transaction_get_reserved1 (osip_transaction_t * transaction);

/**
 * Get a pointer to your personal context associated with this transaction.
 * @param transaction The element to work on.
 */
  void *osip_transaction_get_reserved2 (osip_transaction_t * transaction);

/**
 * Get a pointer to your personal context associated with this transaction.
 * @param transaction The element to work on.
 */
  void *osip_transaction_get_reserved3 (osip_transaction_t * transaction);

/**
 * Get a pointer to your personal context associated with this transaction.
 * @param transaction The element to work on.
 */
  void *osip_transaction_get_reserved4 (osip_transaction_t * transaction);

/**
 * Get a pointer to your personal context associated with this transaction.
 * @param transaction The element to work on.
 */
  void *osip_transaction_get_reserved5 (osip_transaction_t * transaction);

/**
 * Get a pointer to your personal context associated with this transaction.
 * @param transaction The element to work on.
 */
  void *osip_transaction_get_reserved6 (osip_transaction_t * transaction);

/**
 * Get target ip and port for this request.
 * (automaticly set by osip_transaction_init() for ict and nict)
 * @param transaction The element to work on.
 * @param ip The ip of host where to send initial request.
 * @param port The port where to send initial request.
 */
  int osip_transaction_get_destination (osip_transaction_t * transaction, char **ip, int *port);


/**
 * Set SRV lookup information to be used by state machine.
 *
 * @param transaction The element to work on.
 * @param record The SRV lookup results for this transaction.
 */
  int osip_transaction_set_srv_record (osip_transaction_t * transaction, osip_srv_record_t * record);

/**
 * Set NAPTR lookup information to be used by state machine.
 *
 * @param transaction The element to work on.
 * @param record The NAPTR lookup results for this transaction.
 */
  int osip_transaction_set_naptr_record (osip_transaction_t * transaction, osip_naptr_t * record);

/**
 * Set the socket for incoming message.
 *
 * @param transaction The element to work on.
 * @param sock The socket for incoming message.
 */
  int osip_transaction_set_in_socket (osip_transaction_t * transaction, int sock);
/**
 * Set the socket for outgoing message.
 *
 * @param transaction The element to work on.
 * @param sock The socket for outgoing message.
 */
  int osip_transaction_set_out_socket (osip_transaction_t * transaction, int sock);



/** 
 * Allocate an osip_t element.
 * @param osip the element to allocate.
 */
  int osip_init (osip_t ** osip);
/**
 * Free all resource in a osip_t element.
 * @param osip The element to release.
 */
  void osip_release (osip_t * osip);

/**
 * Set a pointer in a osip_t element.
 * This help to find your application layer in callbacks.
 * @param osip The element to work on.
 * @param pointer The element to set.
 */
  void osip_set_application_context (osip_t * osip, void *pointer);

/**
 * Get a pointer in a osip_t element.
 * This help to find your application layer in callbacks.
 * @param osip The element to work on.
 */
  void *osip_get_application_context (osip_t * osip);


/**
 * Remove a transaction from the osip stack.
 * @param osip The element to work on.
 * @param ict The transaction to add.
 */
  int osip_remove_transaction (osip_t * osip, osip_transaction_t * ict);


/**
 * Consume ALL pending osip_event_t previously added in the fifos of ict transactions.
 * @param osip The element to work on.
 */
  int osip_ict_execute (osip_t * osip);
/**
 * Consume ALL pending osip_event_t previously added in the fifos of ist transactions.
 * @param osip The element to work on.
 */
  int osip_ist_execute (osip_t * osip);
/**
 * Consume ALL pending osip_event_t previously added in the fifos of nict transactions.
 * @param osip The element to work on.
 */
  int osip_nict_execute (osip_t * osip);
/**
 * Consume ALL pending osip_event_t previously added in the fifos of nist transactions.
 * @param osip The element to work on.
 */
  int osip_nist_execute (osip_t * osip);

/**
 * Retreive the minimum timer value to be used by an application
 * so that the osip_timer_*_execute method don't have to be called
 * often.
 * 
 * @param osip The element to work on.
 * @param lower_tv The minimum timer when the application should wake up.
 */
  void osip_timers_gettimeout (osip_t * osip, struct timeval *lower_tv);

/**
 * Check if an ict transactions needs a timer event.
 * @param osip The element to work on.
 */
  void osip_timers_ict_execute (osip_t * osip);
/**
 * Check if an ist transactions needs a timer event.
 * @param osip The element to work on.
 */
  void osip_timers_ist_execute (osip_t * osip);
/**
 * Check if a nict transactions needs a timer event.
 * @param osip The element to work on.
 */
  void osip_timers_nict_execute (osip_t * osip);
/**
 * Check if a nist transactions needs a timer event.
 * @param osip The element to work on.
 */
  void osip_timers_nist_execute (osip_t * osip);

/* Take care of mutlithreading issuewhile using this method */
/**
 * Search for a transaction that match this event (MUST be a MESSAGE event).
 * @param transactions The list of transactions to work on.
 * @param evt The element representing the SIP MESSAGE.
 */
  osip_transaction_t *osip_transaction_find (osip_list_t * transactions, osip_event_t * evt);


#ifndef DOXYGEN
/**
 * Some race conditions can happen in multi threaded applications.
 * Use this method carefully.
 * <BR>Search for a transaction that match this event (MUST be a MESSAGE event).
 * @param osip The element to work on.
 * @param evt The element representing the SIP MESSAGE.
 */
#ifdef OSIP_MONOTHREAD
  osip_transaction_t *osip_find_transaction (osip_t * osip, osip_event_t * evt);
#endif

  osip_transaction_t *__osip_find_transaction (osip_t * osip, osip_event_t * evt, int consume);
#endif

/**
 * Search for a transaction that match this event (MUST be a MESSAGE event)
 * and add this event if a transaction is found..
 * @param osip The element to work on.
 * @param evt The element representing the SIP MESSAGE.
 */
  int osip_find_transaction_and_add_event (osip_t * osip, osip_event_t * evt);

/**
 * Create a transaction for this event (MUST be a SIP REQUEST event).
 * @param osip The element to work on.
 * @param evt The element representing the new SIP REQUEST.
 */
  osip_transaction_t *osip_create_transaction (osip_t * osip, osip_event_t * evt);

/**
 * Create a sipevent from a SIP message string.
 * @param buf The SIP message as a string.
 * @param length The length of the buffer to parse.
 */
  osip_event_t *osip_parse (const char *buf, size_t length);


/**
 * Send required retransmissions
 * @param osip The element to work on.
 */
  void osip_retransmissions_execute (osip_t * osip);

/**
 * Start out of fsm 200 Ok retransmissions. This is usefull for user-agents.
 * @param osip The osip_t structure.
 * @param dialog The dialog the 200 Ok is part of.
 * @param msg200ok The 200 ok response.
 * @param sock The socket to be used to send the message. (optional).
 */
  void osip_start_200ok_retransmissions (osip_t * osip, struct osip_dialog *dialog, osip_message_t * msg200ok, int sock);

/**
 * Start out of fsm ACK retransmissions. This is usefull for user-agents.
 * @param osip The osip_t structure.
 * @param dialog The dialog the ACK is part of.
 * @param ack The ACK that has just been sent in response to a 200 Ok.
 * @param dest The destination host.
 * @param port The destination port.
 * @param sock The socket to be used to send the message. (optional).
 */
  void osip_start_ack_retransmissions (osip_t * osip, struct osip_dialog *dialog, osip_message_t * ack, char *dest, int port, int sock);

/**
 * Stop the out of fsm 200 Ok retransmissions matching an incoming ACK.
 * @param osip The osip_t structure.
 * @param ack  The ack that has just been received.
 */
  struct osip_dialog *osip_stop_200ok_retransmissions (osip_t * osip, osip_message_t * ack);

/**
 * Stop out of fsm retransmissions (ACK or 200 Ok) associated to a given dialog.
 * This function must be called before freeing a dialog if out of fsm retransmissions
 * have been scheduled.
 * @param osip The osip_t structure
 * @param dialog The dialog.
 */
  void osip_stop_retransmissions_from_dialog (osip_t * osip, struct osip_dialog *dialog);


/**
 * Allocate a sipevent (we know this message is an OUTGOING SIP message).
 * @param sip The SIP message we want to send.
 */
  osip_event_t *osip_new_outgoing_sipmessage (osip_message_t * sip);

/**
 * Free all ressource in a sipevent.
 * @param event The event to free.
 */
  void osip_event_free (osip_event_t * event);

/**
 * Register the callback used to send SIP message.
 * @param cf The osip element attached to the transaction.
 * @param cb The method we want to register.
 */
  void osip_set_cb_send_message (osip_t * cf, int (*cb) (osip_transaction_t *, osip_message_t *, char *, int, int));

/* FOR INCOMING TRANSACTION */
/**
 * Check if the sipevent is of type RCV_REQINVITE.
 * @param event the event to check.
 */
#define EVT_IS_RCV_INVITE(event)       (event->type==RCV_REQINVITE)
/**
 * Check if the sipevent is of type RCV_REQACK.
 * @param event the event to check.
 */
#define EVT_IS_RCV_ACK(event)          (event->type==RCV_REQACK)
/**
 * Check if the sipevent is of type RCV_REQUEST.
 * @param event the event to check.
 */
#define EVT_IS_RCV_REQUEST(event)      (event->type==RCV_REQUEST)
/**
 * Check if the sipevent is of type RCV_STATUS_1XX.
 * @param event the event to check.
 */
#define EVT_IS_RCV_STATUS_1XX(event)   (event->type==RCV_STATUS_1XX)
/**
 * Check if the sipevent is of type RCV_STATUS_2XX.
 * @param event the event to check.
 */
#define EVT_IS_RCV_STATUS_2XX(event)   (event->type==RCV_STATUS_2XX)
/**
 * Check if the sipevent is of type RCV_STATUS_3456XX.
 * @param event the event to check.
 */
#define EVT_IS_RCV_STATUS_3456XX(event)   (event->type==RCV_STATUS_3456XX)


/* FOR OUTGOING TRANSACTION */
/**
 * Check if the sipevent is of type SND_REQINVITE.
 * @param event the event to check.
 */
#define EVT_IS_SND_INVITE(event)       (event->type==SND_REQINVITE)
/**
 * Check if the sipevent is of type SND_REQACK.
 * @param event the event to check.
 */
#define EVT_IS_SND_ACK(event)          (event->type==SND_REQACK)
/**
 * Check if the sipevent is of type SND_REQUEST.
 * @param event the event to check.
 */
#define EVT_IS_SND_REQUEST(event)      (event->type==SND_REQUEST)
/**
 * Check if the sipevent is of type SND_STATUS_1XX.
 * @param event the event to check.
 */
#define EVT_IS_SND_STATUS_1XX(event)   (event->type==SND_STATUS_1XX)
/**
 * Check if the sipevent is of type SND_STATUS_2XX.
 * @param event the event to check.
 */
#define EVT_IS_SND_STATUS_2XX(event)   (event->type==SND_STATUS_2XX)
/**
 * Check if the sipevent is of type SND_STATUS_3456XX.
 * @param event the event to check.
 */
#define EVT_IS_SND_STATUS_3456XX(event)   (event->type==SND_STATUS_3456XX)
/**
 * Check if the sipevent is of an incoming SIP MESSAGE.
 * @param event the event to check.
 */
#define EVT_IS_INCOMINGMSG(event)      (event->type>=RCV_REQINVITE \
                	               &&event->type<=RCV_STATUS_3456XX)
/**
 * Check if the sipevent is of an incoming SIP REQUEST.
 * @param event the event to check.
 */
#define EVT_IS_INCOMINGREQ(event)      (EVT_IS_RCV_INVITE(event) \
                                       ||EVT_IS_RCV_ACK(event) \
                                       ||EVT_IS_RCV_REQUEST(event))
/**
 * Check if the sipevent is of an incoming SIP RESPONSE.
 * @param event the event to check.
 */
#define EVT_IS_INCOMINGRESP(event)     (EVT_IS_RCV_STATUS_1XX(event) \
                                       ||EVT_IS_RCV_STATUS_2XX(event) \
				       ||EVT_IS_RCV_STATUS_3456XX(event))
/**
 * Check if the sipevent is of an outgoing SIP MESSAGE.
 * @param event the event to check.
 */
#define EVT_IS_OUTGOINGMSG(event)      (event->type>=SND_REQINVITE \
                	               &&event->type<=SND_STATUS_3456XX)
/**
 * Check if the sipevent is of an outgoing SIP REQUEST.
 * @param event the event to check.
 */
#define EVT_IS_OUTGOINGREQ(event)      (EVT_IS_SND_INVITE(event) \
                                       ||EVT_IS_SND_ACK(event) \
                                       ||EVT_IS_SND_REQUEST(event))
/**
 * Check if the sipevent is of an outgoing SIP RESPONSE.
 * @param event the event to check.
 */
#define EVT_IS_OUTGOINGRESP(event)     (EVT_IS_SND_STATUS_1XX(event) \
                                       ||EVT_IS_SND_STATUS_2XX(event) \
				       ||EVT_IS_SND_STATUS_3456XX(event))

/**
 * Check if the sipevent is a SIP MESSAGE.
 * @param event the event to check.
 */
#define EVT_IS_MSG(event)              (event->type>=RCV_REQINVITE \
                	               &&event->type<=SND_STATUS_3456XX)
/**
 * Check if the sipevent is of type KILL_TRANSACTION.
 * NOTE: THIS IS AN INTERNAL METHOD ONLY
 * @param event the event to check.
 */
#define EVT_IS_KILL_TRANSACTION(event) (event->type==KILL_TRANSACTION)

#ifdef __cplusplus
}
#endif
/** @} */
#endif