static int determine_source (struct sip_msg *msg, enum hash_source source, str *source_string) { source_string->s = NULL; source_string->len = 0; if(validate_msg(msg) < 0) { return -1; } switch (source) { case shs_call_id: return determine_call_id (msg, source_string); case shs_from_uri: return determine_fromto_uri (get_from(msg), source_string); case shs_from_user: return determine_fromto_user (get_from(msg), source_string); case shs_to_uri: return determine_fromto_uri (get_to(msg), source_string); case shs_to_user: return determine_fromto_user (get_to(msg), source_string); case shs_rand: return determine_fromrand(source_string); /* msg is not needed */ default: LM_ERR("unknown hash source %i.\n", (int) source); return -1; } }
void packet_process(u_char *user,const struct pcap_pkthdr *h,const u_char *bytes) { //get bob's command: 1 for start | 2 for connect_ap char *command = "./init.sh"; printf("packets comes\n"); struct lorcon_packet *packet = (struct lorcon_packet *)(bytes+21); int plen = h->len - 25 - sizeof(struct lorcon_packet); printf("%d\n",plen); struct bob_msg *msg = (struct bob_msg *)(packet->payload); if(validate_msg(msg)==0){ printf("invalid msg format\n"); return; } u_char cmd = msg->command; switch(cmd){ case CSI_COMMAND: //call the init script if(system(command)<0){ printf("system error\n"); } break; //other command default: break; } exit(0); // //cancel alarm // alarm(0); // // //jump over radiotap header:25+24+1024 // //here four-byte ECC code may be added !!! radiotap header is 21 // struct lorcon_packet *packet = (struct lorcon_packet *)(bytes+21); // int cnt; // int plen = h->len - 25 - sizeof(struct lorcon_packet); // printf("%d\n",plen); // cnt = fwrite(packet->payload,1,plen,file); // if(plen < 1024){ // //transmit over // fclose(file); // exit(0); // } // // //set alarm // alarm(1); }