encode_allow.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #define _GNU_SOURCE
00041 #include <stdio.h>
00042 #include <string.h>
00043 #include <netinet/in.h>
00044 #include <arpa/inet.h>
00045 #include "../../parser/parse_allow.h"
00046 #include "../../parser/msg_parser.h"
00047 #include "encode_allow.h"
00048
00049 char *mismetodos[]={"UNDEF","INVITE","CANCEL","ACK","BYE","INFO","OPTIONS","UPDATE","REGISTER","MESSAGE","SUBSCRIBE","NOTIFY","PRACK","REFER","OTHER"};
00050
00051
00052
00053
00054
00055
00056 int encode_allow(char *hdrstart,int hdrlen,unsigned int *bodi,char *where)
00057 {
00058 unsigned int i;
00059 memcpy(&i,bodi,4);
00060 i=htonl(i);
00061 memcpy(where,&i,4);
00062 return 4;
00063 }
00064
00065 int print_encoded_allow(FILE *fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
00066 {
00067 unsigned int i,j=0,body;
00068
00069 memcpy(&body,payload,4);
00070 body=ntohl(body);
00071 fprintf(fd,"%sMETHODS=",prefix);
00072 if(body==0)
00073 fprintf(fd,"UNKNOWN");
00074 for(i=0;i<32;j=(0x01<<i),i++){
00075 if(body & (j<15))
00076 fprintf(fd,",%s",mismetodos[i]);
00077 }
00078 fprintf(fd,"\n");
00079 return 1;
00080 }