📄 input.c
字号:
printf (" sender's originator address: %s\n", convert_address_to_string (&qostmsg->originator)); printf (" received from my interface: %s\n", convert_address_to_string (&qostmsg->my_addr)); printf (" originator's busy time: %d\n", qostmsg->my_busy_time); printf (" sender has the following MPR selector busy time information:\n"); fprintf (y_file,"--------THE RECEIVED MESSAGE IS A QoS TC with following information!\n"); fprintf (y_file," sender's interface address: %s\n", convert_address_to_string (&qostmsg->source_addr)); fprintf (y_file," sender's originator address: %s\n", convert_address_to_string (&qostmsg->originator)); fprintf (y_file," received from my interface: %s\n", convert_address_to_string (&qostmsg->my_addr)); fprintf (y_file," originator's busy time: %d\n", qostmsg->my_busy_time); fprintf (y_file," sender has the following MPR selector busy time information:\n"); } for (mbusy = mprsbusy; (char *)mbusy < (char *)m + ntohs(m->olsr_msgsize); mbusy++) { mprs_busy_time = (struct tc_mpr_busy_time *)malloc(sizeof(struct tc_mpr_busy_time)); if (mprs_busy_time == 0) { printf("olsrd: out of memery \n"); break; } memcpy(&(mprs_busy_time->busy_time),mbusy,sizeof(olsr_u32_t)); mprs_busy_time->next = qostmsg->multipoint_relay_selector_busy_time; qostmsg->multipoint_relay_selector_busy_time = mprs_busy_time; /*** debug ***/ if (debug_level >3) { printf ("+++ mpr selector busy time: %d\n", mprs_busy_time->busy_time); fprintf (y_file, "+++ mpr selector busy time: %d\n", mprs_busy_time->busy_time); } }}/******************** end of revision **********//* * Build TC Message according to tc_message struct from olsrmsg struct. */void tc_chgestruct(struct tc_message *tmsg, struct olsrmsg *m, struct sockaddr *from, int index){ struct tcmsg *tc; //CRC v4->v6 chg struct olsr_ip_addr *mprsaddr, *maddr; struct tc_mpr_addr *mprs; tmsg->multipoint_relay_selector_address = (struct tc_mpr_addr *)NULL; if (!m) return; if (m->olsr_msgtype != TC_PACKET) return; tc = m->olsr_tc; mprsaddr = tc->tc_mprsaddr; /*CRC v4->v6 del tmsg->source_addr = ((struct sockaddr_in *)from)->sin_addr.s_addr; tmsg->originator = tc->tc_origaddr; */ //CRC v4->v6 add /*memcpy(&(tmsg->source_addr),&(((struct sockaddr_in6 *)from)->sin6_addr),sizeof(struct olsr_ip_addr));*/ //CRC HNA add /*-------------------------------------------------------------------*/ /*memcpy(&(tmsg->source_addr),&(m->olsr_source),sizeof(struct olsr_ip_addr));*/ //commented by Y.Ge /*-------------------------------------------------------------------*/ /*memcpy(&(tmsg->originator),&(tc->tc_origaddr),sizeof(struct olsr_ip_addr));*/ //commented by Y.Ge /********************** added by Y.Ge ********************/ memcpy(&(tmsg->source_addr),&(((struct sockaddr_in6 *)from)->sin6_addr),sizeof(struct olsr_ip_addr)); memcpy(&(tmsg->originator),&(m->olsr_source),sizeof(struct olsr_ip_addr)); memcpy (&tmsg->my_addr, &addr_manet[index], sizeof(struct olsr_ip_addr)); /********************** end of revision ******************/ //tmsg->packet_seq_number = ntohs(tc->tc_seqnum); //commented by Y.Ge tmsg->packet_seq_number = ntohs(m->olsr_msgseq); //added by Y.Ge //tmsg->hop_count = tc->tc_hopcnt; //commented by Y.Ge tmsg->hop_count = m->olsr_hopcount; //added by Y.Ge tmsg->time_to_live = m->olsr_ttl; //added by Y.Ge tmsg->mssn = ntohs(tc->tc_mprseqnum); if (debug_level >3) { printf ("--------THE RECEIVED MESSAGE IS A TC with following information!\n"); printf (" sender's interface address: %s\n", convert_address_to_string (&tmsg->source_addr)); printf (" sender's originator address: %s\n", convert_address_to_string (&tmsg->originator)); printf (" received from my interface: %s\n", convert_address_to_string (&tmsg->my_addr)); printf (" sender has the following MPR selector information:\n"); fprintf (y_file,"--------THE RECEIVED MESSAGE IS A TC with following information!\n"); fprintf (y_file," sender's interface address: %s\n", convert_address_to_string (&tmsg->source_addr)); fprintf (y_file," sender's originator address: %s\n", convert_address_to_string (&tmsg->originator)); fprintf (y_file," received from my interface: %s\n", convert_address_to_string (&tmsg->my_addr)); fprintf (y_file," sender has the following MPR selector information:\n"); } /* the following "for" is commented and re-writed by Y.Ge **/ /*for (maddr = mprsaddr; (char *)maddr < (char *)m + ntohs(m->olsr_nextmsg); maddr++)*/ for (maddr = mprsaddr; (char *)maddr < (char *)m + ntohs(m->olsr_msgsize); maddr++) { mprs = (struct tc_mpr_addr *)malloc(sizeof(struct tc_mpr_addr)); if (mprs == 0) { printf("olsrd: out of memery \n"); break; } /*CRC v4->v6 del mprs->address = *maddr;*/ //CRC v4->v6 add memcpy(&(mprs->address),maddr,sizeof(struct olsr_ip_addr)); mprs->next = tmsg->multipoint_relay_selector_address; tmsg->multipoint_relay_selector_address = mprs; /*** debug ***/ if (debug_level >3) { printf ("+++ mpr selector: %s\n", convert_address_to_string(&mprs->address)); fprintf (y_file, "+++ mpr selector: %s\n", convert_address_to_string(&mprs->address)); } }}/************************* added by Y.Ge *****************//* * Build MID Message according to tc_message struct from olsrmsg struct. */void mid_chgestruct(struct mid_message *mmsg, struct olsrmsg *m, struct sockaddr *from, int index){ struct midmsg *mid; //CRC v4->v6 chg struct olsr_ip_addr *midaddr, *maddr; struct mid_iface_addr *midinterfaces, *midinterfaces_debug; mmsg->mid_interface_address = (struct mid_iface_addr *)NULL; if (!m) return; if (m->olsr_msgtype != MID_PACKET) return; mid = m->olsr_mid; midaddr = mid->mid_ifaceaddr; memcpy(&(mmsg->source_addr),&(((struct sockaddr_in6 *)from)->sin6_addr),sizeof(struct olsr_ip_addr)); memcpy(&(mmsg->originator_addr),&(m->olsr_source),sizeof(struct olsr_ip_addr)); memcpy (&mmsg->my_addr, &addr_manet[index], sizeof(struct olsr_ip_addr)); mmsg->packet_seq_number = ntohs(m->olsr_msgseq); mmsg->hop_count = m->olsr_hopcount; mmsg->time_to_live = m->olsr_ttl; mmsg->v_time = m->olsr_vtime; /*** debug ***/ if (debug_level >3) { printf ("--------THE RECEIVED MESSAGE IS A MID with following information!\n"); printf (" sender's interface address: %s\n", convert_address_to_string (&mmsg->source_addr)); printf (" sender's originator address: %s\n", convert_address_to_string (&mmsg->originator_addr)); printf (" received from my interface: %s\n", convert_address_to_string (&mmsg->my_addr)); printf (" sender has the following mid information:\n"); fprintf (y_file,"--------THE RECEIVED MESSAGE IS A MID with following information!\n"); fprintf (y_file," sender's interface address: %s\n", convert_address_to_string (&mmsg->source_addr)); fprintf (y_file," sender's originator address: %s\n", convert_address_to_string (&mmsg->originator_addr)); fprintf (y_file," received from my interface: %s\n", convert_address_to_string (&mmsg->my_addr)); fprintf (y_file," sender has the following mid information:\n"); } for (maddr = midaddr; (char *)maddr < (char *)m + ntohs(m->olsr_msgsize); maddr++) { /*printf (" +++ interface address: %s\n", convert_address_to_string(maddr));*/ midinterfaces = (struct mid_iface_addr *)malloc(sizeof(struct mid_iface_addr)); if (midinterfaces == 0) { printf("olsrd: out of memery \n"); break; } memcpy(&(midinterfaces->interface_address),maddr,sizeof(struct olsr_ip_addr)); midinterfaces->next = mmsg->mid_interface_address; mmsg->mid_interface_address = midinterfaces; /*printf ("... after adding this address, the message is:\n"); midinterfaces_debug = mmsg->mid_interface_address; while(midinterfaces_debug!=NULL) { printf ("interface address: %s\n", convert_address_to_string(&midinterfaces_debug->interface_address)); midinterfaces_debug = midinterfaces_debug->next; } printf ("... this adding round finished\n");*/ /*** debug ***/ if (debug_level >3) { printf ("mid interface address: %s\n", convert_address_to_string(&midinterfaces->interface_address)); fprintf (y_file,"mid interface address: %s\n", convert_address_to_string(&midinterfaces->interface_address)); } } /*printf ("+++++++++++++++++++++++ after MID chagestruct, the message is:\n"); midinterfaces_debug = mmsg->mid_interface_address; while(midinterfaces_debug!=NULL) { printf ("interface address: %s\n", convert_address_to_string(&midinterfaces_debug->interface_address)); midinterfaces_debug = midinterfaces_debug->next; } printf ("++++++++++++++++++++ MID changestruct finished ++++++++++++++++\n");*/ }/************************* end of revision ***************///CRC HNA add/* Build HNA Message according to hna_message struct from olsrmsg struct.*/void hna_chgestruct(struct hna_message *hmsg, struct olsrmsg *m, struct sockaddr *from, int index) //"index" is added by Y.Ge{ struct hnamsg *hptr; struct hnaaddr *hna_addr, *haddr; struct hna_net_addr *netaddrptr; hmsg->hna_net_addrs =(struct hna_net_addr *)NULL; if (!m) return; if (m->olsr_msgtype != HNA_PACKET) return; hptr = m->olsr_hna; hna_addr = hptr->hna_netaddr; /* CRC v4->v6 add: memcpy(&(tmsg->source_addr),&(((struct sockaddr_in6 *)from)->sin6_addr),sizeof(struct olsr_ip_addr));*/ //CRC HNA add /*------------------------------------------------------------------------*/ //memcpy(&(hmsg->source_addr),&(m->olsr_source),sizeof(struct olsr_ip_addr)); //commented by Y.Ge /*------------------------------------------------------------------------*/ /*memcpy(&(hmsg->originator),&(hptr->hna_origaddr),sizeof(struct olsr_ip_addr)); hmsg->packet_seq_number = ntohs(hptr->hna_seqnum); hmsg->hop_count = hptr->hna_hopcnt; hmsg->msg_seq_number = ntohs(hptr->hna_msgseqnum);*/ //commented by Y.Ge /************** added by Y.Ge ************/ memcpy(&(hmsg->source_addr),&(((struct sockaddr_in6 *)from)->sin6_addr),sizeof(struct olsr_ip_addr)); memcpy(&(hmsg->originator),&(m->olsr_source),sizeof(struct olsr_ip_addr)); memcpy (&hmsg->my_addr, &addr_manet[index], sizeof(struct olsr_ip_addr)); hmsg->packet_seq_number = ntohs(m->olsr_msgseq); hmsg->hop_count = m->olsr_hopcount; hmsg->time_to_live = m->olsr_ttl; hmsg->v_time = m->olsr_vtime; /*** debug ***/ if (debug_level >3) { printf ("--------THE RECEIVED MESSAGE IS A HNA with following information!\n"); printf (" sender's interface address: %s\n", convert_address_to_string (&hmsg->source_addr)); printf (" sender's originator address: %s\n", convert_address_to_string (&hmsg->originator)); printf (" received from my interface: %s\n", convert_address_to_string (&hmsg->my_addr)); printf (" sender has the following HNA information:\n"); fprintf (y_file,"--------THE RECEIVED MESSAGE IS A HNA with following information!\n"); fprintf (y_file," sender's interface address: %s\n", convert_address_to_string (&hmsg->source_addr)); fprintf (y_file," sender's originator address: %s\n", convert_address_to_string (&hmsg->originator)); fprintf (y_file," received from my interface: %s\n", convert_address_to_string (&hmsg->my_addr)); fprintf (y_file," sender has the following HNA information:\n"); } /************** end of revision **********/ /* the following "for" is commented and re-writed by Y.Ge **/ /*for (haddr = hna_addr; (char *)haddr < (char *)m + ntohs(m->olsr_nextmsg); haddr++)*/ for (haddr = hna_addr; (char *)haddr < (char *)m + ntohs(m->olsr_msgsize); haddr++) { netaddrptr = (struct hna_net_addr *)malloc(sizeof(struct hna_net_addr)); if (netaddrptr == 0) { printf("olsrd: out of memery \n"); break; } memcpy(&(netaddrptr->net_addr),&(haddr->addr),sizeof(struct olsr_ip_addr)); netaddrptr->prefix=ntohs(haddr->prefix); netaddrptr->next = hmsg->hna_net_addrs; hmsg->hna_net_addrs = netaddrptr; /*** debug ***/ if (debug_level >3) { printf ("hna address: %s, prefix: %d\n", convert_address_to_string(&netaddrptr->net_addr),netaddrptr->prefix); fprintf (y_file,"hna address: %s, prefix: %d\n", convert_address_to_string(&netaddrptr->net_addr),netaddrptr->prefix); } }}/* * Process a newly received packet. */void olsr_input(struct sockaddr *from, struct olsr *olsr, int size, int index) //"index" is added by Y.Ge, which interface the packet is recieved?{ struct olsrmsg *m = olsr->olsr_msg; struct hello_message hellopacket; struct tc_message tcpacket_in, *tcpacket_out; struct rt_message *routepacket = NULL; //CRC HNA add
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -