/* * dump_section - dump the current section */ void Dump_section( void ) /***********************/ { section_dbg_header sdh; Wread( &sdh, sizeof( section_dbg_header ) ); Wdputs( "Section " ); Putdec( sdh.section_id ); Wdputs( " (off=" ); Puthex( Curr_sectoff, 8 ); Wdputslc( ")\n" ); Wdputslc( "=========================\n" ); Dump_header( (char *)&sdh.mod_offset, sdh_msg ); Wdputslc( "\n" ); currSect = sdh.section_id; if( Debug_options & MODULE_INFO ) { dump_module_info( &sdh ); } if( Debug_options & GLOBAL_INFO ) { dump_global_info( &sdh ); } if( Debug_options & ADDR_INFO ) { dump_addr_info( &sdh ); } } /* dump_section */
void cassidy_host_continue(struct adns_continuation *cr, err_t ugh) { if(ugh) { DBG_log("cassidy error: %s", ugh); /* continuation is freed by dnskey */ return; } struct addrinfo *ai = sort_addr_info(cr->ipanswers); dump_addr_info(ai); cr->ipanswers = ai; }
int main(void) { struct api_signature *sig = NULL; int load_type, load_unit, load_slice, load_partition; int i; const char * loaderdev; /* * If we can't find the magic signature and related info, exit with a * unique error code that U-Boot reports as "## Application terminated, * rc = 0xnnbadab1". Hopefully 'badab1' looks enough like "bad api" to * provide a clue. It's better than 0xffffffff anyway. */ if (!api_search_sig(&sig)) return (0x01badab1); syscall_ptr = sig->syscall; if (syscall_ptr == NULL) return (0x02badab1); if (sig->version > API_SIG_VERSION) return (0x03badab1); /* Clear BSS sections */ bzero(__sbss_start, __sbss_end - __sbss_start); bzero(__bss_start, _end - __bss_start); /* * Initialise the heap as early as possible. Once this is done, * alloc() is usable. The stack is buried inside us, so this is safe. */ uboot_heap_start = round_page((uintptr_t)end); uboot_heap_end = uboot_heap_start + 512 * 1024; setheap((void *)uboot_heap_start, (void *)uboot_heap_end); /* * Set up console. */ cons_probe(); printf("Compatible U-Boot API signature found @%x\n", (uint32_t)sig); printf("\n"); printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); printf("\n"); dump_sig(sig); dump_addr_info(); meminfo(); /* * Enumerate U-Boot devices */ if ((devs_no = ub_dev_enum()) == 0) panic("no U-Boot devices found"); printf("Number of U-Boot devices: %d\n", devs_no); get_load_device(&load_type, &load_unit, &load_slice, &load_partition); /* * March through the device switch probing for things. */ for (i = 0; devsw[i] != NULL; i++) { if (devsw[i]->dv_init == NULL) continue; if ((devsw[i]->dv_init)() != 0) continue; printf("Found U-Boot device: %s\n", devsw[i]->dv_name); currdev.d_dev = devsw[i]; currdev.d_type = currdev.d_dev->dv_type; currdev.d_unit = 0; if ((load_type == -1 || (load_type & DEV_TYP_STOR)) && strcmp(devsw[i]->dv_name, "disk") == 0) { if (probe_disks(i, load_type, load_unit, load_slice, load_partition) == 0) break; } if ((load_type == -1 || (load_type & DEV_TYP_NET)) && strcmp(devsw[i]->dv_name, "net") == 0) break; } /* * If we couldn't find a boot device, return an error to u-boot. * U-boot may be running a boot script that can try something different * so returning an error is better than forcing a reboot. */ if (devsw[i] == NULL) { printf("No boot device found!\n"); return (0xbadef1ce); } env_setenv("currdev", EV_VOLATILE, uboot_fmtdev(&currdev), uboot_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, uboot_fmtdev(&currdev), env_noset, env_nounset); setenv("LINES", "24", 1); /* optional */ setenv("prompt", "loader>", 1); archsw.arch_loadaddr = uboot_loadaddr; archsw.arch_getdev = uboot_getdev; archsw.arch_copyin = uboot_copyin; archsw.arch_copyout = uboot_copyout; archsw.arch_readin = uboot_readin; archsw.arch_autoload = uboot_autoload; interact(); /* doesn't return */ return (0); }
int main(void) { struct api_signature *sig = NULL; int diskdev, i, netdev, usedev; struct open_file f; const char * loaderdev; if (!api_search_sig(&sig)) return (-1); syscall_ptr = sig->syscall; if (syscall_ptr == NULL) return (-2); if (sig->version > API_SIG_VERSION) return (-3); /* Clear BSS sections */ bzero(__sbss_start, __sbss_end - __sbss_start); bzero(__bss_start, _end - __bss_start); /* * Set up console. */ cons_probe(); printf("Compatible API signature found @%x\n", (uint32_t)sig); dump_sig(sig); dump_addr_info(); /* * Initialise the heap as early as possible. Once this is done, * alloc() is usable. The stack is buried inside us, so this is * safe. */ setheap((void *)end, (void *)(end + 512 * 1024)); /* * Enumerate U-Boot devices */ if ((devs_no = ub_dev_enum()) == 0) panic("no U-Boot devices found"); printf("Number of U-Boot devices: %d\n", devs_no); printf("\n"); printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); meminfo(); /* * March through the device switch probing for things -- sort of. * * The devsw array will have one or two items in it. If * LOADER_DISK_SUPPORT is defined the first item will be a disk (which * may not actually work if u-boot didn't supply one). If * LOADER_NET_SUPPORT is defined the next item will be a network * interface. Again it may not actually work at the u-boot level. * * The original logic was to always use a disk if it could be * successfully opened, otherwise use the network interface. Now that * logic is amended to first check whether the u-boot environment * contains a loaderdev variable which tells us which device to use. If * it does, we use it and skip the original (second) loop which "probes" * for a device. We still loop over the devsw just in case it ever gets * expanded to hold more than 2 devices (but then unit numbers, which * don't currently exist, may come into play). If the device named by * loaderdev isn't found, fall back using to the old "probe" loop. * * The original probe loop still effectively behaves as it always has: * the first usable disk device is choosen, and a network device is used * only if no disk device is found. The logic has been reworked so that * it examines (and thus lists) every potential device along the way * instead of breaking out of the loop when the first device is found. */ loaderdev = ub_env_get("loaderdev"); usedev = -1; if (loaderdev != NULL) { for (i = 0; devsw[i] != NULL; i++) { if (strcmp(loaderdev, devsw[i]->dv_name) == 0) { if (devsw[i]->dv_init == NULL) continue; if ((devsw[i]->dv_init)() != 0) continue; usedev = i; goto have_device; } } printf("U-Boot env contains 'loaderdev=%s', " "device not found.\n", loaderdev); } printf("Probing for bootable devices...\n"); diskdev = -1; netdev = -1; for (i = 0; devsw[i] != NULL; i++) { if (devsw[i]->dv_init == NULL) continue; if ((devsw[i]->dv_init)() != 0) continue; printf("Bootable device: %s\n", devsw[i]->dv_name); if (strncmp(devsw[i]->dv_name, "disk", strlen(devsw[i]->dv_name)) == 0) { f.f_devdata = &currdev; currdev.d_dev = devsw[i]; currdev.d_type = currdev.d_dev->dv_type; currdev.d_unit = 0; currdev.d_disk.slice = 0; if (devsw[i]->dv_open(&f, &currdev) == 0) { devsw[i]->dv_close(&f); if (diskdev == -1) diskdev = i; } } else if (strncmp(devsw[i]->dv_name, "net", strlen(devsw[i]->dv_name)) == 0) { if (netdev == -1) netdev = i; } } if (diskdev != -1) usedev = diskdev; else if (netdev != -1) usedev = netdev; else panic("No bootable devices found!\n"); have_device: currdev.d_dev = devsw[usedev]; currdev.d_type = devsw[usedev]->dv_type; currdev.d_unit = 0; if (currdev.d_type == DEV_TYP_STOR) currdev.d_disk.slice = 0; printf("Current device: %s\n", currdev.d_dev->dv_name); env_setenv("currdev", EV_VOLATILE, uboot_fmtdev(&currdev), uboot_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, uboot_fmtdev(&currdev), env_noset, env_nounset); setenv("LINES", "24", 1); /* optional */ setenv("prompt", "loader>", 1); archsw.arch_getdev = uboot_getdev; archsw.arch_copyin = uboot_copyin; archsw.arch_copyout = uboot_copyout; archsw.arch_readin = uboot_readin; archsw.arch_autoload = uboot_autoload; interact(); /* doesn't return */ return (0); }
int main(int argc, char *argv[]) { err_t err = NULL; struct addrinfo hints, *result1, *result2; unsigned char buffer1[1024]; unsigned int buffer1_len = sizeof(buffer1); unsigned int serial_size; int i,s; #ifdef HAVE_EFENCE EF_PROTECT_FREE=1; #endif initproctitle(argc, argv); progname = argv[0]; leak_detective = 1; tool_init_log(); cur_debugging |= DBG_DNS; zero(&hints); hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */ hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */ hints.ai_protocol = 0; /* Any protocol */ hints.ai_canonname = NULL; hints.ai_addr = NULL; hints.ai_next = NULL; if(argc==1) { printf("usage: %s [name]...\n", progname); exit(10); } for(i=1; i < argc; i++) { DBG_log("looking up: %s\n", argv[i]); s = getaddrinfo(argv[i], NULL, &hints, &result1); if(s!=0) { printf("lookup: %s a/aaaa lookup error: %s\n" , argv[i], gai_strerror(s)); continue; } /* sort things so they come out consistently */ result1 = sort_addr_info(result1); dump_addr_info(result1); /* now serialize it into the buffer */ serial_size = serialize_addr_info(result1, buffer1, buffer1_len); freeaddrinfo(result1); DBG_log("serialized size=%u\n", serial_size); result2 = deserialize_addr_info(buffer1, serial_size); dump_addr_info(result2); osw_freeaddrinfo(result2); } report_leaks(); tool_close_log(); exit(0); }
int main(void) { struct api_signature *sig = NULL; int i; struct open_file f; if (!api_search_sig(&sig)) return (-1); syscall_ptr = sig->syscall; if (syscall_ptr == NULL) return (-2); if (sig->version > API_SIG_VERSION) return (-3); /* Clear BSS sections */ bzero(__sbss_start, __sbss_end - __sbss_start); bzero(__bss_start, _end - __bss_start); /* * Set up console. */ cons_probe(); printf("Compatible API signature found @%x\n", (uint32_t)sig); dump_sig(sig); dump_addr_info(); /* * Initialise the heap as early as possible. Once this is done, * alloc() is usable. The stack is buried inside us, so this is * safe. */ setheap((void *)end, (void *)(end + 512 * 1024)); /* * Enumerate U-Boot devices */ if ((devs_no = ub_dev_enum()) == 0) panic("no U-Boot devices found"); printf("Number of U-Boot devices: %d\n", devs_no); printf("\n"); printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); meminfo(); /* * March through the device switch probing for things. */ for (i = 0; devsw[i] != NULL; i++) { if (devsw[i]->dv_init == NULL) continue; if ((devsw[i]->dv_init)() != 0) continue; printf("\nDevice: %s\n", devsw[i]->dv_name); currdev.d_dev = devsw[i]; currdev.d_type = currdev.d_dev->dv_type; currdev.d_unit = 0; if (strncmp(devsw[i]->dv_name, "disk", strlen(devsw[i]->dv_name)) == 0) { f.f_devdata = &currdev; currdev.d_disk.slice = 0; if (devsw[i]->dv_open(&f,&currdev) == 0) break; } if (strncmp(devsw[i]->dv_name, "net", strlen(devsw[i]->dv_name)) == 0) break; } if (devsw[i] == NULL) panic("No boot device found!"); env_setenv("currdev", EV_VOLATILE, uboot_fmtdev(&currdev), uboot_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, uboot_fmtdev(&currdev), env_noset, env_nounset); setenv("LINES", "24", 1); /* optional */ setenv("prompt", "loader>", 1); archsw.arch_getdev = uboot_getdev; archsw.arch_copyin = uboot_copyin; archsw.arch_copyout = uboot_copyout; archsw.arch_readin = uboot_readin; archsw.arch_autoload = uboot_autoload; interact(); /* doesn't return */ return (0); }