int main(int argc, char *argv[]) { encryptionInit(); std::thread routing(start, &fwdTable); std::thread test(tcpreceive ,6969, std::ref(q), &fwdTable); GObject *window; GtkBuilder *builder; gtk_init (&argc, &argv); //Construct a GtkBuilder instance and load our UI description builder = gtk_builder_new (); gtk_builder_add_from_file (builder, "builder.ui", NULL); window = gtk_builder_get_object (builder, "window"); g_signal_connect (window, "destroy", G_CALLBACK (End), NULL); Button[0] = (GtkButton*) gtk_builder_get_object (builder, "button1"); Button[1] = (GtkButton*) gtk_builder_get_object (builder, "button2"); Button[2] = (GtkButton*) gtk_builder_get_object (builder, "button3"); Button[3] = (GtkButton*) gtk_builder_get_object (builder, "button4"); Button[4] = (GtkButton*) gtk_builder_get_object (builder, "button5"); g_signal_connect (Button[0], "clicked", G_CALLBACK (ButtonClick), NULL); g_signal_connect (Button[1], "clicked", G_CALLBACK (ButtonClick), NULL); g_signal_connect (Button[2], "clicked", G_CALLBACK (ButtonClick), NULL); g_signal_connect (Button[3], "clicked", G_CALLBACK (ButtonClick), NULL); g_signal_connect (Button[4], "clicked", G_CALLBACK (ButtonClick), NULL); Buffer[0] = (GtkTextBuffer*) gtk_builder_get_object(builder, "AllText1"); Buffer[1] = (GtkTextBuffer*) gtk_builder_get_object(builder, "AllText2"); Buffer[2] = (GtkTextBuffer*) gtk_builder_get_object(builder, "AllText3"); Buffer[3] = (GtkTextBuffer*) gtk_builder_get_object(builder, "AllText4"); Buffer[4] = (GtkTextBuffer*) gtk_builder_get_object(builder, "AllText5"); InputBar = (GtkEntry*) gtk_builder_get_object (builder, "TextInput"); ChatText = (GtkTextView*) gtk_builder_get_object (builder, "ChatText"); g_signal_connect (InputBar, "activate", G_CALLBACK (Printsend), NULL); //std::cout << "Destination IP" << std::endl; //std::cin >> DestinationIP; gtk_main (); std::cout << "Say something: " << std::endl; while(1){ Message.clear(); std::getline(std::cin, Message); if (Message.size()==0){ Message = getIP() + " is connected to you."; } sendMessage(getIP(), DestinationIP, getNextHop(DestinationIP, fwdTable), encrypt(Message,getReceiverKey(DestinationIP, fwdTable))); //string Hoi = encrypt(Message,getPublicKey()); //std:: cout << Hoi << ", " << decrypt(Hoi, getPublicKey()) << std::endl; //std::cout << getNextHop(DestinationIP) << std::endl; } }
error_t fowarding_send_internal(OpenQueueEntry_t *msg, ipv6_header_iht ipv6_header, uint8_t fw_SendOrfw_Rcv) { getNextHop(&(msg->l3_destinationAdd),&(msg->l2_nextORpreviousHop)); // getNextHop(&(msg->l3_sourceAdd),&(msg->l2_nextORpreviousHop)); if (msg->l2_nextORpreviousHop.type==ADDR_NONE) { openserial_printError(COMPONENT_FORWARDING,ERR_NO_NEXTHOP, (errorparameter_t)0, (errorparameter_t)0); return E_FAIL; } return iphc_sendFromForwarding(msg, ipv6_header,fw_SendOrfw_Rcv); }
void deleteButton(std::string IP){ for (int i = 0; i<5;i++){ std::string ButtonString = (std::string) gtk_button_get_label(Button[i]); if(IP==ButtonString){ //gtk_button_set_label(Button[i], "NONE"); gtk_widget_set_opacity((GtkWidget*) Button[i],0.5); gtk_widget_set_sensitive ((GtkWidget*) Button[i], false); if(getNextHop(DestinationIP, fwdTable) == ButtonString){ DestinationIP = ""; gtk_editable_set_editable( (GtkEditable*) InputBar, false); } } } }
void Printsend(GtkMenuItem *sender, gpointer user_data) { if (DestinationIP.size()!=0){ const gchar *Input = gtk_entry_get_text (InputBar); std::string Message = (std::string) Input; std::string Print = "You: " + Message + "\n"; const gchar *Insert = &Print[0]; gtk_text_buffer_insert_at_cursor(gtk_text_view_get_buffer(ChatText), Insert , -1); gtk_entry_set_text(InputBar, ""); sendMessage(getIP(), DestinationIP, getNextHop(DestinationIP, fwdTable), encrypt(Message,getReceiverKey(DestinationIP, fwdTable))); } Message.clear(); return; }
void AmBasicSipDialog::updateDialogTarget(const AmSipReply& reply) { if( (reply.code > 100) && (reply.code < 300) && !reply.to_uri.empty() && !reply.to_tag.empty() && (remote_uri.empty() || (reply.cseq_method.length()==6 && ((reply.cseq_method == SIP_METH_INVITE) || (reply.cseq_method == SIP_METH_UPDATE) || (reply.cseq_method == SIP_METH_NOTIFY))) || (reply.cseq_method == SIP_METH_SUBSCRIBE)) ) { setRemoteUri(reply.to_uri); if(!getNextHop().empty()) { string nh = reply.remote_ip + ":" + int2str(reply.remote_port) + "/" + reply.trsp; setNextHop(nh); } string ua = getHeader(reply.hdrs,"Server"); setRemoteUA(ua); } }
int32_t getNextHopwithObject(char *objectName) { //check the previous list int i, j, flagi, counter, prefixLength, prefixHop, tempLength; double smallestV; char *prefix; prefixLength = 0; prefixHop = -1; double tempdist[MAX_NODE]; smallestV = 9999; flagi = -1; counter = NodeAmount; for (i = 0; i < MAX_NODE; i++) tempdist[i] = dist[i]; while (counter) { smallestV = 9999; flagi = -1; for (i = 0; i < NodeAmount; i++) { if (tempdist[i] < smallestV) { smallestV = tempdist[i]; flagi = i; } } for (i = 0; i < objectCount[flagi]; i++) { if (strncmp(objectList[flagi][i], objectName, strlen(objectName)) == 0) return getNextHop(NodeList[flagi]); else if ((prefix = strstr(objectName, objectList[flagi][i])) != NULL ) //longest prefix match { tempLength = 0; if (objectName[0] == prefix[0]) { for (j = 0; j < 128; j++) { if (objectList[flagi][i][j] != '\0') { tempLength++; continue; } else break; } if (objectList[flagi][i][tempLength - 1] == '/') { if (tempLength > prefixLength) { prefixLength = tempLength; prefixHop = getNextHop(NodeList[flagi]); } } } } } tempdist[flagi] = 9999; counter--; } if (prefixHop != -1) return prefixHop; return -1; }