93 lines
1.7 KiB
C
93 lines
1.7 KiB
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// SIP Methods
|
|
typedef enum {
|
|
SIP_METHOD_UNKNOWN = 0,
|
|
SIP_METHOD_INVITE,
|
|
SIP_METHOD_ACK,
|
|
SIP_METHOD_BYE,
|
|
SIP_METHOD_CANCEL,
|
|
SIP_METHOD_REGISTER,
|
|
SIP_METHOD_OPTIONS,
|
|
SIP_METHOD_INFO,
|
|
SIP_METHOD_UPDATE,
|
|
SIP_METHOD_PRACK
|
|
} sip_method_t;
|
|
|
|
// Geparste SIP-Nachricht
|
|
typedef struct {
|
|
bool is_request; // true = Request, false = Response
|
|
|
|
// Request Line
|
|
sip_method_t method;
|
|
char request_uri[128];
|
|
|
|
// Status Line (Response)
|
|
int status_code;
|
|
char reason_phrase[64];
|
|
|
|
// Headers
|
|
char via[256];
|
|
char from[256];
|
|
char from_tag[64];
|
|
char to[256];
|
|
char to_tag[64];
|
|
char call_id[128];
|
|
int cseq;
|
|
sip_method_t cseq_method;
|
|
char contact[256];
|
|
int content_length;
|
|
char content_type[64];
|
|
|
|
// Authorization
|
|
char www_authenticate[512];
|
|
char proxy_authenticate[512];
|
|
|
|
// SDP Body
|
|
char sdp_body[2048];
|
|
bool has_sdp;
|
|
|
|
// RTP Info aus SDP
|
|
char rtp_ip[32];
|
|
uint16_t rtp_port;
|
|
uint8_t rtp_payload_type;
|
|
|
|
} sip_message_t;
|
|
|
|
/**
|
|
* Parst eine SIP-Nachricht
|
|
*/
|
|
int sip_parse_message(const char* data, size_t len, sip_message_t* msg);
|
|
|
|
/**
|
|
* Extrahiert URI aus Header
|
|
*/
|
|
int sip_extract_uri(const char* header, char* uri, size_t uri_len);
|
|
|
|
/**
|
|
* Extrahiert Tag aus Header
|
|
*/
|
|
int sip_extract_tag(const char* header, char* tag, size_t tag_len);
|
|
|
|
/**
|
|
* Extrahiert Display-Name aus Header
|
|
*/
|
|
int sip_extract_display_name(const char* header, char* name, size_t name_len);
|
|
|
|
/**
|
|
* Parst SDP und extrahiert RTP-Info
|
|
*/
|
|
int sip_parse_sdp(sip_message_t* msg);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|