static void test_variables( libvlc_instance_t *p_vlc ) { libvlc_int_t *p_libvlc = p_vlc->p_libvlc_int; srand( time( NULL ) ); log( "Testing for integers\n" ); test_integer( p_libvlc ); log( "Testing for booleans\n" ); test_booleans( p_libvlc ); log( "Testing for floats\n" ); test_floats( p_libvlc ); log( "Testing for strings\n" ); test_strings( p_libvlc ); log( "Testing for addresses\n" ); test_address( p_libvlc ); log( "Testing the callbacks\n" ); test_callbacks( p_libvlc ); log( "Testing the limits\n" ); test_limits( p_libvlc ); log( "Testing choices\n" ); test_choices( p_libvlc ); log( "Testing var_Change()\n" ); test_change( p_libvlc ); log( "Testing type at creation\n" ); test_creation_and_type( p_libvlc ); }
javacall_bool bt_push_test_filter(const javacall_bt_address bdaddr, const char *filter) { char address[13] = {0}; javacall_bool auth; sprintf(address, "%02X%02X%02X%02X%02X%02X", bdaddr[5], bdaddr[4], bdaddr[3], bdaddr[2], bdaddr[1], bdaddr[0]); if (!test_address(address, &filter)) { return JAVACALL_FALSE; } if (javacall_bt_bcc_is_trusted(bdaddr, &auth) != JAVACALL_OK) { return JAVACALL_FALSE; } if (auth == JAVACALL_TRUE) { if (!test_prefix(&filter, ";authorized")) { return JAVACALL_FALSE; } } else { if (javacall_bt_bcc_is_authenticated(bdaddr, &auth) != JAVACALL_OK) { return JAVACALL_FALSE; } if (auth == JAVACALL_TRUE) { if (!test_prefix(&filter, ";authenticated")) { return JAVACALL_FALSE; } } } if (test_prefix(&filter, ";blacklist=")) { while (*filter != '\0') { if (test_address(address, &filter)) { return JAVACALL_FALSE; } while ((*filter != ';') && (*filter != '\0')) { filter++; } if (*filter == ';') { filter++; } else if (*filter != '\0') { return JAVACALL_FALSE; } } } return JAVACALL_TRUE; }
int main (int argc, char **argv) { qof_init(); if (cashobjects_register()) { test_address(); print_test_results(); } qof_close(); return get_rv(); }
gulong get_my_address() { gulong found; addrcnt = 0; #ifdef WIN32 gint i; SOCKET sd = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0); if (sd == SOCKET_ERROR) { return 0; } INTERFACE_INFO InterfaceList[20]; unsigned long nBytesReturned; if (WSAIoctl(sd, SIO_GET_INTERFACE_LIST, 0, 0, &InterfaceList, sizeof(InterfaceList), &nBytesReturned, 0, 0) == SOCKET_ERROR) { closesocket(sd); return 0; } gint nNumInterfaces = nBytesReturned / sizeof(INTERFACE_INFO); for (i = 0; i < nNumInterfaces; ++i) { struct sockaddr_in *pAddress; pAddress = (struct sockaddr_in *) & (InterfaceList[i].iiAddress); g_print("Interface %s\n", inet_ntoa(pAddress->sin_addr)); //u_long nFlags = InterfaceList[i].iiFlags; if (/*(nFlags & IFF_UP) &&*/ (addrcnt < 16)) addrs[addrcnt++] = ntohl(pAddress->sin_addr.s_addr); } closesocket(sd); #else // !WIN32 struct if_nameindex *ifnames, *ifnm; struct ifreq ifr; struct sockaddr_in sin; gint fd; fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) return 0; ifnames = if_nameindex(); for (ifnm = ifnames; ifnm && ifnm->if_name && ifnm->if_name[0]; ifnm++) { strncpy (ifr.ifr_name, ifnm->if_name, IFNAMSIZ); if (ioctl (fd, SIOCGIFADDR, &ifr) == 0) { memcpy (&sin, &(ifr.ifr_addr), sizeof (sin)); if (addrcnt < 16) addrs[addrcnt++] = ntohl(sin.sin_addr.s_addr); g_print ("Interface %s = IP %s\n", ifnm->if_name, inet_ntoa (sin.sin_addr)); } } if_freenameindex (ifnames); close(fd); #endif // WIN32 if ((found = test_address(0xc0000000, 0xff000000, FALSE)) != 0) // 192.x.x.x return found; if ((found = test_address(0xac000000, 0xff000000, FALSE)) != 0) // 172.x.x.x return found; if ((found = test_address(0x0a000000, 0xff000000, FALSE)) != 0) // 10.x.x.x return found; if ((found = test_address(0x7f000000, 0xff000000, TRUE)) != 0) // 127.x.x.x return found; if ((found = test_address(0x00000000, 0x00000000, FALSE)) != 0) // any address return found; return 0; }
//------------------------------------------------------------------------------ // Name: do_find // Desc: //------------------------------------------------------------------------------ void DialogReferences::do_find() { bool ok = false; edb::address_t address; const edb::address_t page_size = edb::v1::debugger_core->page_size(); const QString text = ui->txtAddress->text(); if(!text.isEmpty()) { ok = edb::v1::eval_expression(text, &address); } if(ok) { edb::v1::memory_regions().sync(); const QList<IRegion::pointer> regions = edb::v1::memory_regions().regions(); int i = 0; for(const IRegion::pointer ®ion: regions) { // a short circut for speading things up if(region->accessible() || !ui->chkSkipNoAccess->isChecked()) { const edb::address_t page_count = region->size() / page_size; const QVector<quint8> pages = edb::v1::read_pages(region->start(), page_count); if(!pages.isEmpty()) { const quint8 *p = &pages[0]; const quint8 *const pages_end = &pages[0] + region->size(); while(p != pages_end) { if(pages_end - p < edb::v1::pointer_size()) { break; } const edb::address_t addr = p - &pages[0] + region->start(); edb::address_t test_address(0); memcpy(&test_address, p, edb::v1::pointer_size()); if(test_address == address) { auto item = new QListWidgetItem(edb::v1::format_pointer(addr)); item->setData(TypeRole, 'D'); item->setData(AddressRole, addr); ui->listWidget->addItem(item); } edb::Instruction inst(p, pages_end, addr); if(inst) { switch(inst.operation()) { case edb::Instruction::Operation::X86_INS_MOV: // instructions of the form: mov [ADDR], 0xNNNNNNNN Q_ASSERT(inst.operand_count() == 2); if(inst.operands()[0].general_type() == edb::Operand::TYPE_EXPRESSION) { if(inst.operands()[1].general_type() == edb::Operand::TYPE_IMMEDIATE && static_cast<edb::address_t>(inst.operands()[1].immediate()) == address) { auto item = new QListWidgetItem(edb::v1::format_pointer(addr)); item->setData(TypeRole, 'C'); item->setData(AddressRole, addr); ui->listWidget->addItem(item); } } break; case edb::Instruction::Operation::X86_INS_PUSH: // instructions of the form: push 0xNNNNNNNN Q_ASSERT(inst.operand_count() == 1); if(inst.operands()[0].general_type() == edb::Operand::TYPE_IMMEDIATE && static_cast<edb::address_t>(inst.operands()[0].immediate()) == address) { auto item = new QListWidgetItem(edb::v1::format_pointer(addr)); item->setData(TypeRole, 'C'); item->setData(AddressRole, addr); ui->listWidget->addItem(item); } break; default: if(is_jump(inst) || is_call(inst)) { if(inst.operands()[0].general_type() == edb::Operand::TYPE_REL) { if(inst.operands()[0].relative_target() == address) { auto item = new QListWidgetItem(edb::v1::format_pointer(addr)); item->setData(TypeRole, 'C'); item->setData(AddressRole, addr); ui->listWidget->addItem(item); } } } break; } } Q_EMIT updateProgress(util::percentage(i, regions.size(), p - &pages[0], region->size())); ++p; } } } else { Q_EMIT updateProgress(util::percentage(i, regions.size())); } ++i; } } }
int Handle_Packet (char *buffer, int bytes_recieved) { IP_Header *ip; int from_mask[4], to_mask[4]; unsigned int body_offset, body_size; #ifdef DEBUG #ifdef UNIX addr.s_addr = IP_FROM(buffer); fprintf (stdout, "\n%s", inet_ntoa(addr)); if (test_address (from_mask, flags.from_ip_mask) == 0) { fprintf (stdout, " (Src OK)"); } else { fprintf (stdout, " (Src WRONG)"); } addr.s_addr = IP_TO(buffer); fprintf (stdout, "\n%s", inet_ntoa(addr)); if (test_address (to_mask, flags.to_ip_mask) == 0) { fprintf (stdout, " (Dest OK)"); } else { fprintf (stdout, " (Dest WRONG)"); } fprintf (stdout, "\nProtocol: %d", PROTOCOL(buffer)); #endif #endif /********************************************************/ /* Dumping ethernet headers ? */ /********************************************************/ if (flags.eth_hd == YES) { dump_eth_header(ETH_HEADER(buffer), flags.desc); } if (ETH_FORMAT(buffer) != ETHERNET_II) { return HANDLER_OK; } /********************************************************/ /* Dump *IP* stuff *ONLY* */ /********************************************************/ if (ETH_TYPE(buffer) == IP_ETH) { /********************************************************/ /* Set IP masks */ /********************************************************/ get_addr (IP_FROM(buffer), from_mask); get_addr (IP_TO(buffer), to_mask); /*******************************************************/ /* Checking IP address with mask */ /* Checking port numbers */ /* Checking protocol */ /* ... */ /*******************************************************/ if ( (test_address (from_mask, flags.from_ip_mask) == 0) && (test_address (to_mask, flags.to_ip_mask) == 0) && ( (flags.from_port_num == ALL_PORT) || (get_src_port_number(buffer) == flags.from_port_num) ) && ( (flags.to_port_num == ALL_PORT) || (get_dst_port_number(buffer) == flags.to_port_num) ) && ( ( (PROTOCOL(buffer) == UDP_PACKET) && (flags.proto_udp == YES) ) || ( (PROTOCOL(buffer) == TCP_PACKET) && (flags.proto_tcp == YES) ) || ( (PROTOCOL(buffer) == IGMP_PACKET) && (flags.proto_igmp == YES) ) ) /* end test on protocol */ ) /* end if condition statement */ { /******************************************************************/ /* Sanity check */ /******************************************************************/ ip = IP_HEADER(buffer); if ( ((ntohs(ip->ip_total_length)+ETH_HD_LEN) > bytes_recieved) && (flags.verbose == YES) ) { fprintf (stdout, "\nWARNING: received %d bytes", bytes_recieved); fprintf (stdout, "\n total packet size "); fprintf (stdout, "%d bytes", ntohs(ip->ip_total_length)+ETH_HD_LEN); fprintf (stdout, "\n\nThis may be a network error ... skipping"); fprintf (stdout, " the packet.\n"); fflush (stdout); return HANDLER_OK; } /******************************************************************/ /* Dump the IP header if requested */ /******************************************************************/ if (flags.ip_hd == YES) { dump_ip_header(ip, flags.desc); } /******************************************************************/ /* Dump the following headers if requested: */ /* - UDP */ /* - TCP */ /* */ /* In the case of UDP, it may be a RIP message. */ /******************************************************************/ if (PROTOCOL(buffer) == UDP_PACKET) { if (flags.udp_hd == YES) { dump_udp_header(UDP_HEADER(buffer), flags.desc); } switch (UDP_SRC_PORT(buffer)) { case SER_RIP: if (RIP_VERSION(buffer) == 1) { dump_rip1_header (buffer, flags.desc); } else { fprintf (stdout, "\nRIP version 2 !"); }; break; default:; } } if ((PROTOCOL(buffer) == TCP_PACKET) && (flags.tcp_hd == YES)) { dump_tcp_header(TCP_HEADER(buffer), flags.desc); } /********************************************************************/ /* Dump the packet bopy for the following protocols if requested: */ /* - TCP */ /* - UDP */ /* - IGMP */ /* */ /* Note that for IGMP the IGMP header is not separated from the bo- */ /* -dy. */ /********************************************************************/ if (flags.body_level != BD_NONE) { /* Get offset and size of the body */ body_info (buffer, &body_offset, &body_size); switch (flags.body_level) { case BD_HEXA : dump_hexa (buffer+body_offset, body_size); break; case BD_ASCII : dump_ascii (buffer+body_offset, body_size); break; case BD_MIX : dump (buffer+body_offset, body_size); break; default : { if (flags.verbose == YES) { fprintf (stderr, "\nUnknown dump_body option\n"); } else { fprintf (stderr, "\nInternal error\n"); } return HANDLER_ERR; } } /* end switch (dump_body) */ } /* end if for UDP/TCP/dump_body */ } return HANDLER_OK; } /* end if for *IP* stuff *ONLY* */ /*****************************************************/ /* So it is not an IP stuff */ /*****************************************************/ /******************************************************/ /* May be it is ARP ? */ /******************************************************/ if ((ETH_TYPE(buffer) == ARP_ETH) && (flags.proto_arp == YES)) { dump_ARP_header (ARP_HEADER(buffer), flags.desc); } return HANDLER_OK; }