* Get OSP token from SIP message * param msg SIP message * param token OSP authorization token * param tokensize Size of OSP authorization token * return 0 success, -1 failure */
| 1078 | * return 0 success, -1 failure |
| 1079 | */ |
| 1080 | int ospGetOspToken( |
| 1081 | struct sip_msg* msg, |
| 1082 | unsigned char* token, |
| 1083 | unsigned int* tokensize) |
| 1084 | { |
| 1085 | struct hdr_field* hf; |
| 1086 | int errorcode; |
| 1087 | int result = -1; |
| 1088 | |
| 1089 | if (parse_headers(msg, HDR_EOH_F, 0) == 0) { |
| 1090 | hf = get_header_by_name(msg, OSP_TOKENHEADER_NAME, OSP_TOKENHEADER_SIZE); |
| 1091 | if (hf) { |
| 1092 | if ((errorcode = OSPPBase64Decode(hf->body.s, hf->body.len, token, tokensize)) == OSPC_ERR_NO_ERROR) { |
| 1093 | result = 0; |
| 1094 | } else { |
| 1095 | LM_ERR("failed to base64 decode token (%d)\n", errorcode); |
| 1096 | LM_ERR("header '%.*s' length %d\n", |
| 1097 | hf->body.len, hf->body.s, hf->body.len); |
| 1098 | } |
| 1099 | } |
| 1100 | } else { |
| 1101 | LM_ERR("failed to parse all headers\n"); |
| 1102 | } |
| 1103 | |
| 1104 | return result; |
| 1105 | } |
| 1106 | |
| 1107 | /* |
| 1108 | * Get first VIA header and use the IP or host name |
no test coverage detected