Source

ocaml-sip / tests / data / Testdata_messages.ml

open Sip_types
open Batteries

(*********************************************************************************************************************
 *
 *)

module Util = struct

    let eol_sep = "\r\n"

    let prepare_invalid_message title msg = (title, String.concat eol_sep msg)

    let prepare_valid_message title msg descr = (title, String.concat eol_sep msg, descr)

    type message_description
        = DescrMimeField of string * string
        | DescrMimeFields of string * string list
        | DescrContentLength of int
        | DescrSipVersion of sip_version
        | DescrMaxForwards of int
        | DescrCseq of sip_cseq
        | DescrUri of sip_uri
        | DescrCallId of sip_call_id
        | DescrSipMethod of sip_request_method

    let descr_content_length i = DescrContentLength i
    let descr_sip_version i    = DescrSipVersion i
    let descr_max_forwards i   = DescrMaxForwards i
    let descr_mime_field a b   = DescrMimeField (a,b)
    let descr_mime_fields a b  = DescrMimeFields (a,b)
    let descr_cseq c           = DescrCseq c
    let descr_uri c            = DescrUri c
    let descr_sip_method c     = DescrSipMethod c
    let descr_call_id c        = DescrCallId c
end

module Valid_messages = struct
    open Util

    let messages = 
        [ prepare_valid_message "basic invite RFC3261.4"
            [ "INVITE sip:bob@biloxi.com SIP/2.0" 
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
            ; "Max-Forwards: 70" 
            ; "To: Bob <sip:bob@biloxi.com>" 
            ; "From: Alice <sip:alice@atlanta.com>;tag=1928301774" 
            ; "Call-ID: a84b4c76e66710@pc33.atlanta.com" 
            ; "CSeq: 314159 INVITE"
            ; "Contact: <sip:alice@pc33.atlanta.com>"
            ; "Content-Type: application/sdp"
            ; "Content-Length: 142"
            ; ""
            ; String.repeat "a" 142
            ]

            [ descr_sip_method INVITE
            ; descr_uri (SipUri "sip:bob@biloxi.com")
            ; descr_sip_version SIP_2_0
            ; descr_cseq (SipCseq "314159 INVITE")
            ; descr_call_id (SipCallId "a84b4c76e66710@pc33.atlanta.com")
            ; descr_max_forwards 70
            ; descr_content_length 142
            ; descr_mime_fields "Via"
                [ "SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
                ]
            ]

        ; prepare_valid_message "basic invite RFC3261.4, multiline header"
            [ "INVITE sip:bob@biloxi.com SIP/2.0" 
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
            ; "Max-Forwards: 70" 
            ; "To: Bob <sip:bob@biloxi.com>" 
            ; "From: Alice <sip:alice@atlanta.com>;tag=1928301774" 
            ; "Call-ID: a84b4c76e66710@pc33.atlanta.com" 
            ; "CSeq: 314159 INVITE"
            ; "Contact: <sip:alice@pc33.atlanta.com>"
            ; "Content-Type: application/sdp"
            ; "Test-header: header"
            ; "  multiline"
            ; "  test"
            ; "Content-Length: 142"
            ; ""
            ; String.repeat "a" 142
            ]

            [ descr_max_forwards 70
            ; descr_sip_version SIP_2_0
            ; descr_content_length 142

            ; descr_mime_fields "Via"
                [ "SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
                ]

            ; descr_mime_field "Test-header" "header multiline test"
            ]

        ; prepare_valid_message "invite with multipart body RFC3261.23.4.2"
            [ "INVITE sip:bob@biloxi.com SIP/2.0"
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8"
            ; "To: Bob <sip:bob@biloxi.com>"
            ; "From: Alice <sip:alice@atlanta.com>;tag=1928301774"
            ; "Call-ID: a84b4c76e66710"
            ; "CSeq: 314159 INVITE"
            ; "Max-Forwards: 70"
            ; "Date: Thu, 21 Feb 2002 13:02:03 GMT"
            ; "Contact: <sip:alice@pc33.atlanta.com>"
            ; "Content-Type: multipart/signed;"
            ; "  protocol=\"application/pkcs7-signature\";"
            ; "  micalg=sha1; boundary=boundary42"
            ; "Content-Length: 568"
            ; ""
            ; "--boundary42"
            ; "Content-Type: message/sip"
            ; ""
            ; "INVITE sip:bob@biloxi.com SIP/2.0"
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8"
            ; "To: Bob <bob@biloxi.com>"
            ; "From: Alice <alice@atlanta.com>;tag=1928301774"
            ; "Call-ID: a84b4c76e66710"
            ; "CSeq: 314159 INVITE"
            ; "Max-Forwards: 70"
            ; "Date: Thu, 21 Feb 2002 13:02:03 GMT"
            ; "Contact: <sip:alice@pc33.atlanta.com>"
            ; "Content-Type: application/sdp"
            ; "Content-Length: 147"
            ; ""
            ; "v=0"
            ; "o=UserA 2890844526 2890844526 IN IP4 here.com"
            ; "s=Session SDP"
            ; "c=IN IP4 pc33.atlanta.com"
            ; "t=0 0"
            ; "m=audio 49172 RTP/AVP 0"
            ; "a=rtpmap:0 PCMU/8000"
            ; ""
            ; "--boundary42"
            ; "Content-Type: application/pkcs7-signature; name=smime.p7s"
            ; "Content-Transfer-Encoding: base64"
            ; "Content-Disposition: attachment; filename=smime.p7s;"
            ; " handling=required"
            ; "ghyHhHUujhJhjH77n8HHGTrfvbnj756tbB9HG4VQpfyF467GhIGfHfYT6"
            ; "4VQpfyF467GhIGfHfYT6jH77n8HHGghyHhHUujhJh756tbB9HGTrfvbnj"
            ; "n8HHGTrfvhJhjH776tbB9HG4VQbnj7567GhIGfHfYT6ghyHhHUujpfyF4"
            ; "7GhIGfHfYT64VQbnj756"
            ; ""
            ; "--boundary42-"
            ]

            [ descr_sip_method INVITE
            ; descr_uri (SipUri "sip:bob@biloxi.com")
            ; descr_sip_version SIP_2_0
            ; descr_call_id (SipCallId "a84b4c76e66710")
            ; descr_cseq (SipCseq "314159 INVITE")
            ; descr_max_forwards 70
            ; descr_mime_field "date" "Thu, 21 Feb 2002 13:02:03 GMT"
            ; descr_mime_field "content-type"
                "multipart/signed; protocol=\"application/pkcs7-signature\"; micalg=sha1; boundary=boundary42"
            ; descr_content_length 568
            ]

        ; prepare_valid_message "basic invite RFC3261.4, but as SIP/1.0"
            [ "INVITE sip:bob@biloxi.com SIP/1.0" 
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
            ; "Max-Forwards: 70" 
            ; "To: Bob <sip:bob@biloxi.com>" 
            ; "From: Alice <sip:alice@atlanta.com>;tag=1928301774" 
            ; "Call-ID: a84b4c76e66710@pc33.atlanta.com" 
            ; "CSeq: 314159 INVITE"
            ; "Contact: <sip:alice@pc33.atlanta.com>"
            ; "Content-Type: application/sdp"
            ; "Content-Length: 142"
            ; ""
            ; String.repeat "a" 142
            ]

            [ descr_max_forwards 70
            ; descr_sip_version SIP_1_0
            ; descr_content_length 142

            ; descr_mime_fields "Via"
                [ "SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
                ]
            ]

        ; prepare_valid_message "basic invite RFC3261.4, but as SIP/1.5"
            [ "INVITE sip:bob@biloxi.com SIP/1.5" 
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
            ; "Max-Forwards: 70" 
            ; "To: Bob <sip:bob@biloxi.com>" 
            ; "From: Alice <sip:alice@atlanta.com>;tag=1928301774" 
            ; "Call-ID: a84b4c76e66710@pc33.atlanta.com" 
            ; "CSeq: 314159 INVITE"
            ; "Contact: <sip:alice@pc33.atlanta.com>"
            ; "Content-Type: application/sdp"
            ; "Content-Length: 142"
            ; ""
            ; String.repeat "a" 142
            ]

            [ descr_max_forwards 70
            ; descr_sip_version (UnknownSipVersion "1.5")
            ; descr_content_length 142

            ; descr_mime_fields "Via"
                [ "SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
                ]
            ]


    ]

end


module Invalid_messages = struct
    open Util

    let messages =
        [ prepare_invalid_message "basic invite RFC3261.4, without the Contact header"
            [ "INVITE sip:bob@biloxi.com SIP/2.0" 
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
            ; "Max-Forwards: 70" 
            ; "To: Bob <sip:bob@biloxi.com>" 
            ; "From: Alice <sip:alice@atlanta.com>;tag=1928301774" 
            ; "Call-ID: a84b4c76e66710@pc33.atlanta.com" 
            ; "CSeq: 314159 INVITE"
            ; "Content-Type: application/sdp"
            ; "Content-Length: 142"
            ; ""
            ; String.repeat "a" 142
            ]

        ; prepare_invalid_message "basic invite RFC3261.4, without the Call-ID header"
            [ "INVITE sip:bob@biloxi.com SIP/2.0" 
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
            ; "Max-Forwards: 70" 
            ; "To: Bob <sip:bob@biloxi.com>" 
            ; "From: Alice <sip:alice@atlanta.com>;tag=1928301774" 
            ; "CSeq: 314159 INVITE"
            ; "Contact: <sip:alice@pc33.atlanta.com>"
            ; "Content-Type: application/sdp"
            ; "Content-Length: 142"
            ; ""
            ; String.repeat "a" 142
            ]

        ; prepare_invalid_message "basic invite RFC3261.4, without the CSeq header"
            [ "INVITE sip:bob@biloxi.com SIP/2.0" 
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
            ; "Max-Forwards: 70" 
            ; "To: Bob <sip:bob@biloxi.com>" 
            ; "From: Alice <sip:alice@atlanta.com>;tag=1928301774" 
            ; "Call-ID: a84b4c76e66710@pc33.atlanta.com" 
            ; "Contact: <sip:alice@pc33.atlanta.com>"
            ; "Content-Type: application/sdp"
            ; "Content-Length: 142"
            ; ""
            ; String.repeat "a" 142
            ]

        ; prepare_invalid_message "basic invite RFC3261.4, without the Max-forwards header"
            [ "INVITE sip:bob@biloxi.com SIP/2.0" 
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
            ; "To: Bob <sip:bob@biloxi.com>" 
            ; "From: Alice <sip:alice@atlanta.com>;tag=1928301774" 
            ; "Call-ID: a84b4c76e66710@pc33.atlanta.com" 
            ; "CSeq: 314159 INVITE"
            ; "Contact: <sip:alice@pc33.atlanta.com>"
            ; "Content-Type: application/sdp"
            ; "Content-Length: 142"
            ; ""
            ; String.repeat "a" 142
            ]

        ; prepare_invalid_message "basic invite RFC3261.4, without MIME"
            [ "INVITE sip:bob@biloxi.com SIP/2.0" 
            ; ""
            ]

        ; prepare_invalid_message "basic invite RFC3261.4, as HTTP/1.1 message"
            [ "INVITE sip:bob@biloxi.com HTTP/1.1" 
            ; "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" 
            ; "Max-Forwards: 70" 
            ; "To: Bob <sip:bob@biloxi.com>" 
            ; "From: Alice <sip:alice@atlanta.com>;tag=1928301774" 
            ; "Call-ID: a84b4c76e66710@pc33.atlanta.com" 
            ; "CSeq: 314159 INVITE"
            ; "Contact: <sip:alice@pc33.atlanta.com>"
            ; "Content-Type: application/sdp"
            ; "Content-Length: 142"
            ; ""
            ; String.repeat "a" 142
            ]
        ]


end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.