Wed Jan 8 2020 09:50:13

Asterisk developer's documentation


http.h File Reference

Support for Private Asterisk HTTP Servers. More...

Go to the source code of this file.

Data Structures

struct  ast_http_uri
 Definition of a URI handler. More...
 

Typedefs

typedef int(* ast_http_callback )(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
 HTTP Callbacks. More...
 

Enumerations

enum  ast_http_method {
  AST_HTTP_UNKNOWN = -1, AST_HTTP_GET = 0, AST_HTTP_POST, AST_HTTP_HEAD,
  AST_HTTP_PUT
}
 HTTP Request methods known by Asterisk. More...
 

Functions

const char * ast_get_http_method (enum ast_http_method method) attribute_pure
 Return http method name string. More...
 
void ast_http_auth (struct ast_tcptls_session_instance *ser, const char *realm, const unsigned long nonce, const unsigned long opaque, int stale, const char *text)
 Send http "401 Unauthorized" response and close socket. More...
 
void ast_http_error (struct ast_tcptls_session_instance *ser, int status, const char *title, const char *text)
 Send HTTP error message and close socket. More...
 
const char * ast_http_ftype2mtype (const char *ftype) attribute_pure
 Return mime type based on extension. More...
 
struct ast_variableast_http_get_cookies (struct ast_variable *headers)
 Get cookie from Request headers. More...
 
struct ast_variableast_http_get_post_vars (struct ast_tcptls_session_instance *ser, struct ast_variable *headers)
 Get post variables from client Request Entity-Body, if content type is application/x-www-form-urlencoded. More...
 
uint32_t ast_http_manid_from_vars (struct ast_variable *headers) attribute_pure
 Return manager id, if exist, from request headers. More...
 
void ast_http_prefix (char *buf, int len)
 Return the current prefix. More...
 
void ast_http_send (struct ast_tcptls_session_instance *ser, enum ast_http_method method, int status_code, const char *status_title, struct ast_str *http_header, struct ast_str *out, const int fd, unsigned int static_content)
 Generic function for sending http/1.1 response. More...
 
int ast_http_uri_link (struct ast_http_uri *urihandler)
 Register a URI handler. More...
 
void ast_http_uri_unlink (struct ast_http_uri *urihandler)
 Unregister a URI handler. More...
 
void ast_http_uri_unlink_all_with_key (const char *key)
 Unregister all handlers with matching key. More...
 

Detailed Description

Support for Private Asterisk HTTP Servers.

Note
Note: The Asterisk HTTP servers are extremely simple and minimal and only support the "GET" method.
Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
Note
In order to have TLS/SSL support, we need the openssl libraries. Still we can decide whether or not to use them by commenting in or out the DO_SSL macro. TLS/SSL support is basically implemented by reading from a config file (currently http.conf) the names of the certificate and cipher to use, and then run ssl_setup() to create an appropriate SSL_CTX (ssl_ctx) If we support multiple domains, presumably we need to read multiple certificates. When we are requested to open a TLS socket, we run make_file_from_fd() on the socket, to do the necessary setup. At the moment the context's name is hardwired in the function, but we can certainly make it into an extra parameter to the function. We declare most of ssl support variables unconditionally, because their number is small and this simplifies the code.
: the ssl-support variables (ssl_ctx, do_ssl, certfile, cipher) and their setup should be moved to a more central place, e.g. asterisk.conf and the source files that processes it. Similarly, ssl_setup() should be run earlier in the startup process so modules have it available.

Definition in file http.h.

Typedef Documentation

typedef int(* ast_http_callback)(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)

HTTP Callbacks.

Note
The callback function receives server instance, uri, http method, get method (if present in URI), and http headers as arguments and should use the ast_http_send() function for sending content allocated with ast_str and/or content from an opened file descriptor.

Status and status text should be sent as arguments to the ast_http_send() function to reflect the status of the request (200 or 304, for example). Content length is calculated by ast_http_send() automatically.

Static content may be indicated to the ast_http_send() function, to indicate that it may be cached.

* The return value may include additional headers at the front and MUST
* include a blank line with \r\n to provide separation between user headers
* and content (even if no content is specified)
* 

For an error response, the ast_http_error() function may be used.

Definition at line 88 of file http.h.

Enumeration Type Documentation

HTTP Request methods known by Asterisk.

Enumerator
AST_HTTP_UNKNOWN 

Unknown response

AST_HTTP_GET 
AST_HTTP_POST 
AST_HTTP_HEAD 
AST_HTTP_PUT 

Not supported in Asterisk

Definition at line 56 of file http.h.

56  {
57  AST_HTTP_UNKNOWN = -1, /*!< Unknown response */
58  AST_HTTP_GET = 0,
61  AST_HTTP_PUT, /*!< Not supported in Asterisk */
62 };

Function Documentation

const char* ast_get_http_method ( enum ast_http_method  method)

Return http method name string.

Since
1.8

Definition at line 153 of file http.c.

References ARRAY_LEN, ast_http_methods_text, and ast_cfhttp_methods_text::text.

Referenced by auth_http_callback().

154 {
155  int x;
156 
157  for (x = 0; x < ARRAY_LEN(ast_http_methods_text); x++) {
158  if (ast_http_methods_text[x].method == method) {
159  return ast_http_methods_text[x].text;
160  }
161  }
162 
163  return NULL;
164 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ast_cfhttp_methods_text ast_http_methods_text[]
const char * text
Definition: http.c:144
void ast_http_auth ( struct ast_tcptls_session_instance ser,
const char *  realm,
const unsigned long  nonce,
const unsigned long  opaque,
int  stale,
const char *  text 
)

Send http "401 Unauthorized" response and close socket.

Definition at line 468 of file http.c.

References ast_free, ast_http_send(), AST_HTTP_UNKNOWN, ast_str_create(), and ast_str_set().

Referenced by auth_http_callback().

471 {
472  struct ast_str *http_headers = ast_str_create(128);
473  struct ast_str *out = ast_str_create(512);
474 
475  if (!http_headers || !out) {
476  ast_free(http_headers);
477  ast_free(out);
478  return;
479  }
480 
481  ast_str_set(&http_headers, 0,
482  "WWW-authenticate: Digest algorithm=MD5, realm=\"%s\", nonce=\"%08lx\", qop=\"auth\", opaque=\"%08lx\"%s\r\n"
483  "Content-type: text/html\r\n",
484  realm ? realm : "Asterisk",
485  nonce,
486  opaque,
487  stale ? ", stale=true" : "");
488 
489  ast_str_set(&out, 0,
490  "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
491  "<html><head>\r\n"
492  "<title>401 Unauthorized</title>\r\n"
493  "</head><body>\r\n"
494  "<h1>401 Unauthorized</h1>\r\n"
495  "<p>%s</p>\r\n"
496  "<hr />\r\n"
497  "<address>Asterisk Server</address>\r\n"
498  "</body></html>\r\n",
499  text ? text : "");
500 
501  ast_http_send(ser, AST_HTTP_UNKNOWN, 401, "Unauthorized", http_headers, out, 0, 0);
502  return;
503 }
struct ast_str * ast_str_create(size_t init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:420
char * text
Definition: app_queue.c:1091
void ast_http_send(struct ast_tcptls_session_instance *ser, enum ast_http_method method, int status_code, const char *status_title, struct ast_str *http_header, struct ast_str *out, const int fd, unsigned int static_content)
Generic function for sending http/1.1 response.
Definition: http.c:393
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:874
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
#define ast_free(a)
Definition: astmm.h:97
void ast_http_error ( struct ast_tcptls_session_instance ser,
int  status,
const char *  title,
const char *  text 
)

Send HTTP error message and close socket.

Definition at line 506 of file http.c.

References ast_free, ast_http_send(), AST_HTTP_UNKNOWN, ast_str_create(), and ast_str_set().

Referenced by auth_http_callback(), generic_http_callback(), handle_uri(), http_post_callback(), httpd_helper_thread(), httpstatus_callback(), and static_callback().

507 {
508  struct ast_str *http_headers = ast_str_create(40);
509  struct ast_str *out = ast_str_create(256);
510 
511  if (!http_headers || !out) {
512  ast_free(http_headers);
513  ast_free(out);
514  return;
515  }
516 
517  ast_str_set(&http_headers, 0, "Content-type: text/html\r\n");
518 
519  ast_str_set(&out, 0,
520  "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
521  "<html><head>\r\n"
522  "<title>%d %s</title>\r\n"
523  "</head><body>\r\n"
524  "<h1>%s</h1>\r\n"
525  "<p>%s</p>\r\n"
526  "<hr />\r\n"
527  "<address>Asterisk Server</address>\r\n"
528  "</body></html>\r\n",
529  status_code, status_title, status_title, text);
530 
531  ast_http_send(ser, AST_HTTP_UNKNOWN, status_code, status_title, http_headers, out, 0, 0);
532  return;
533 }
struct ast_str * ast_str_create(size_t init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:420
char * text
Definition: app_queue.c:1091
void ast_http_send(struct ast_tcptls_session_instance *ser, enum ast_http_method method, int status_code, const char *status_title, struct ast_str *http_header, struct ast_str *out, const int fd, unsigned int static_content)
Generic function for sending http/1.1 response.
Definition: http.c:393
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:874
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
#define ast_free(a)
Definition: astmm.h:97
const char* ast_http_ftype2mtype ( const char *  ftype)

Return mime type based on extension.

Parameters
ftypefilename extension
Returns
String containing associated MIME type
Since
1.8

Definition at line 166 of file http.c.

References ARRAY_LEN, ext, and mimetypes.

Referenced by static_callback().

167 {
168  int x;
169 
170  if (ftype) {
171  for (x = 0; x < ARRAY_LEN(mimetypes); x++) {
172  if (!strcasecmp(ftype, mimetypes[x].ext)) {
173  return mimetypes[x].mtype;
174  }
175  }
176  }
177  return NULL;
178 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
const char * ext
Definition: http.c:112
static struct @274 mimetypes[]
Limit the kinds of files we&#39;re willing to serve up.
struct ast_variable* ast_http_get_cookies ( struct ast_variable headers)

Get cookie from Request headers.

Definition at line 862 of file http.c.

References ast_variables_destroy(), ast_variable::name, ast_variable::next, parse_cookies(), and ast_variable::value.

Referenced by ast_http_manid_from_vars(), generic_http_callback(), http_post_callback(), and httpstatus_callback().

863 {
864  struct ast_variable *v, *cookies = NULL;
865 
866  for (v = headers; v; v = v->next) {
867  if (!strcasecmp(v->name, "Cookie")) {
868  ast_variables_destroy(cookies);
869  cookies = parse_cookies(v->value);
870  }
871  }
872  return cookies;
873 }
static struct ast_variable * parse_cookies(const char *cookies)
Definition: http.c:828
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: config.c:586
const char * value
Definition: config.h:79
const char * name
Definition: config.h:77
struct ast_variable * next
Definition: config.h:82
struct ast_variable* ast_http_get_post_vars ( struct ast_tcptls_session_instance ser,
struct ast_variable headers 
)

Get post variables from client Request Entity-Body, if content type is application/x-www-form-urlencoded.

Parameters
serTCP/TLS session object
headersList of HTTP headers
Returns
List of variables within the POST body
Note
Since returned list is malloc'd, list should be free'd by the calling function
Since
1.8

Definition at line 624 of file http.c.

References ast_free, AST_HTTP_POST, ast_http_send(), ast_log(), ast_malloc, ast_variable_new(), ast_tcptls_session_instance::f, http_decode(), LOG_WARNING, MAX_POST_CONTENT, ast_variable::name, ast_variable::next, strsep(), ast_variable::value, and var.

Referenced by auth_http_callback(), and generic_http_callback().

626 {
627  int content_length = 0;
628  struct ast_variable *v, *post_vars=NULL, *prev = NULL;
629  char *buf, *var, *val;
630  int res;
631 
632  for (v = headers; v; v = v->next) {
633  if (!strcasecmp(v->name, "Content-Type")) {
634  if (strcasecmp(v->value, "application/x-www-form-urlencoded")) {
635  return NULL;
636  }
637  break;
638  }
639  }
640 
641  for (v = headers; v; v = v->next) {
642  if (!strcasecmp(v->name, "Content-Length")) {
643  content_length = atoi(v->value);
644  break;
645  }
646  }
647 
648  if (content_length <= 0) {
649  return NULL;
650  }
651 
652  if (content_length > MAX_POST_CONTENT - 1) {
653  ast_log(LOG_WARNING, "Excessively long HTTP content. %d is greater than our max of %d\n",
654  content_length, MAX_POST_CONTENT);
655  ast_http_send(ser, AST_HTTP_POST, 413, "Request Entity Too Large", NULL, NULL, 0, 0);
656  return NULL;
657  }
658 
659  buf = ast_malloc(content_length + 1);
660  if (!buf) {
661  return NULL;
662  }
663 
664  res = fread(buf, 1, content_length, ser->f);
665  if (res < content_length) {
666  /* Error, distinguishable by ferror() or feof(), but neither
667  * is good. */
668  goto done;
669  }
670  buf[content_length] = '\0';
671 
672  while ((val = strsep(&buf, "&"))) {
673  var = strsep(&val, "=");
674  if (val) {
675  http_decode(val);
676  } else {
677  val = "";
678  }
679  http_decode(var);
680  if ((v = ast_variable_new(var, val, ""))) {
681  if (post_vars) {
682  prev->next = v;
683  } else {
684  post_vars = v;
685  }
686  prev = v;
687  }
688  }
689 
690 done:
691  ast_free(buf);
692  return post_vars;
693 }
char * strsep(char **str, const char *delims)
Definition: ast_expr2.c:325
#define LOG_WARNING
Definition: logger.h:144
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
void ast_http_send(struct ast_tcptls_session_instance *ser, enum ast_http_method method, int status_code, const char *status_title, struct ast_str *http_header, struct ast_str *out, const int fd, unsigned int static_content)
Generic function for sending http/1.1 response.
Definition: http.c:393
const char * value
Definition: config.h:79
const char * name
Definition: config.h:77
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
#define MAX_POST_CONTENT
Definition: http.c:618
static void http_decode(char *s)
Definition: http.c:605
struct ast_variable * next
Definition: config.h:82
#define ast_malloc(a)
Definition: astmm.h:91
struct ast_variable * ast_variable_new(const char *name, const char *value, const char *filename)
Definition: config.c:278
uint32_t ast_http_manid_from_vars ( struct ast_variable headers)

Return manager id, if exist, from request headers.

Parameters
headersList of HTTP headers
Returns
32-bit associated manager session identifier
Since
1.8

Definition at line 180 of file http.c.

References ast_http_get_cookies(), ast_variables_destroy(), ast_variable::name, ast_variable::next, and ast_variable::value.

Referenced by http_post_callback(), and static_callback().

181 {
182  uint32_t mngid = 0;
183  struct ast_variable *v, *cookies;
184 
185  cookies = ast_http_get_cookies(headers);
186  for (v = cookies; v; v = v->next) {
187  if (!strcasecmp(v->name, "mansession_id")) {
188  sscanf(v->value, "%30x", &mngid);
189  break;
190  }
191  }
192  ast_variables_destroy(cookies);
193  return mngid;
194 }
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: config.c:586
const char * value
Definition: config.h:79
const char * name
Definition: config.h:77
struct ast_variable * next
Definition: config.h:82
struct ast_variable * ast_http_get_cookies(struct ast_variable *headers)
Get cookie from Request headers.
Definition: http.c:862
void ast_http_prefix ( char *  buf,
int  len 
)

Return the current prefix.

Parameters
[out]bufdestination buffer for previous
[in]lenlength of prefix to copy
Since
1.6.1

Definition at line 196 of file http.c.

References ast_copy_string().

197 {
198  if (buf) {
199  ast_copy_string(buf, prefix, len);
200  }
201 }
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
static char prefix[MAX_PREFIX]
Definition: http.c:107
void ast_http_send ( struct ast_tcptls_session_instance ser,
enum ast_http_method  method,
int  status_code,
const char *  status_title,
struct ast_str http_header,
struct ast_str out,
const int  fd,
unsigned int  static_content 
)

Generic function for sending http/1.1 response.

Parameters
serTCP/TLS session object
methodGET/POST/HEAD
status_codeHTTP response code (200/401/403/404/500)
status_titleEnglish equivalent to the status_code parameter
http_headerAn ast_str object containing all headers
outAn ast_str object containing the body of the response
fdIf out is NULL, a file descriptor where the body of the response is held (otherwise -1)
static_contentZero if the content is dynamically generated and should not be cached; nonzero otherwise
Note
Function determines the HTTP response header from status_code, status_header, and http_header.

Extra HTTP headers MUST be present only in the http_header argument. The argument "out" should contain only content of the response (no headers!).

HTTP content can be constructed from the argument "out", if it is not NULL; otherwise, the function will read content from FD.

This function calculates the content-length http header itself.

Both the http_header and out arguments will be freed by this function; however, if FD is open, it will remain open.

Since
1.8

Definition at line 393 of file http.c.

References ast_free, ast_get_version(), AST_HTTP_HEAD, ast_localtime(), ast_log(), ast_str_buffer(), ast_str_strlen(), ast_strftime(), ast_tcptls_close_session_file(), ast_tvnow(), errno, ast_tcptls_session_instance::f, len(), LOG_ERROR, and LOG_WARNING.

Referenced by ast_http_auth(), ast_http_error(), ast_http_get_post_vars(), auth_http_callback(), generic_http_callback(), handle_uri(), httpstatus_callback(), and static_callback().

397 {
398  struct timeval now = ast_tvnow();
399  struct ast_tm tm;
400  char timebuf[80];
401  int content_length = 0;
402 
403  if (!ser || 0 == ser->f) {
404  return;
405  }
406 
407  ast_strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", ast_localtime(&now, &tm, "GMT"));
408 
409  /* calc content length */
410  if (out) {
411  content_length += ast_str_strlen(out);
412  }
413 
414  if (fd) {
415  content_length += lseek(fd, 0, SEEK_END);
416  lseek(fd, 0, SEEK_SET);
417  }
418 
419  /* send http header */
420  fprintf(ser->f, "HTTP/1.1 %d %s\r\n"
421  "Server: Asterisk/%s\r\n"
422  "Date: %s\r\n"
423  "Connection: close\r\n"
424  "%s"
425  "Content-Length: %d\r\n"
426  "%s"
427  "\r\n",
428  status_code, status_title ? status_title : "OK",
429  ast_get_version(),
430  timebuf,
431  static_content ? "" : "Cache-Control: no-cache, no-store\r\n",
432  content_length,
433  http_header ? ast_str_buffer(http_header) : ""
434  );
435 
436  /* send content */
437  if (method != AST_HTTP_HEAD || status_code >= 400) {
438  if (out && ast_str_strlen(out)) {
439  if (fwrite(ast_str_buffer(out), ast_str_strlen(out), 1, ser->f) != 1) {
440  ast_log(LOG_ERROR, "fwrite() failed: %s\n", strerror(errno));
441  }
442  }
443 
444  if (fd) {
445  char buf[256];
446  int len;
447  while ((len = read(fd, buf, sizeof(buf))) > 0) {
448  if (fwrite(buf, len, 1, ser->f) != 1) {
449  ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
450  break;
451  }
452  }
453  }
454  }
455 
456  if (http_header) {
457  ast_free(http_header);
458  }
459  if (out) {
460  ast_free(out);
461  }
462 
464  return;
465 }
const char * ast_get_version(void)
Retrieve the Asterisk version string.
Definition: version.c:14
#define LOG_WARNING
Definition: logger.h:144
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Definition: localtime.c:1570
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define LOG_ERROR
Definition: logger.h:155
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
#define ast_free(a)
Definition: astmm.h:97
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Definition: localtime.c:2351
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:471
void ast_tcptls_close_session_file(struct ast_tcptls_session_instance *tcptls_session)
Closes a tcptls session instance&#39;s file and/or file descriptor. The tcptls_session will be set to NUL...
Definition: tcptls.c:1033
int ast_http_uri_link ( struct ast_http_uri urih)

Register a URI handler.

Register a URI handler.

They are sorted by length of the string, not alphabetically. Duplicate entries are not replaced, but the insertion order (using <= and not just <) makes sure that more recent insertions hide older ones. On a lookup, we just scan the list and stop at the first matching entry.

Definition at line 544 of file http.c.

References AST_RWLIST_EMPTY, AST_RWLIST_FIRST, AST_RWLIST_INSERT_AFTER, AST_RWLIST_INSERT_HEAD, AST_RWLIST_INSERT_TAIL, AST_RWLIST_NEXT, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, http_uri_redirect::entry, len(), and ast_http_uri::uri.

Referenced by __ast_http_post_load(), __init_manager(), and ast_http_init().

545 {
546  struct ast_http_uri *uri;
547  int len = strlen(urih->uri);
548 
550 
551  if ( AST_RWLIST_EMPTY(&uris) || strlen(AST_RWLIST_FIRST(&uris)->uri) <= len ) {
554  return 0;
555  }
556 
557  AST_RWLIST_TRAVERSE(&uris, uri, entry) {
558  if (AST_RWLIST_NEXT(uri, entry) &&
559  strlen(AST_RWLIST_NEXT(uri, entry)->uri) <= len) {
560  AST_RWLIST_INSERT_AFTER(&uris, uri, urih, entry);
562 
563  return 0;
564  }
565  }
566 
568 
570 
571  return 0;
572 }
#define AST_RWLIST_NEXT
Definition: linkedlists.h:440
#define AST_RWLIST_INSERT_AFTER
Definition: linkedlists.h:687
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
struct ast_http_uri::@175 entry
#define AST_RWLIST_INSERT_HEAD
Definition: linkedlists.h:703
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
#define AST_RWLIST_EMPTY
Definition: linkedlists.h:451
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:726
Definition of a URI handler.
Definition: http.h:91
Definition: http.c:104
const char * uri
Definition: http.h:94
#define AST_RWLIST_FIRST
Definition: linkedlists.h:422
void ast_http_uri_unlink ( struct ast_http_uri urihandler)

Unregister a URI handler.

Definition at line 574 of file http.c.

References AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and http_uri_redirect::entry.

Referenced by __init_manager(), and http_shutdown().

575 {
577  AST_RWLIST_REMOVE(&uris, urih, entry);
579 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
struct ast_http_uri::@175 entry
#define AST_RWLIST_REMOVE
Definition: linkedlists.h:870
Definition: http.c:104
void ast_http_uri_unlink_all_with_key ( const char *  key)

Unregister all handlers with matching key.

Definition at line 581 of file http.c.

References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_http_uri::data, ast_http_uri::dmallocd, http_uri_redirect::entry, ast_http_uri::key, and ast_http_uri::mallocd.

Referenced by __ast_http_post_load(), and unload_module().

582 {
583  struct ast_http_uri *urih;
586  if (!strcmp(urih->key, key)) {
588  if (urih->dmallocd) {
589  ast_free(urih->data);
590  }
591  if (urih->mallocd) {
592  ast_free(urih);
593  }
594  }
595  }
598 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
const char * key
Definition: http.h:104
struct ast_http_uri::@175 entry
unsigned int mallocd
Definition: http.h:98
#define AST_RWLIST_REMOVE_CURRENT
Definition: linkedlists.h:565
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:542
#define ast_free(a)
Definition: astmm.h:97
Definition of a URI handler.
Definition: http.h:91
unsigned int dmallocd
Definition: http.h:100
Definition: http.c:104
void * data
Definition: http.h:102
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:602