⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sip.c

📁 radius协议源码÷The Radius Stack will connect to a Radius Server. This stack implementation is built upo
💻 C
字号:
/**************************************************************************** ** File: sip.c**** Author: Mike Borella**** Comments: Dump SIP header information. I didn't try to do anything** fancy with this - I just dump the plaintext headers.  This makes ** debugging easier since parsing is such a pain to get right.*******************************************************************************/#include <stdio.h>#include <unistd.h>#include <string.h>#include <ctype.h>#include "config.h"#include "ip.h"#include "udp.h"#define LINE_SIZE 256#define FALSE 0#define TRUE  1extern u_char *packet_end;extern struct arg_t *my_args;/*----------------------------------------------------------------------------**** dump_sip()**** Parse SIP packet and dump fields.  This code is kludgy - I'll fix it later****----------------------------------------------------------------------------*/void dump_sip(u_char *bp, int length){  u_char *ep = bp + length;  u_char *p;  u_char *ptr;  char line[LINE_SIZE];  int use_sdp = FALSE;  int i;  int n = 0;  int get_next_line(u_char *, u_char *, char *);  void dump_sdp(u_char *, int);  int firstLine;  /*   * Make sure we don't run off the end of the packet   */  if (ep > packet_end)     ep = packet_end;  p = bp;  if (!my_args->m)    {      printf("-----------------------------------------------------------------\n");      printf("                        SIP Headers\n");      printf("-----------------------------------------------------------------\n");    }  firstLine = 1;  while(p <= ep && (n = get_next_line(p, ep, line)))    {      p = p + n;      length = length - n;      if ( firstLine )	{	  firstLine = 0;	  if ( !strncmp(line,"SIP",3) )	    {	      printf("sip-res:    %-45s [%s:%d->%s:%d]\n", 		     line,		     current_ip_src_addr,		     current_ip_src_port,		     current_ip_dst_addr,		     current_ip_dst_port);	    }	  else	    {	      printf("sip-req:    %-45s [%s:%d->%s:%d]\n", 		     line,		     current_ip_src_addr,		     current_ip_src_port,		     current_ip_dst_addr,		     current_ip_dst_port);	    }	}      else	{	  if (!my_args->m)	    {	      printf("Header:                 %s\n", line);	    }	}      for (i=0; i<strlen(line); i++)	line[i] = tolower(line[i]);      if (!my_args->m)	{    	  if (!strncmp("content-type", line, 12))	    {	      ptr = &line[14];	      while(isspace(*ptr)) 		ptr++;	      	      if (!strncmp("application/sdp", ptr, 15))		use_sdp = TRUE;	    }	}    }    p = p + 2;  if (use_sdp)    dump_sdp(p, length);}#define hashfn(x) \    ((int)((((int)x[0]) << 8) | ((int)x[1])))#define mkhash(x,y) \    ((((int)(x)) << 8) | ((int)(y)))int is_sip(u_char *bp){    /* calculate a hash to find out if it's right */    switch(hashfn(bp))    {	case mkhash('I','N'):	case mkhash('A','C'):	case mkhash('O','P'):	case mkhash('B','Y'):	case mkhash('R','E'):	case mkhash('C','A'):	case mkhash('S','I'):	    return 1;	default:	    return 0;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -