/** * Process a received TopologyControl message */ void olsr_process_received_tc(struct olsrv2 *olsr, struct message_header *m, union olsr_ip_addr *in_if, union olsr_ip_addr *from_addr) { struct tc_message message; if (tc_change_structure(olsr, &message, m, from_addr) == OLSR_FALSE){ //Fix for Memory Loss olsr_free_tc_packet(&message); return; } process_tc(olsr, &message, in_if); olsr_free_tc_packet(&message); olsr->stat.numTcReceived++; if(DEBUG_OLSRV2) { olsr_printf("Increment Tc Message Received Count to %d\n", olsr->stat.numTcReceived); } return; }
int ipc_evaluate_message(union olsr_message *olsr_in) { int ipc_pack = 0; olsr_u8_t type; int msgsize; char itoa_buf[10]; olsr_u8_t vtime; union olsr_ip_addr *originator; /* Find size, vtime, originator and type - same for IPv4 and 6 */ type = olsr_in->v4.olsr_msgtype; msgsize = ntohs(olsr_in->v4.olsr_msgsize); vtime = olsr_in->v4.olsr_vtime; originator = (union olsr_ip_addr *)&olsr_in->v4.originator; gui_itoa(msgsize, itoa_buf); switch (type) { case HELLO_MESSAGE: //printf("Received HELLO packet\n"); if (!freeze_packets) packet_list_add("HELLO", ip_to_string(originator), itoa_buf); if (ipversion == AF_INET) { process_hello(msgsize, vtime, originator, (union hello_message *)&olsr_in->v4.message.hello); } else { process_hello(msgsize, vtime, originator, (union hello_message *)&olsr_in->v6.message.hello); } break; case TC_MESSAGE: if (!freeze_packets) packet_list_add("TC", ip_to_string(originator), itoa_buf); if (ipversion == AF_INET) { process_tc(msgsize, vtime, originator, (union tc_message *)&olsr_in->v4.message.tc); //printf("Received TC packet from %s\n", ip_to_string(&m->olsr_tc->tc_origaddr)); } else { process_tc(msgsize, vtime, originator, (union tc_message *)&olsr_in->v6.message.tc); //printf("Received TC packet from %s\n", ip_to_string(&m->olsr_tc->tc_origaddr)); } break; case MID_MESSAGE: if (!freeze_packets) packet_list_add("MID", ip_to_string(originator), itoa_buf); if (ipversion == AF_INET) { process_mid(msgsize, vtime, originator, (union mid_message *)&olsr_in->v4.message.mid); //printf("Received MID packet from %s\n", ip_to_string(&m->olsr_mid->mid_origaddr)); } else { process_mid(msgsize, vtime, originator, (union mid_message *)&olsr_in->v6.message.mid); //printf("Received MID packet from %s\n", ip_to_string(&m->olsr_mid->mid_origaddr)); } break; case HNA_MESSAGE: if (!freeze_packets) packet_list_add("HNA", ip_to_string(originator), itoa_buf); if (ipversion == AF_INET) { process_hna(msgsize, vtime, originator, (union hna_message *)&olsr_in->v4.message.hna); //printf("Received HNA packet\n"); } else { process_hna(msgsize, vtime, originator, (union hna_message *)&olsr_in->v6.message.hna); //printf("Received HNA packet\n"); } break; case IPC_MESSAGE: //printf("Received IPC packet\n"); ipc_pack = 1; /* Don't add to buffer */ ipc_eval_route_packet((struct routemsg *)olsr_in); break; case IPC_NET: //printf("Received IPC packet\n"); ipc_pack = 1; /* Don't add to buffer */ ipc_eval_net_info((struct netmsg *)olsr_in); break; default: if (!freeze_packets) { char unk_label[8]; sprintf(unk_label, "%d", type); packet_list_add(unk_label, ip_to_string(originator), itoa_buf); } printf("Unknown packet type %d\n", type); break; } if (!freeze_packets && !ipc_pack) { add_packet_to_buffer(olsr_in, msgsize); } return 1; }