⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scrambler.hh

📁 COPE the first practical network coding scheme which is developped on click
💻 HH
字号:
#ifndef SCRAMBLER_HH#define SCRAMBLER_HH#include<click/packet.hh>/* * note: not an element! * xor's two packets  */CLICK_DECLSclass Scrambler { public:    Scrambler()  {}		  ~Scrambler() {}		    inline WritablePacket* xor_packet(Packet *packet1, Packet *packet2, uint16_t, uint16_t);};// do we need 'inline'?inline WritablePacket *Scrambler::xor_packet(Packet *packet1, Packet *packet2, uint16_t len1, uint16_t len2){  // note that packets should arrive without ethernet headers  // not sure if the check is necessary  if (!packet1 || !packet2)  // add a chatter?  click_chatter... #include <click/glue.hh> in that case     return 0;//*** need to extract packet header first// might need something like...//  click_ether *eh = (click_ether *) p->data();//  struct srpacket *pk = (struct srpacket *) (eh+1);  WritablePacket *p_out;  unsigned char *p_out_data;  //int len1 = packet1->length();   //int len2 = packet2->length();//*** see if the length include any end of string symbol  int i;// *** need to make sure we don't encode IP headers, or actually...?// the following could be optimised now that len1 and len2 are both passed to the function// but we'll leave it for now  // first check if the two packets are of equal length  // pad up the shorter one with '0'  // xor the data  if (len1 < len2) {    p_out = packet2->clone()->uniqueify();    const unsigned char *p1_data = packet1->data();    p_out_data = p_out->data();    for (i = 0; i < len1; i++)            p_out_data[i] ^= p1_data[i];    // xor the rest with a sequence of "0"    for (; i < len2; i++)      p_out_data[i] ^= char(0);  //*** is that right?!?!  } else {    p_out = packet1->clone()->uniqueify();    const unsigned char *p2_data = packet2->data();    p_out_data = p_out->data();    for (i = 0; i < len2; i++)            p_out_data[i] ^= p2_data[i];    // xor the rest with a sequence of "0"    for (; i < len1; i++)      p_out_data[i] ^= char(0);  //*** is that right?!?!  }  return p_out;}CLICK_ENDDECLS#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -