Asterisk - The Open Source Telephony Project  18.5.0
Macros | Functions | Variables
res_pjsip_stir_shaken.c File Reference
#include "asterisk.h"
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_session.h"
#include "asterisk/module.h"
#include "asterisk/res_stir_shaken.h"
Include dependency graph for res_pjsip_stir_shaken.c:

Go to the source code of this file.

Macros

#define AST_BUILDOPT_SUM   ""
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static void add_date_header (const struct ast_sip_session *session, pjsip_tx_data *tdata)
 
static int add_identity_header (const struct ast_sip_session *session, pjsip_tx_data *tdata)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int compare_caller_id (char *caller_id, const char *json_str)
 Compare the caller ID from the INVITE with the one in the payload. More...
 
static int compare_timestamp (const char *json_str)
 Compare the current timestamp with the one in the payload. If the difference is greater than the signature timeout, it's not valid anymore. More...
 
static char * get_attestation_from_payload (const char *json_str)
 Get the attestation from the payload. More...
 
static int load_module (void)
 
static int stir_shaken_incoming_request (struct ast_sip_session *session, pjsip_rx_data *rdata)
 
static void stir_shaken_outgoing_request (struct ast_sip_session *session, pjsip_tx_data *tdata)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "PJSIP STIR/SHAKEN Module for Asterisk" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .requires = "res_pjsip,res_pjsip_session,res_stir_shaken", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_sip_session_supplement stir_shaken_supplement
 

Macro Definition Documentation

◆ AST_BUILDOPT_SUM

#define AST_BUILDOPT_SUM   ""

Definition at line 373 of file res_pjsip_stir_shaken.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 381 of file res_pjsip_stir_shaken.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 381 of file res_pjsip_stir_shaken.c.

◆ add_date_header()

static void add_date_header ( const struct ast_sip_session session,
pjsip_tx_data *  tdata 
)
static

Definition at line 320 of file res_pjsip_stir_shaken.c.

References ast_debug, ast_sip_add_date_header(), and NULL.

Referenced by stir_shaken_outgoing_request().

321 {
322  static const pj_str_t date_str = { "Date", 4 };
323  pjsip_fromto_hdr *old_date;
324 
325  old_date = pjsip_msg_find_hdr_by_name(tdata->msg, &date_str, NULL);
326  if (old_date) {
327  ast_debug(3, "Found old STIR/SHAKEN date header, no need to add one\n");
328  return;
329  }
330 
332 }
#define NULL
Definition: resample.c:96
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
void ast_sip_add_date_header(pjsip_tx_data *tdata)
Adds a Date header to the tdata, formatted like: Date: Wed, 01 Jan 2021 14:53:01 GMT.
Definition: res_pjsip.c:3288

◆ add_identity_header()

static int add_identity_header ( const struct ast_sip_session session,
pjsip_tx_data *  tdata 
)
static

Definition at line 211 of file res_pjsip_stir_shaken.c.

References ast_base64url_encode_string(), ast_calloc, ast_copy_pj_str(), ast_free, ast_json_dump_string, ast_json_free(), ast_json_object_get(), ast_json_pack(), ast_log, ast_malloc, ast_stir_shaken_payload_free(), ast_stir_shaken_payload_get_public_cert_url(), ast_stir_shaken_payload_get_signature(), ast_stir_shaken_sign(), ast_sip_session::id, LOG_ERROR, NULL, ast_party_id::number, ast_stir_shaken_payload::public_cert_url, RAII_VAR, ast_stir_shaken_payload::signature, STIR_SHAKEN_ENCRYPTION_ALGORITHM, STIR_SHAKEN_PPT, and ast_party_number::str.

Referenced by stir_shaken_outgoing_request().

212 {
213  static const pj_str_t identity_str = { "Identity", 8 };
214  pjsip_generic_string_hdr *identity_hdr;
215  pj_str_t identity_val;
216  pjsip_fromto_hdr *old_identity;
217  pjsip_fromto_hdr *to;
218  pjsip_sip_uri *uri;
219  char *signature;
220  char *public_cert_url;
221  struct ast_json *header;
222  struct ast_json *payload;
223  char *dumped_string;
224  RAII_VAR(char *, dest_tn, NULL, ast_free);
225  RAII_VAR(struct ast_json *, json, NULL, ast_json_free);
227  RAII_VAR(char *, encoded_header, NULL, ast_free);
228  RAII_VAR(char *, encoded_payload, NULL, ast_free);
229  RAII_VAR(char *, combined_str, NULL, ast_free);
230  size_t combined_size;
231 
232  old_identity = pjsip_msg_find_hdr_by_name(tdata->msg, &identity_str, NULL);
233  if (old_identity) {
234  return 0;
235  }
236 
237  to = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_TO, NULL);
238  if (!to) {
239  ast_log(LOG_ERROR, "Failed to find To header while adding STIR/SHAKEN Identity header\n");
240  return -1;
241  }
242 
243  uri = pjsip_uri_get_uri(to->uri);
244  if (!uri) {
245  ast_log(LOG_ERROR, "Failed to retrieve URI from To header while adding STIR/SHAKEN Identity header\n");
246  return -1;
247  }
248 
249  dest_tn = ast_malloc(uri->user.slen + 1);
250  if (!dest_tn) {
251  ast_log(LOG_ERROR, "Failed to allocate memory for STIR/SHAKEN dest->tn\n");
252  return -1;
253  }
254 
255  ast_copy_pj_str(dest_tn, &uri->user, uri->user.slen + 1);
256 
257  /* x5u (public key URL), attestation, and origid will be added by ast_stir_shaken_sign */
258  json = ast_json_pack("{s: {s: s, s: s, s: s}, s: {s: {s: s}, s: {s: s}}}",
259  "header", "alg", "ES256", "ppt", "shaken", "typ", "passport",
260  "payload", "dest", "tn", dest_tn, "orig", "tn",
261  session->id.number.str);
262  if (!json) {
263  ast_log(LOG_ERROR, "Failed to allocate memory for STIR/SHAKEN JSON\n");
264  return -1;
265  }
266 
267  ss_payload = ast_stir_shaken_sign(json);
268  if (!ss_payload) {
269  ast_log(LOG_ERROR, "Failed to allocate memory for STIR/SHAKEN payload\n");
270  return -1;
271  }
272 
273  header = ast_json_object_get(json, "header");
274  dumped_string = ast_json_dump_string(header);
275  encoded_header = ast_base64url_encode_string(dumped_string);
276  ast_json_free(dumped_string);
277  if (!encoded_header) {
278  ast_log(LOG_ERROR, "Failed to encode STIR/SHAKEN header\n");
279  return -1;
280  }
281 
282  payload = ast_json_object_get(json, "payload");
283  dumped_string = ast_json_dump_string(payload);
284  encoded_payload = ast_base64url_encode_string(dumped_string);
285  ast_json_free(dumped_string);
286  if (!encoded_payload) {
287  ast_log(LOG_ERROR, "Failed to encode STIR/SHAKEN payload\n");
288  return -1;
289  }
290 
291  signature = (char *)ast_stir_shaken_payload_get_signature(ss_payload);
292  public_cert_url = ast_stir_shaken_payload_get_public_cert_url(ss_payload);
293 
294  /* The format for the identity header:
295  * header.payload.signature;info=<public_cert_url>alg=STIR_SHAKEN_ENCRYPTION_ALGORITHM;ppt=STIR_SHAKEN_PPT
296  */
297  combined_size = strlen(encoded_header) + 1 + strlen(encoded_payload) + 1
298  + strlen(signature) + strlen(";info=<>alg=;ppt=") + strlen(public_cert_url)
299  + strlen(STIR_SHAKEN_ENCRYPTION_ALGORITHM) + strlen(STIR_SHAKEN_PPT) + 1;
300  combined_str = ast_calloc(1, combined_size);
301  if (!combined_str) {
302  ast_log(LOG_ERROR, "Failed to allocate memory for STIR/SHAKEN identity string\n");
303  return -1;
304  }
305  snprintf(combined_str, combined_size, "%s.%s.%s;info=<%s>alg=%s;ppt=%s", encoded_header,
306  encoded_payload, signature, public_cert_url, STIR_SHAKEN_ENCRYPTION_ALGORITHM, STIR_SHAKEN_PPT);
307 
308  identity_val = pj_str(combined_str);
309  identity_hdr = pjsip_generic_string_hdr_create(tdata->pool, &identity_str, &identity_val);
310  if (!identity_hdr) {
311  ast_log(LOG_ERROR, "Failed to create STIR/SHAKEN Identity header\n");
312  return -1;
313  }
314 
315  pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)identity_hdr);
316 
317  return 0;
318 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
void ast_json_free(void *p)
Asterisk&#39;s custom JSON allocator. Exposed for use by unit tests.
Definition: json.c:52
#define ast_json_dump_string(root)
Encode a JSON value to a compact string.
Definition: json.h:763
char * ast_stir_shaken_payload_get_public_cert_url(const struct ast_stir_shaken_payload *payload)
Retrieve the value for &#39;public_cert_url&#39; from an ast_stir_shaken_payload.
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
Definition: res_pjsip.c:5240
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
struct ast_stir_shaken_payload * ast_stir_shaken_sign(struct ast_json *json)
Sign a JSON STIR/SHAKEN payload.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
char * ast_base64url_encode_string(const char *src)
Encode string in base64 URL.
Definition: main/utils.c:521
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
#define STIR_SHAKEN_ENCRYPTION_ALGORITHM
#define LOG_ERROR
Definition: logger.h:285
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
unsigned char * ast_stir_shaken_payload_get_signature(const struct ast_stir_shaken_payload *payload)
Retrieve the value for &#39;signature&#39; from an ast_stir_shaken_payload.
#define STIR_SHAKEN_PPT
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
Abstract JSON element (object, array, string, int, ...).
void ast_stir_shaken_payload_free(struct ast_stir_shaken_payload *payload)
Free a STIR/SHAKEN payload.
struct ast_party_id id
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 381 of file res_pjsip_stir_shaken.c.

◆ compare_caller_id()

static int compare_caller_id ( char *  caller_id,
const char *  json_str 
)
static

Compare the caller ID from the INVITE with the one in the payload.

Parameters
json_strThe JSON string represntation of the payload
Return values
-1on failure
0on success

Definition at line 66 of file res_pjsip_stir_shaken.c.

References ast_json_free(), ast_json_load_string(), ast_json_object_get(), ast_json_string_get(), NULL, and RAII_VAR.

Referenced by stir_shaken_incoming_request().

67 {
68  RAII_VAR(struct ast_json *, json, NULL, ast_json_free);
69  char *caller_id_other;
70 
71  json = ast_json_load_string(json_str, NULL);
72  caller_id_other = (char *)ast_json_string_get(ast_json_object_get(
73  ast_json_object_get(json, "orig"), "tn"));
74 
75  if (strcmp(caller_id, caller_id_other)) {
76  return -1;
77  }
78 
79  return 0;
80 }
void ast_json_free(void *p)
Asterisk&#39;s custom JSON allocator. Exposed for use by unit tests.
Definition: json.c:52
struct ast_json * ast_json_load_string(const char *input, struct ast_json_error *error)
Parse null terminated string into a JSON object or array.
Definition: json.c:546
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
Abstract JSON element (object, array, string, int, ...).

◆ compare_timestamp()

static int compare_timestamp ( const char *  json_str)
static

Compare the current timestamp with the one in the payload. If the difference is greater than the signature timeout, it's not valid anymore.

Parameters
json_strThe JSON string representation of the payload
Return values
-1on failure
0on success

Definition at line 91 of file res_pjsip_stir_shaken.c.

References ast_debug, ast_json_free(), ast_json_integer_get(), ast_json_load_string(), ast_json_object_get(), ast_stir_shaken_get_signature_timeout(), ast_tvnow(), NULL, and RAII_VAR.

Referenced by stir_shaken_incoming_request().

92 {
93  RAII_VAR(struct ast_json *, json, NULL, ast_json_free);
94  long int timestamp;
95  struct timeval now = ast_tvnow();
96 
97 #ifdef TEST_FRAMEWORK
98  ast_debug(3, "Ignoring STIR/SHAKEN timestamp\n");
99  return 0;
100 #endif
101 
102  json = ast_json_load_string(json_str, NULL);
103  timestamp = ast_json_integer_get(ast_json_object_get(json, "iat"));
104 
105  if (now.tv_sec - timestamp > ast_stir_shaken_get_signature_timeout()) {
106  return -1;
107  }
108 
109  return 0;
110 }
void ast_json_free(void *p)
Asterisk&#39;s custom JSON allocator. Exposed for use by unit tests.
Definition: json.c:52
unsigned int ast_stir_shaken_get_signature_timeout(void)
Retrieve the value for &#39;signature_timeout&#39; from &#39;general&#39; config object.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
struct ast_json * ast_json_load_string(const char *input, struct ast_json_error *error)
Parse null terminated string into a JSON object or array.
Definition: json.c:546
#define NULL
Definition: resample.c:96
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
Abstract JSON element (object, array, string, int, ...).
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ get_attestation_from_payload()

static char* get_attestation_from_payload ( const char *  json_str)
static

Get the attestation from the payload.

Parameters
json_strThe JSON string representation of the payload
Return values
Emptystring on failure
Theattestation on success

Definition at line 43 of file res_pjsip_stir_shaken.c.

References ast_json_free(), ast_json_load_string(), ast_json_object_get(), ast_json_string_get(), ast_strlen_zero, NULL, and RAII_VAR.

Referenced by stir_shaken_incoming_request().

44 {
45  RAII_VAR(struct ast_json *, json, NULL, ast_json_free);
46  char *attestation;
47 
48  json = ast_json_load_string(json_str, NULL);
49  attestation = (char *)ast_json_string_get(ast_json_object_get(json, "attest"));
50 
51  if (!ast_strlen_zero(attestation)) {
52  return attestation;
53  }
54 
55  return "";
56 }
void ast_json_free(void *p)
Asterisk&#39;s custom JSON allocator. Exposed for use by unit tests.
Definition: json.c:52
struct ast_json * ast_json_load_string(const char *input, struct ast_json_error *error)
Parse null terminated string into a JSON object or array.
Definition: json.c:546
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
Abstract JSON element (object, array, string, int, ...).

◆ load_module()

static int load_module ( void  )
static

Definition at line 366 of file res_pjsip_stir_shaken.c.

References AST_MODULE_LOAD_SUCCESS, and ast_sip_session_register_supplement.

367 {
370 }
static struct ast_sip_session_supplement stir_shaken_supplement
#define ast_sip_session_register_supplement(supplement)

◆ stir_shaken_incoming_request()

static int stir_shaken_incoming_request ( struct ast_sip_session session,
pjsip_rx_data *  rdata 
)
static

Definition at line 122 of file res_pjsip_stir_shaken.c.

References ast_base64url_decode_string(), ast_begins_with(), ast_free, ast_sip_rdata_get_header_value(), ast_stir_shaken_add_verification(), ast_stir_shaken_payload_free(), ast_stir_shaken_verify(), AST_STIR_SHAKEN_VERIFY_MISMATCH, AST_STIR_SHAKEN_VERIFY_NOT_PRESENT, AST_STIR_SHAKEN_VERIFY_PASSED, AST_STIR_SHAKEN_VERIFY_SIGNATURE_FAILED, ast_strlen_zero, ast_sip_session::channel, compare_caller_id(), compare_timestamp(), ast_sip_session::endpoint, get_attestation_from_payload(), ast_sip_session::id, NULL, ast_party_id::number, ast_stir_shaken_payload::payload, RAII_VAR, ast_sip_endpoint::stir_shaken, and ast_party_number::str.

123 {
124  static const pj_str_t identity_str = { "Identity", 8 };
125  char *identity_hdr_val;
126  char *encoded_val;
127  struct ast_channel *chan = session->channel;
128  char *caller_id = session->id.number.str;
129  RAII_VAR(char *, header, NULL, ast_free);
130  RAII_VAR(char *, payload, NULL, ast_free);
131  char *signature;
132  char *algorithm;
133  char *public_cert_url;
134  char *attestation;
135  int mismatch = 0;
136  struct ast_stir_shaken_payload *ss_payload;
137 
138  if (!session->endpoint->stir_shaken) {
139  return 0;
140  }
141 
142  identity_hdr_val = ast_sip_rdata_get_header_value(rdata, identity_str);
143  if (ast_strlen_zero(identity_hdr_val)) {
145  return 0;
146  }
147 
148  encoded_val = strtok_r(identity_hdr_val, ".", &identity_hdr_val);
149  header = ast_base64url_decode_string(encoded_val);
150  if (ast_strlen_zero(header)) {
152  return 0;
153  }
154 
155  encoded_val = strtok_r(identity_hdr_val, ".", &identity_hdr_val);
156  payload = ast_base64url_decode_string(encoded_val);
157  if (ast_strlen_zero(payload)) {
159  return 0;
160  }
161 
162  /* It's fine to leave the signature encoded */
163  signature = strtok_r(identity_hdr_val, ";", &identity_hdr_val);
164  if (ast_strlen_zero(signature)) {
166  return 0;
167  }
168 
169  /* Trim "info=<" to get public cert URL */
170  strtok_r(identity_hdr_val, "<", &identity_hdr_val);
171  public_cert_url = strtok_r(identity_hdr_val, ">", &identity_hdr_val);
172  if (ast_strlen_zero(public_cert_url)) {
174  return 0;
175  }
176 
177  /* Make sure the public URL is actually a URL */
178  if (!ast_begins_with(public_cert_url, "http")) {
180  return 0;
181  }
182 
183  algorithm = strtok_r(identity_hdr_val, ";", &identity_hdr_val);
184  if (ast_strlen_zero(algorithm)) {
186  return 0;
187  }
188 
189  attestation = get_attestation_from_payload(payload);
190 
191  ss_payload = ast_stir_shaken_verify(header, payload, signature, algorithm, public_cert_url);
192  if (!ss_payload) {
194  return 0;
195  }
196  ast_stir_shaken_payload_free(ss_payload);
197 
198  mismatch |= compare_caller_id(caller_id, payload);
199  mismatch |= compare_timestamp(payload);
200 
201  if (mismatch) {
203  return 0;
204  }
205 
207 
208  return 0;
209 }
Main Channel structure associated with a channel.
struct ast_sip_endpoint * endpoint
char * ast_base64url_decode_string(const char *src)
Decode string from base64 URL.
Definition: main/utils.c:448
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
char * ast_sip_rdata_get_header_value(pjsip_rx_data *rdata, const pj_str_t str)
Get a specific header value from rdata.
Definition: res_pjsip.c:3543
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
static int compare_timestamp(const char *json_str)
Compare the current timestamp with the one in the payload. If the difference is greater than the sign...
struct ast_channel * channel
static char * get_attestation_from_payload(const char *json_str)
Get the attestation from the payload.
struct ast_stir_shaken_payload * ast_stir_shaken_verify(const char *header, const char *payload, const char *signature, const char *algorithm, const char *public_cert_url)
Verify a JSON STIR/SHAKEN payload.
int ast_stir_shaken_add_verification(struct ast_channel *chan, const char *identity, const char *attestation, enum ast_stir_shaken_verification_result result)
Add a STIR/SHAKEN verification result to a channel.
#define ast_free(a)
Definition: astmm.h:182
struct ast_json * payload
static int compare_caller_id(char *caller_id, const char *json_str)
Compare the caller ID from the INVITE with the one in the payload.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Definition: strings.h:94
void ast_stir_shaken_payload_free(struct ast_stir_shaken_payload *payload)
Free a STIR/SHAKEN payload.
unsigned int stir_shaken
Definition: res_pjsip.h:903
struct ast_party_id id
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ stir_shaken_outgoing_request()

static void stir_shaken_outgoing_request ( struct ast_sip_session session,
pjsip_tx_data *  tdata 
)
static

Definition at line 334 of file res_pjsip_stir_shaken.c.

References add_date_header(), add_identity_header(), ast_strlen_zero, ast_sip_session::endpoint, ast_sip_session::id, ast_party_id::number, ast_sip_endpoint::stir_shaken, ast_party_number::str, and ast_party_number::valid.

335 {
336  if (!session->endpoint->stir_shaken) {
337  return;
338  }
339 
340  if (ast_strlen_zero(session->id.number.str) && session->id.number.valid) {
341  return;
342  }
343 
344  /* If adding the Identity header fails for some reason, there's no point
345  * adding the Date header.
346  */
347  if ((add_identity_header(session, tdata)) != 0) {
348  return;
349  }
350  add_date_header(session, tdata);
351 }
struct ast_sip_endpoint * endpoint
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
static int add_identity_header(const struct ast_sip_session *session, pjsip_tx_data *tdata)
static void add_date_header(const struct ast_sip_session *session, pjsip_tx_data *tdata)
#define ast_strlen_zero(foo)
Definition: strings.h:52
unsigned int stir_shaken
Definition: res_pjsip.h:903
struct ast_party_id id
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 360 of file res_pjsip_stir_shaken.c.

References ast_sip_session_unregister_supplement().

361 {
363  return 0;
364 }
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.
Definition: pjsip_session.c:63
static struct ast_sip_session_supplement stir_shaken_supplement

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "PJSIP STIR/SHAKEN Module for Asterisk" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .requires = "res_pjsip,res_pjsip_session,res_stir_shaken", }
static

Definition at line 381 of file res_pjsip_stir_shaken.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 381 of file res_pjsip_stir_shaken.c.

◆ stir_shaken_supplement

struct ast_sip_session_supplement stir_shaken_supplement
static

Definition at line 353 of file res_pjsip_stir_shaken.c.