test_imsaka.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. #ifndef _TEST_IMS_AKA_H
  23. #define _TEST_IMS_AKA_H
  24. #include "tinysip/authentication/tsip_challenge.h" /* Not part of the API */
  25. #define TEST_IMS_AKA_REQUEST "REGISTER sip:ims.inexbee.com SIP/2.0\r\n" \
  26. "v: SIP/2.0/TCP 192.168.16.82:2851;branch=z9hG4bK1272986926192;rport\r\n" \
  27. "f: <sip:bob@ims.inexbee.com>;tag=1272986909384\r\n" \
  28. "t: <sip:bob@ims.inexbee.com>\r\n" \
  29. "m: <sip:bob@192.168.16.82:2851;transport=tcp>;expires=30;+g.oma.sip-im;+g.3gpp.smsip;language=\"en,fr\"\r\n" \
  30. "i: ef566354-2051-df74-b888-1d30e1753213\r\n" \
  31. "CSeq: 30149 REGISTER\r\n" \
  32. "l: 0\r\n" \
  33. "Max-Forwards: 70\r\n" \
  34. "Authorization: Digest username=\"bob@ims.inexbee.com\",realm=\"ims.inexbee.com\",nonce=\"\",uri=\"sip:ims.inexbee.com\",response=\"\"\r\n" \
  35. "Privacy: header;id\r\n" \
  36. "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n" \
  37. "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n" \
  38. "User-Agent: IM-client/OMA1.0 doubango/v1.0.0\r\n" \
  39. "P-Preferred-Identity: <sip:bob@ims.inexbee.com>\r\n" \
  40. "k: path\r\n" \
  41. "Action-Header: Myheader-value\r\n" \
  42. "\r\n"
  43. void test_imsaka()
  44. {
  45. tsip_challenge_t* challenge;
  46. tsip_stack_handle_t *stack;
  47. tsip_request_t *request = tsk_null;
  48. tsk_ragel_state_t state;
  49. tsip_header_Authorization_t* hdr_Auth;
  50. /* create the SIP stack */
  51. stack = tsip_stack_create(tsk_null, "sip:ims.inexbee.com", "bob@ims.inexbee.com", "sip:bob@ims.inexbee.com",
  52. TSIP_STACK_SET_PASSWORD("bob"),
  53. TSIP_STACK_SET_NULL());
  54. /* create the chalenge */
  55. challenge = tsip_challenge_create(stack,
  56. tsk_false,
  57. "Digest", /* scheme */
  58. "ims.inexbee.com", /* realm */
  59. "RqhHfrN+ciXaM4mt8k/0Lyx7bgshVgAA5TcTpiTtqsY=", /* nonce */
  60. tsk_null, /* opaque */
  61. "AKAv1-MD5", /* algorithm */
  62. "auth" /* qop */
  63. );
  64. /* Parse SIP request */
  65. tsk_ragel_state_init(&state, TEST_IMS_AKA_REQUEST, tsk_strlen(TEST_IMS_AKA_REQUEST));
  66. if(!tsip_message_parse(&state, &request, tsk_true)) {
  67. goto bail;
  68. }
  69. /* Gets auth header */
  70. if((hdr_Auth = (tsip_header_Authorization_t*)tsip_challenge_create_header_authorization(challenge, request))) {
  71. TSK_DEBUG_INFO("Response=[%s]", hdr_Auth->response);
  72. }
  73. bail:
  74. TSK_OBJECT_SAFE_FREE(request);
  75. TSK_OBJECT_SAFE_FREE(challenge);
  76. TSK_OBJECT_SAFE_FREE(stack);
  77. getchar();
  78. }
  79. #endif /* _TEST_IMS_AKA_H */