📄 output.c
字号:
//msg->olsr_seqnum = htons(pkt_seqnum[ifp->my_index]++); //added by Y.Ge //TRACE_OUTPUT(ifp, dst, outputsize); //(*output)(s6, flags, dst, outputsize); //inet6_output(s6, flags, dst, outputsize); //commented by Y.Ge tointerface (sndmsg, (struct hello_message *)NULL, (struct tc_message *)NULL, (struct mid_message *)NULL,(struct hna_message *)NULL, (struct interface *)NULL, ifp->my_index); //added by Y.Ge } if (debug_level > 3) { printf (" INCLUDING MESSAGE NEIGHBORS! \n"); fprintf (y_file," INCLUDING MESSAGE NEIGHBORS! \n"); } for (i = 0; i < HELLOSTATUS_MAX; i++) //revised by Y.Ge. Originally, i starts with 1 { /* printf ("===== i= %d\n", i); */ lastpacket = sametype = 0; outputsize = (char *)hinfo - packet; /*printf ("outputsize: %d\n, maxpacketsize: %d\n", outputsize, MAXPACKETSIZE); fprintf (y_file,"outputsize: %d\n, maxpacketsize: %d\n", outputsize, MAXPACKETSIZE);*/ if (outputsize > MAXPACKETSIZE - (int)sizeof (struct hellinfo)) { msg->olsr_packlen = htons(outputsize); //msg->olsr_seqnum = htons(pkt_seqnum[ifp->my_index]++); //added by Y.Ge //memset(msg->olsr_res, 0, sizeof(msg->olsr_res)); //commented by Y.Ge m->olsr_msgtype = HELLO_PACKET; m->olsr_vtime = olsr_compute_vtime (neighbor_hold_time); //added by Y.Ge //m->olsr_broad = MSG_NOBROADCAST; //commented by Y.Ge //m->olsr_nextmsg = (char *)hinfo - (char *)m; //commented by Y.Ge //m->olsr_nextmsg = htons(m->olsr_nextmsg); //commented by Y.Ge m->olsr_msgsize = (char *)hinfo - (char *)m; //addeded by Y.Ge m->olsr_msgsize = htons(m->olsr_msgsize); //addeded by Y.Ge m->olsr_ttl = 1; //added by Y.Ge m->olsr_hopcount = 0; //added by Y.Ge /* deal with packe sequence number of the chunked HELLO */ m->olsr_msgseq = htons(message->packet_seq_number + hello_chunk[ifp->my_index]); //added by Y.Ge hello_chunk[ifp->my_index]++; //added by Y.Ge //CRC HNA add //--------------------------------------------------------------- //memcpy(&(m->olsr_source),&addr_ip,sizeof(struct olsr_ip_addr)); //memcpy(&(m->olsr_source),&(message->source_addr),sizeof(struct olsr_ip_addr)); //commented by Y.Ge memcpy(&(m->olsr_source), &(message->originator_addr), sizeof(struct olsr_ip_addr)); //added by Y.Ge //--------------------------------------------------------------- //hinfo->next_linktype = (char *)haddr - (char *)hinfo;//commented by Y.Ge //hinfo->next_linktype = ntohs(hinfo->next_linktype); //commented by Y.Ge hinfo->link_msg_size = (char *)haddr - (char *)hinfo; //added by Y.Ge hinfo->link_msg_size = ntohs (hinfo->link_msg_size); //added by Y.Ge //h->hell_seqnum = htons(hello_seqnum++); //commented by Y.Ge //h->hell_mprseqnum = htons(message->mpr_seq_number); //commented by Y.Ge memset(h->hell_resvd, 0, sizeof(h->hell_resvd)); //added by Y.Ge h->hell_htime = olsr_compute_vtime (hello_int); //added by Y.Ge h->hell_willingness = message->willingness; //added by Y.Ge if (debug_level > 3) { printf ("++++++++++ HELLO packet chunked!\n"); //printf (" Message sequence: %d\n", ntohs(msg->olsr_seqnum)); printf (" HELLO sequence: %d\n", ntohs(m->olsr_msgseq)); printf (" HELLO packet size: %d\n", (char *)haddr - (char *)m); printf (" HELLO link message size: %d\n", (char *)haddr - (char *)hinfo); printf (" HELLO willingniss: %d\n", h->hell_willingness); fprintf (y_file,"++++++++++ HELLO packet chunked!\n"); //fprintf (y_file," Message sequence: %d\n", ntohs(msg->olsr_seqnum)); fprintf (y_file," HELLO sequence: %d\n",ntohs(m->olsr_msgseq)); fprintf (y_file," HELLO packet size: %d\n", (char *)haddr - (char *)m); fprintf (y_file," HELLO link message size: %d\n", (char *)haddr - (char *)hinfo); fprintf (y_file," HELLO willingniss: %d\n", h->hell_willingness); } //TRACE_OUTPUT(ifp, dst, outputsize); //(*output)(s6, flags, dst, outputsize); //inet6_output(s6, flags, dst, outputsize); //commented by Y.Ge tointerface (sndmsg, (struct hello_message *)NULL, (struct tc_message *)NULL, (struct mid_message *)NULL,(struct hna_message *)NULL, (struct interface *)NULL, ifp->my_index); //added by Y.Ge m = msg->olsr_msg; h = m->olsr_hello; hinfo = h->hell_info; haddr = hinfo->neigh_addr; npackets++; } for (nb = message->neighbors; nb != NULL; nb = nb->next) { outputsize = (char *)haddr - packet; if (outputsize > MAXPACKETSIZE - (int)sizeof (haddr)) { msg->olsr_packlen = htons(outputsize); //memset(msg->olsr_res, 0, sizeof(msg->olsr_res)); //commented by Y.Ge //msg->olsr_seqnum = htons(pkt_seqnum[ifp->my_index]++); //added by Y.Ge m->olsr_msgtype = HELLO_PACKET; m->olsr_vtime = olsr_compute_vtime (neighbor_hold_time); //added by Y.Ge //m->olsr_broad = MSG_NOBROADCAST; //commented by Y.Ge //m->olsr_nextmsg = (char *)haddr - (char *)m; //commented by Y.Ge //m->olsr_nextmsg = htons(m->olsr_nextmsg); //commented by Y.Ge m->olsr_msgsize = (char *)haddr - (char *)m; //added by Y.Ge m->olsr_msgsize = htons(m->olsr_msgsize); //added by Y.Ge m->olsr_ttl = 1; //added by Y.Ge m->olsr_hopcount = 0; //added by Y.Ge /* deal with packe sequence number of the chunked HELLO */ m->olsr_msgseq = htons(message->packet_seq_number + hello_chunk[ifp->my_index]); //added by Y.Ge hello_chunk[ifp->my_index]++; //added by Y.Ge //CRC hna added----------------------------------------------- //memcpy(&(m->olsr_source),&addr_ip,sizeof(struct olsr_ip_addr)); //memcpy(&(m->olsr_source),&(message->source_addr),sizeof(struct olsr_ip_addr)); //commented by Y.Ge memcpy(&(m->olsr_source), &(message->originator_addr), sizeof(struct olsr_ip_addr)); //added by Y.Ge //------------------------------------------------------------ //hinfo->next_linktype = (char *)haddr - (char *)hinfo; //commented by Y.Ge //hinfo->next_linktype = ntohs(hinfo->next_linktype); //commented by Y.Ge //h->hell_seqnum = htons(hello_seqnum++); //commented by Y.Ge //h->hell_mprseqnum = htons(message->mpr_seq_number); //commented by Y.Ge hinfo->link_msg_size = (char *)haddr - (char *)hinfo; //added by Y.Ge hinfo->link_msg_size = ntohs (hinfo->link_msg_size); //added by Y.Ge memset(h->hell_resvd, 0, sizeof(h->hell_resvd)); //added by Y.Ge h->hell_htime = olsr_compute_vtime (hello_int); //added by Y.Ge h->hell_willingness = message->willingness; //added by Y.Ge if (debug_level > 3) { printf ("++++++++++ HELLO packet chunked!\n"); //printf (" Message sequence: %d\n", ntohs(msg->olsr_seqnum)); printf (" HELLO sequence: %d\n", ntohs(m->olsr_msgseq)); printf (" HELLO packet size: %d\n", (char *)haddr - (char *)m); printf (" HELLO link message size: %d\n", (char *)haddr - (char *)hinfo); printf (" HELLO willingniss: %d\n", h->hell_willingness); fprintf (y_file,"++++++++++ HELLO packet chunked!\n"); //fprintf (y_file," Message sequence: %d\n", ntohs(msg->olsr_seqnum)); fprintf (y_file," HELLO sequence: %d\n",ntohs(m->olsr_msgseq)); fprintf (y_file," HELLO packet size: %d\n", (char *)haddr - (char *)m); fprintf (y_file," HELLO link message size: %d\n", (char *)haddr - (char *)hinfo); fprintf (y_file," HELLO willingniss: %d\n", h->hell_willingness); } //TRACE_OUTPUT(ifp, dst, outputsize); //(*output)(s6, flags, dst, outputsize); //inet6_output(s6, flags, dst, outputsize); //commented by Y.Ge tointerface (sndmsg, (struct hello_message *)NULL, (struct tc_message *)NULL, (struct mid_message *)NULL,(struct hna_message *)NULL, (struct interface *)NULL, ifp->my_index); //added by Y.Ge m = msg->olsr_msg; h = m->olsr_hello; hinfo = h->hell_info; haddr = hinfo->neigh_addr; //hinfo->link_type = i; //commented by Y.Ge hinfo->link_code = i; //added by Y.Ge lastpacket = sametype; npackets++; } //if (nb->status == i) //commented by Y.Ge if ((nb->neigh_status*4 + nb->link_status) == i) //added by Y.Ge, link_code = the combination of neigghbor status and lind status { if (debug_level > 3) { printf (" now consider neighbor %s with neighbor status: %d, link status: %d\n", convert_address_to_string (&nb->address), nb->neigh_status, nb->link_status); printf ("neighbor's link code is: %d\n", i); fprintf (y_file," now consider neighbor %s with neighbor status: %d, link status: %d\n", convert_address_to_string (&nb->address), nb->neigh_status, nb->link_status); fprintf (y_file,"neighbor's link code is: %d\n", i); } sametype++; if (sametype == 1) { //hinfo->link_type = i; //commented by Y.Ge hinfo->link_code = i; //added by Y.Ge memset(hinfo->res, 0, sizeof(hinfo->res)); } //CRC v4->v6 del *haddr = nb->address; //CRC v4->v6 memcpy(haddr,&(nb->address),sizeof(struct olsr_ip_addr)); found = 1; haddr++; } } if (sametype && sametype > lastpacket) { //hinfo->next_linktype = (char *)haddr - (char *)hinfo; //commented by Y.Ge //hinfo->next_linktype = ntohs(hinfo->next_linktype); //commented by Y.Ge hinfo->link_msg_size = (char *)haddr - (char *)hinfo; //added by Y.Ge hinfo->link_msg_size = ntohs (hinfo->link_msg_size); //added by Y.Ge hinfo = (struct hellinfo *)((char *)haddr); haddr = hinfo->neigh_addr; } } /* for i*/ //h->hell_seqnum = htons(hello_seqnum++); //commented by Y.Ge //h->hell_mprseqnum = htons(message->mpr_seq_number); //commented by Y.Ge memset(h->hell_resvd, 0, sizeof(h->hell_resvd)); //added by Y.Ge h->hell_htime = olsr_compute_vtime (hello_int); //added by Y.Ge h->hell_willingness = message->willingness; //added by Y.Ge m->olsr_msgtype = HELLO_PACKET; m->olsr_vtime = olsr_compute_vtime (neighbor_hold_time); //added by Y.Ge //m->olsr_broad = MSG_NOBROADCAST; //commented by Y.Ge //m->olsr_nextmsg = (char *)hinfo - (char *)m; //commented by Y.Ge //m->olsr_nextmsg = htons(m->olsr_nextmsg); //commented by Y.Ge m->olsr_msgsize = (char *)hinfo - (char *)m; //added by Y.Ge m->olsr_msgsize = htons(m->olsr_msgsize); //added by Y.Ge m->olsr_ttl = 1; //added by Y.Ge m->olsr_hopcount = 0; //added by Y.Ge m->olsr_msgseq = htons(message->packet_seq_number + hello_chunk[ifp->my_index]); //added by Y.Ge hello_chunk[ifp->my_index] ++; //CRC HNA add //--------------------------------------------------------------------------- //memcpy(&(m->olsr_source),&addr_ip,sizeof(struct olsr_ip_addr)); //memcpy(&(m->olsr_source),&(message->source_addr),sizeof(struct olsr_ip_addr)); //commented by Y.Ge memcpy(&(m->olsr_source), &(message->originator_addr), sizeof(struct olsr_ip_addr)); //added by Y.Ge //--------------------------------------------------------------------------- outputsize = (char *)hinfo - packet; msg->olsr_packlen = htons(outputsize); //memset(msg->olsr_res, 0, sizeof(msg->olsr_res)); //commented by Y.Ge //msg->olsr_seqnum = htons(pkt_seqnum[ifp->my_index]++); //added by Y.Ge if (debug_level > 3) { printf ("++++++++++ HELLO packet built finished!\n"); //printf (" Message sequence: %d\n", ntohs(msg->olsr_seqnum)); printf (" HELLO sequence: %d\n", ntohs(m->olsr_msgseq)); printf (" HELLO packet size: %d\n", (char *)haddr - (char *)m); printf (" HELLO link message size: %d\n", (char *)haddr - (char *)hinfo); printf (" HELLO willingniss: %d\n", h->hell_willingness); fprintf (y_file,"++++++++++ HELLO packet built finished!\n"); //fprintf (y_file," Message sequence: %d\n", ntohs(msg->olsr_seqnum)); fprintf (y_file," HELLO sequence: %d\n", ntohs(m->olsr_msgseq)); fprintf (y_file," HELLO packet size: %d\n", (char *)haddr - (char *)m); fprintf (y_file," HELLO link message size: %d\n", (char *)haddr - (char *)hinfo); fprintf (y_file," HELLO willingniss: %d\n", h->hell_willingness); } if (outputsize > MAXPACKETSIZE - (int)sizeof (struct olsrmsg)) { //TRACE_OUTPUT(ifp, dst, outputsize); //(*output)(s6, flags, dst, outputsize); //inet6_output(s6, flags, dst, outputsize); //commented by Y.Ge tointerface (sndmsg, (struct hello_message *)NULL, (struct tc_message *)NULL, (struct mid_message *)NULL,(struct hna_message *)NULL, (struct interface *)NULL, ifp->my_index); //added by Y.Ge } /* * Delete the list of neighbor messages. */ nb = message->neighbors; while (nb) { prev_nb = nb; nb = nb->next; free(prev_nb); } }/*************************** added by Y.Ge ****************//* * if the node uses QoS functions, * after build HELLO, the node builds QOSHELLO * to inform its own busy time */void qoshello_build(struct sockaddr *dst, int flags, struct interface *ifp){ int remainsize = outputsize - comm_head_size; struct olsrmsg *m = outputsize ? (struct olsrmsg *)((char *)msg->olsr_msg + remainsize) : msg->olsr_msg; struct qoshellomsg *qosh =m->olsr_qos_hello; olsr_u32_t *hello_busy_time = qosh->hell_busy; struct interface *interf; struct sockaddr address; if (debug_level >3) { printf ("\n\n-------------- in qos hello build -----------------\n"); fprintf (y_file,"\n\n-------------- in qos hello build -----------------\n"); printf ("originator address: %s\n", convert_address_to_string(&my_main_addr)); fprintf (y_file, "originator address: %s\n", convert_address_to_string(&my_main_addr)); printf ("sending address: %s\n", convert_address_to_string(&addr_manet[ifp->my_index])); fprintf (y_file,"sending address: %s\n", convert_address_to_string(&addr_manet[ifp->my_index])); } if (outputsize > MAXPACKETSIZE - (int)sizeof (struct olsrmsg)) { msg->olsr_packlen = htons(outputsize); //memset(msg->olsr_res, 0, sizeof(msg->olsr_res)); //commented by Y.Ge //msg->olsr_seqnum = htons(pkt_seqnum[ifp->my_index]++); //added by Y.Ge //TRACE_OUTPUT(ifp, dst, outputsize); //(*output)(s6, flags, dst, outputsize); //inet6_output(s6, flags, dst, outputsize); //commented by Y.Ge tointerface (sndmsg, (struct hello_message *)NULL, (struct tc_message *)NULL, (struct mid_message *)NULL,(struct hna_message *)NULL, (struct interface *)NULL, ifp->my_index); //added by Y.Ge
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -