MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / get_user_agent

Function get_user_agent

modules/mediaproxy/mediaproxy.c:584–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582
583
584static str
585get_user_agent(struct sip_msg* msg)
586{
587 static str unknown = str_init("unknown agent");
588 str block, server;
589 char *ptr;
590
591 if (parse_headers(msg, HDR_USERAGENT_F, 0)==0 && msg->user_agent &&
592 msg->user_agent->body.s && msg->user_agent->body.len>0) {
593 return msg->user_agent->body;
594 }
595
596 // If we can't find user-agent, look after the `Server' header
597 // This is a temporary hack. Normally it should be extracted by opensips.
598
599 block.s = msg->buf;
600 block.len = msg->len;
601
602 ptr = find_line_starting_with(&block, "Server:", True);
603 if (!ptr)
604 return unknown;
605
606 server.s = ptr + 7;
607 server.len = findendline(server.s, block.s+block.len-server.s) - server.s;
608
609 trim(&server);
610 if (server.len == 0)
611 return unknown;
612
613 return server;
614}
615
616
617// Get caller signaling IP

Callers 1

use_media_proxyFunction · 0.85

Calls 3

find_line_starting_withFunction · 0.85
findendlineFunction · 0.85
trimFunction · 0.85

Tested by

no test coverage detected