88 if (lp==NULL)
return buf;
97 char* pa = pp = pp + 9;
98 while (*pp!=
';' && *pp!=
'\0') pp++;
99 if (*pp==
';') *pp =
'\0';
103 char* pt = pp = pp + 6;
104 while (*pp!=
';' && *pp!=
'\0') pp++;
105 if (*pp==
';') *pp =
'\0';
117 while (*pp!=
';' && *pp!=
'\0') pp++;
118 if (*pp==
';') *pp =
'\0';
132 char sipver[] =
"SIP/2.0/UDP ";
137 if (lp==NULL || host==NULL)
return;
142 if (pm==NULL)
return;
144 else if (pm->prev!=NULL) pm = pm->prev;
148 if (port!=0) snprintf(hostport,
LBUF,
"%s:%d", host, port);
149 else snprintf(hostport,
LBUF,
"%s", host);
150 hostport[
LBUF-1] =
'\0';
175 if (lp==NULL || host==NULL)
return;
177 if (port!=0) snprintf(hostport,
LBUF,
"%s:%d", host, port);
178 else snprintf(hostport,
LBUF,
"%s", host);
179 hostport[
LBUF-1] =
'\0';
182 if (lp->ldat.key.buf!=NULL && !strcasecmp((
char*)lp->ldat.key.buf,
"Via")) {
184 if (!strncmp(hostport, (
char*)via_hostport.
buf, strlen(hostport))) {
211 if (lp==NULL || host==NULL)
return;
218 if (pm==NULL)
return;
220 else if (pm->prev!=NULL) {
221 char* pp =
strstrcase((
char*)pm->ldat.val.buf,
"ftag=");
225 while (pp[i]!=
'\0' && pp[i]!=
';' && pp[i]!=
'>' && i<
LBUF) {
236 if (ftag[0]!=
'\0') snprintf(sipuri,
LBUF,
"<sip:%s:%d;ftag=%s;lr=on>", host, port, ftag);
237 else snprintf(sipuri,
LBUF,
"<sip:%s:%d;lr=on>", host, port);
240 if (ftag[0]!=
'\0') snprintf(sipuri,
LBUF,
"<sip:%s;ftag=%s;lr=on>", host, ftag);
241 else snprintf(sipuri,
LBUF,
"<sip:%s;lr=on>", host);
243 sipuri[
LBUF-1] =
'\0';
260 if (lp==NULL || host==NULL)
return;
262 if (port!=0) snprintf(sipuri,
LBUF,
"sip:%s:%d", host, port);
263 else snprintf(sipuri,
LBUF,
"sip:%s", host);
264 sipuri[
LBUF-1] =
'\0';
267 if (lp->ldat.key.buf!=NULL && !strcasecmp((
char*)lp->ldat.key.buf,
"Record-Route")) {
268 char* rrt = (
char*)lp->ldat.val.buf;
269 if (rrt[0]==
'<') rrt++;
271 if (!strncmp(sipuri, rrt, strlen(sipuri))) {
291 if (lp->ldat.key.buf!=NULL && !strcasecmp((
char*)lp->ldat.key.buf,
"Record-Route")) {
313 if (lp==NULL || host==NULL)
return;
316 if (lc==NULL || lc->ldat.val.buf==NULL)
return;
318 char* pa = (
char*)lc->ldat.val.buf;
322 char* pp = strstr(ps,
"@");
323 if (pp==NULL) pp = ps + 3;
328 for (i=0; i<
LBUF-1; i++) {
330 if (*pp==
'\0' || *pp==
'>' || *pp==
' ' || *pp==
';')
break;
339 if (port!=0) snprintf(hostport,
LBUF,
"%s:%d", host, port);
340 else snprintf(hostport,
LBUF,
"%s", host);
341 hostport[
LBUF-1] =
'\0';
370 if (cntct.
buf!=NULL) {
397 if (siptmp.
buf!=NULL) {
400 while (siptmp.
buf[i]!=
'\0' && siptmp.
buf[i]!=
'>' && siptmp.
buf[i]!=
';' &&
402 if (siptmp.
buf[i]==
'@') pp = (
char*)&siptmp.
buf[i+1];
405 siptmp.
buf[i] =
'\0';
428 if (lp==NULL)
return mxfd;
432 mxfd = atoi((
char*)lt->ldat.val.buf);
448 if (lp==NULL)
return;
452 snprintf(mxfd,
LEN_INT,
"%d", nm);
492 if (ls==NULL)
return buf;
496 buf.vldsz =
buf.vldsz - 2;
497 buf.buf[
buf.vldsz] =
'\0';
520 if (lp==NULL || host==NULL || port==0)
return FALSE;
531 if (pm->ldat.key.buf!=NULL && !strcasecmp(
"a", (
char*)pm->ldat.key.buf)) {
532 if (pm->ldat.val.buf!=NULL && !strncasecmp(
"candidate ", (
char*)pm->ldat.val.buf, 10)) {
576 int range, sock1, sock2, port;
581 range = max - min + 1;
582 port = ((rand()%range + min)/2)*2;
586 if (sock1<=0 || sock2<=0) {
592 while(sock1==0 && i<range) {
594 if (port>max) port = ((port%max + min - 1)/2)*2;
598 if (sock1<=0 || sock2<=0) {
615 return (
unsigned short)port;
634 if (lp==NULL || host==NULL || port==0)
return buf;
642 while (
buf.buf[i]!=
';' &&
buf.buf[i]!=
'\0') i++;
643 if (
buf.buf[i]!=
'\0')
buf.buf[i] =
'\0';
645 snprintf(hostport,
LBUF,
"%s:%d", host, port);
646 hostport[
LBUF-1] =
'\0';
661 char dstip[] =
"dstip=";
662 char dstport[] =
"dstport=";
669 if (lp==NULL || ipaddr==NULL || port==0)
return FALSE;
672 if (lc==NULL || lc->ldat.val.buf==NULL)
return FALSE;
676 if (frip.
buf==NULL || frpt.
buf==NULL) {
683 ip = strstr((
char*)frip.
buf, dstip);
684 while (ip[i]!=
'\0' && ip[i]!=
';' && ip[i]!=
'"') i++;
688 pt = strstr((
char*)frpt.
buf, dstport);
689 while (pt[i]!=
'\0' && pt[i]!=
';' && pt[i]!=
'"') i++;
704 lc->ldat.val = nwcntct;
Buffer make_Buffer(int sz)
Buffer型変数のバッファ部をつくり出す.
void free_Buffer(Buffer *buf)
Buffer型変数のバッファ部を解放する
Buffer init_Buffer()
初期化したBuffer型変数を返す.
Buffer dup_Buffer(Buffer buf)
Buffer型変数のコピーをつくる.
int copy_i2Buffer(int src, Buffer *dst)
整数 srcを文字列に変換して,dstへ copyする.
int cat_i2Buffer(int src, Buffer *dst)
整数 srcを文字列に変換して,dstへ catする.
Buffer cawk_Buffer(Buffer str, char cc, int n)
Buffer文字列に対する(変形の)awk.
#define copy_s2Buffer(src, dst)
copy_b2Buffer()
#define replace_sBuffer(buf, f, t)
replace_sBuffer()
#define cat_s2Buffer(src, dst)
cat_b2Buffer()
#define make_Buffer_bystr(str)
set_Buffer()
#define LEN_INT
log 2^64 + '\0' + 1(予備)
int socket_close(int sofd)
call shutdown(), close()
#define udp_server_socket(p, a)
Buffer search_protocol_header_item(tList *list, char *key, int no, char deli, int nm)
void set_protocol_contents(tList *list, Buffer contents)
Buffer search_protocol_header(tList *list, char *key, int no)
int set_protocol_header(tList *list, char *key, char *value, int no, int add_mode)
tList * get_protocol_header_list(Buffer buf, char deli, int fstline, int rcntnt)
Buffer restore_protocol_header(tList *list, char *deli, int mode, int *hdsz)
Buffer restore_protocol_contents(tList *list)
Buffer search_protocol_header_partvalue(tList *list, char *key, char *data, int no)
#define replace_protocol_header(list, key, no, srcval, value)
#define HDLIST_FIRST_LINE_KEY
#define set_protocol_header_item(list, key, no, deli, nm, value)
int vldsz
データの長さ.バイナリデータの場合も使用可能.文字列の場合は 0x00 を含まない.
unsigned char * buf
バッファの先頭へのポインタ.str[bufsz]は必ず 0x00となる.
tList * del_tList(tList **pp)
指定したリストノード以降のリストを削除.
tList * strncmp_tList(tList *pl, const char *key, int len, int no)
char* 型変数によるノードのサーチ.
tList * strncasecmp_tList(tList *pl, const char *key, int len, int no)
char* 型変数によるノードのサーチ.大文字小文字を無視する
tList * del_tList_node(tList **node)
リスト用のノードを削除.
#define add_tList_node_str(p, k, v)
add_tList_node_bystr()