void toggleSwitches(void){
	if (commands[0] == high(OW_DS2405_FAMILY_CODE) 
		&& commands[1] == low(OW_DS2405_FAMILY_CODE)
		&& (commands[2] == COMMAND_OFF || commands[2] == COMMAND_ON)){
		unsigned char stat = MT8870_GetStat();

		for (unsigned char i=0; i<switchCurr; i++){

				if (stat == COMMAND_OFF
					&& DS24x05_GetState(owDevicesIDs[i]) == true){

					DS24x05_Toggle(owDevicesIDs[i]);

					printf("\r");
					print_address(owDevicesIDs[i]);
					printf(" - Switch OFF");
				}else if (stat == COMMAND_ON
						  && DS24x05_GetState(owDevicesIDs[i]) == false){

					DS24x05_Toggle(owDevicesIDs[i]);

					printf("\r");
					print_address(owDevicesIDs[i]);
					printf(" - Switch ON");
				}
		}
		commands_Reset();
	}
}
/*---------------------------------------------------------------------------*/
void print_addresses(void)
{
  uip_ds6_addr_t *lladdr;


  printf("link-local IPv6 address: ");
  
  lladdr = uip_ds6_get_link_local(-1);
  if(lladdr != NULL){
    print_address(lladdr);  
    printf("\r\n");
  }
  else
    printf("None\r\n");
  
  printf("global IPv6 address: ");
  
  lladdr = uip_ds6_get_global(-1);
  if(lladdr != NULL){
    print_address(lladdr);  
    printf("\r\n");
  }
  else
    printf("None\r\n");

}
Beispiel #3
0
enum sym_get_lval symbol_picker_interactive(const char* name, const struct sgv_data* sgv,
                                            struct dbg_lvalue* rtn)
{
    char        buffer[512];
    unsigned    i;

    if (!dbg_interactiveP)
    {
        dbg_printf("More than one symbol named %s, picking the first one\n", name);
        *rtn = sgv->syms[0].lvalue;
        return sglv_found;
    }

    dbg_printf("Many symbols with name '%s', "
               "choose the one you want (<cr> to abort):\n", name);
    for (i = 0; i < sgv->num; i++)
    {
        if (sgv->num - sgv->num_thunks > 1 && (sgv->syms[i].flags & SYMFLAG_THUNK) && !DBG_IVAR(AlwaysShowThunks))
            continue;
        dbg_printf("[%d]: ", i + 1);
        if (sgv->syms[i].flags & SYMFLAG_LOCAL)
        {
            dbg_printf("%s %sof %s\n",
                       sgv->syms[i].flags & SYMFLAG_PARAMETER ? "Parameter" : "Local variable",
                       sgv->syms[i].flags & (SYMFLAG_REGISTER|SYMFLAG_REGREL) ? "(in a register) " : "",
                       name);
        }
        else if (sgv->syms[i].flags & SYMFLAG_THUNK)
        {
            print_address(&sgv->syms[i].lvalue.addr, TRUE);
            /* FIXME: should display where the thunks points to */
            dbg_printf(" thunk %s\n", name);
        }
        else
        {
            print_address(&sgv->syms[i].lvalue.addr, TRUE);
            dbg_printf("\n");
        }
    }
    do
    {
        i = 0;
        if (input_read_line("=> ", buffer, sizeof(buffer)))
        {
            if (buffer[0] == '\0') return sglv_aborted;
            i = atoi(buffer);
            if (i < 1 || i > sgv->num)
                dbg_printf("Invalid choice %d\n", i);
        }
        else return sglv_aborted;
    } while (i < 1 || i > sgv->num);

    /* The array is 0-based, but the choices are 1..n,
     * so we have to subtract one before returning.
     */
    *rtn = sgv->syms[i - 1].lvalue;
    return sglv_found;
}
Beispiel #4
0
int main(
    int argc,
    char *argv[])
{
    BACNET_ADDRESS src = {
        0
    };  /* address where message came from */
    uint16_t pdu_len = 0;
    unsigned timeout = 100;     /* milliseconds */
    BACNET_ADDRESS my_address, broadcast_address;

    (void) argc;
    (void) argv;
    Device_Set_Object_Instance_Number(4194300);
    address_init();
    Init_Service_Handlers();
    dlenv_init();
    datalink_get_broadcast_address(&broadcast_address);
    print_address("Broadcast", &broadcast_address);
    datalink_get_my_address(&my_address);
    print_address("Address", &my_address);
    printf("BACnet stack running...\n");
    /* loop forever */
    for (;;) {
        /* input */

        /* returns 0 bytes on timeout */
        pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
        /* process */
        if (pdu_len) {
            npdu_handler(&src, &Rx_Buf[0], pdu_len);
        }
        if (I_Am_Request) {
            I_Am_Request = false;
            Send_I_Am(&Handler_Transmit_Buffer[0]);
        } else if (Who_Is_Request) {
            Who_Is_Request = false;
            Send_WhoIs(-1, -1);
        } else {
            Read_Properties();
        }

        /* output */

        /* blink LEDs, Turn on or off outputs, etc */

        /* wait for ESC from keyboard before quitting */
        if (kbhit() && (getch() == 0x1B))
            break;
    }

    print_address_cache();

    return 0;
}
Beispiel #5
0
static void
at_return(app_pc instr_addr, app_pc target_addr)
{
    file_t f = (file_t)(ptr_uint_t) dr_get_tls_field(dr_get_current_drcontext());
#ifdef SHOW_SYMBOLS
    print_address(f, instr_addr, "RETURN @ ");
    print_address(f, target_addr, "\t to ");
#else
    dr_fprintf(f, "RETURN @ "PFX" to "PFX"\n", instr_addr, target_addr);
#endif
}
Beispiel #6
0
print_ranges_property(device *me,
		      const device_property *property)
{
  int range_nr;
  range_property_spec range;
  for (range_nr = 0;
       device_find_range_array_property(me, property->name, range_nr, &range);
       range_nr++) {
    print_address(me, &range.child_address);
    print_address(device_parent(me), &range.parent_address);
    print_size(me, &range.size);
  }
}
Beispiel #7
0
/***********************************************************************
 *           break_should_continue
 *
 * Determine if we should continue execution after a SIGTRAP signal when
 * executing in the given mode.
 */
BOOL break_should_continue(ADDRESS64* addr, DWORD code)
{
    enum dbg_exec_mode  mode = dbg_curr_thread->exec_mode;


    if (dbg_curr_thread->stopped_xpoint > 0)
    {
        if (!should_stop(dbg_curr_thread->stopped_xpoint)) return TRUE;

        switch (dbg_curr_process->bp[dbg_curr_thread->stopped_xpoint].xpoint_type)
        {
        case be_xpoint_break:
        case be_xpoint_watch_exec:
            dbg_printf("Stopped on breakpoint %d at ", dbg_curr_thread->stopped_xpoint);
            print_address(&dbg_curr_process->bp[dbg_curr_thread->stopped_xpoint].addr, TRUE);
            dbg_printf("\n");
            break;
        case be_xpoint_watch_read:
        case be_xpoint_watch_write:
            dbg_printf("Stopped on watchpoint %d at ", dbg_curr_thread->stopped_xpoint);
            print_address(addr, TRUE);
            dbg_printf(" new value %s\n",
                       wine_dbgstr_longlong(dbg_curr_process->bp[dbg_curr_thread->stopped_xpoint].w.oldval));
        }
        return FALSE;
    }

    /*
     * If our mode indicates that we are stepping line numbers,
     * get the current function, and figure out if we are exactly
     * on a line number or not.
     */
    if (mode == dbg_exec_step_over_line || mode == dbg_exec_step_into_line)
    {
	if (symbol_get_function_line_status(addr) == dbg_on_a_line_number)
            dbg_curr_thread->exec_count--;
    }
    else if (mode == dbg_exec_step_over_insn || mode == dbg_exec_step_into_insn)
        dbg_curr_thread->exec_count--;

    if (dbg_curr_thread->exec_count > 0 || mode == dbg_exec_finish)
    {
	/*
	 * We still need to execute more instructions.
	 */
	return TRUE;
    }

    /* no breakpoint, continue if in continuous mode */
    return mode == dbg_exec_cont || mode == dbg_exec_finish;
}
Beispiel #8
0
static void
at_call(app_pc instr_addr, app_pc target_addr)
{
    file_t f = (file_t)(ptr_uint_t) dr_get_tls_field(dr_get_current_drcontext());
    dr_mcontext_t mc = {sizeof(mc),DR_MC_CONTROL/*only need xsp*/};
    dr_get_mcontext(dr_get_current_drcontext(), &mc);
#ifdef SHOW_SYMBOLS
    print_address(f, instr_addr, "CALL @ ");
    print_address(f, target_addr, "\t to ");
    dr_fprintf(f, "\tTOS is "PFX"\n", mc.xsp);
#else
    dr_fprintf(f, "CALL @ "PFX" to "PFX", TOS is "PFX"\n",
               instr_addr, target_addr, mc.xsp);
#endif
}
Beispiel #9
0
retc_t
disasm_addr(struct ps_prochandle * ph, ulong_t addr, int num_inst)
{
	ulong_t 	offset;
	ulong_t 	end;
	int		vers = V8_MODE;

	if (ph->pp_dmodel == PR_MODEL_LP64)
		vers = V9_MODE | V9_SGI_MODE;

	for (offset = addr,
	    end = addr + num_inst * 4;
	    offset < end; offset += 4) {
		char *		instr_str;
		unsigned int	instr;

		if (ps_pread(ph, offset, (char *)&instr,
		    sizeof (unsigned)) != PS_OK)
			perror("da: ps_pread");

		cur_ph = ph;
		instr_str = disassemble(instr, offset, print_address,
			0, 0, vers);

		printf("%-30s: %s\n", print_address(offset), instr_str);
	}
	return (RET_OK);
}
Beispiel #10
0
/* Like print_address with slightly different parameters.  */
static void
dis_asm_print_address (bfd_vma addr, struct disassemble_info *info)
{
  struct gdbarch *gdbarch = info->application_data;

  print_address (gdbarch, addr, info->stream);
}
Beispiel #11
0
int main(int argc, const char * argv[]) {
    
    struct address data[SIZE];
    int i = 0, operation;
    
    while (1) {
        
        get_operation(&operation);
        
        if (operation == 2) {
            break;
        }
        else if (operation == 0){
            if (i < SIZE){
                data[i++] = input_address();
            }
            else
                puts("\n\nDatensatz voll. Keine Aufnahme zusaetzlicher Daten moeglich.\n\n");
        }
        else if (operation == 1){
            if(i == 0){
                puts("\n\nEs sind noch keine Datensaetze vorhanden. Geben Sie bitte erst welche ein.\n\n");
            }
            else{
                for (int j = 0; j < i ; j++) {
                    print_address(&data[j]);
                }
            }   
        }
        
    }
    return EXIT_SUCCESS;
}
Beispiel #12
0
/* Function to set the disassembly window's content.
   Disassemble count lines starting at pc.
   Return address of the count'th instruction after pc.  */
static CORE_ADDR
tui_disassemble (struct gdbarch *gdbarch, struct tui_asm_line *asm_lines,
		 CORE_ADDR pc, int count)
{
  string_file gdb_dis_out;

  /* Now construct each line.  */
  for (; count > 0; count--, asm_lines++)
    {
      if (asm_lines->addr_string)
        xfree (asm_lines->addr_string);
      if (asm_lines->insn)
        xfree (asm_lines->insn);
      
      print_address (gdbarch, pc, &gdb_dis_out);
      asm_lines->addr = pc;
      asm_lines->addr_string = xstrdup (gdb_dis_out.c_str ());

      gdb_dis_out.clear ();

      pc = pc + gdb_print_insn (gdbarch, pc, &gdb_dis_out, NULL);

      asm_lines->insn = xstrdup (gdb_dis_out.c_str ());

      /* Reset the buffer to empty.  */
      gdb_dis_out.clear ();
    }
  return pc;
}
Beispiel #13
0
/*----------------------------------------------------------------------------*/
  void
  print_node_conf(void){
    PRINTF("[CFG]: NODE: ");
    print_address(&(conf.my_address));
    PRINTF("\n");
    PRINTF("[CFG]: - Network ID: %d\n[CFG]: - Beacon Period: %d\n[CFG]: - "
      "Report Period: %d\n[CFG]: - Rules TTL: %d\n[CFG]: - Min RSSI: "
      "%d\n[CFG]: - Packet TTL: %d\n[CFG]: - Next Hop -> Sink: ",
      conf.my_net, conf.beacon_period, conf.report_period, 
      conf.rule_ttl, conf.rssi_min, conf.packet_ttl);
    print_address(&(conf.nxh_vs_sink));
    PRINTF(" (hops: %d, rssi: %d)\n", conf.hops_from_sink, conf.rssi_from_sink);
    PRINTF("[CFG]: - Sink: ");
    print_address(&(conf.sink_address));
    PRINTF("\n");
  }
Beispiel #14
0
int
connect_to_ip (const ip_address *ip, int port, const char *print)
{
  struct sockaddr_storage ss;
  struct sockaddr *sa = (struct sockaddr *)&ss;
  int sock;

  /* If PRINT is non-NULL, print the "Connecting to..." line, with
     PRINT being the host name we're connecting to.  */
  if (print)
    {
      const char *txt_addr = print_address (ip);
      if (0 != strcmp (print, txt_addr))
        {
				  char *str = NULL, *name;

          if (opt.enable_iri && (name = idn_decode ((char *) print)) != NULL)
            {
              int len = strlen (print) + strlen (name) + 4;
              str = xmalloc (len);
              snprintf (str, len, "%s (%s)", name, print);
              str[len-1] = '\0';
              xfree (name);
            }

          logprintf (LOG_VERBOSE, _("Connecting to %s|%s|:%d... "),
                     str ? str : escnonprint_uri (print), txt_addr, port);

					if (str)
					  xfree (str);
        }
      else
       {
           if (ip->family == AF_INET)
               logprintf (LOG_VERBOSE, _("Connecting to %s:%d... "), txt_addr, port);
#ifdef ENABLE_IPV6
           else if (ip->family == AF_INET6)
               logprintf (LOG_VERBOSE, _("Connecting to [%s]:%d... "), txt_addr, port);
#endif
       }
    }

  /* Store the sockaddr info to SA.  */
  sockaddr_set_data (sa, ip, port);

printf("The socket function reached!\n");
  /* Create the socket of the family appropriate for the address.  */
  sock = socket (sa->sa_family, SOCK_STREAM, 0);
  if (sock < 0)
    goto err;

#if defined(ENABLE_IPV6) && defined(IPV6_V6ONLY)
  if (opt.ipv6_only) {
    int on = 1;
    /* In case of error, we will go on anyway... */
    int err = setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof (on));
    IF_DEBUG
      if (err < 0)
        DEBUGP (("Failed setting IPV6_V6ONLY: %s", strerror (errno)));
  }
/* Function to set the disassembly window's content.
   Disassemble count lines starting at pc.
   Return address of the count'th instruction after pc.  */
static CORE_ADDR
tui_disassemble (struct tui_asm_line* asm_lines, CORE_ADDR pc, int count)
{
  struct ui_file *gdb_dis_out;

  /* now init the ui_file structure */
  gdb_dis_out = tui_sfileopen (256);

  /* Now construct each line */
  for (; count > 0; count--, asm_lines++)
    {
      if (asm_lines->addr_string)
        xfree (asm_lines->addr_string);
      if (asm_lines->insn)
        xfree (asm_lines->insn);
      
      print_address (pc, gdb_dis_out);
      asm_lines->addr = pc;
      asm_lines->addr_string = xstrdup (tui_file_get_strbuf (gdb_dis_out));

      ui_file_rewind (gdb_dis_out);

      pc = pc + gdb_print_insn (pc, gdb_dis_out);

      asm_lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out));

      /* reset the buffer to empty */
      ui_file_rewind (gdb_dis_out);
    }
  ui_file_delete (gdb_dis_out);
  return pc;
}
Beispiel #16
0
static int format_addr(msp430_amode_t amode, uint16_t addr)
{
	char name[64];
	int numeric = 0;
	const char *prefix = "";

	switch (amode) {
	case MSP430_AMODE_REGISTER:
	case MSP430_AMODE_INDIRECT:
	case MSP430_AMODE_INDIRECT_INC:
		return 0;

	case MSP430_AMODE_IMMEDIATE:
		prefix = "#";
	case MSP430_AMODE_INDEXED:
		numeric = 1;
		break;

	case MSP430_AMODE_ABSOLUTE:
		prefix = "&";
		break;

	case MSP430_AMODE_SYMBOLIC:
		break;
	}

	print_address(addr, name, sizeof(name));
	return printc("%s\x1b[1m%s\x1b[0m", prefix, name);
}
Beispiel #17
0
uint32_t ble_central_bondmngr_init(ble_central_bondmngr_t * p_bm, ble_central_bondmngr_init_t * p_bm_init)
{
    uint32_t err_code;
    
    p_bm->p_sec_params = p_bm_init->p_sec_params;
    
    bond_info.keyset.keys_periph.p_enc_key = &bond_info.enc_key;
    
    if (p_bm_init->delete_bonds)
    {
        err_code = ble_flash_page_erase(BLE_CENTRAL_BONDMNGR_PAGE_NUM);
        if (err_code != NRF_SUCCESS)
            return err_code;
    }
    else
    {
        uint8_t size_to_read = sizeof(bond_info)/sizeof(uint32_t);
        err_code = ble_flash_page_read(BLE_CENTRAL_BONDMNGR_PAGE_NUM, (uint32_t *) &bond_info, &size_to_read);
        if (err_code != NRF_ERROR_NOT_FOUND && err_code != NRF_SUCCESS)
            return err_code;

        printf("Restoring data from %d, %d...\r\n", BLE_CENTRAL_BONDMNGR_PAGE_NUM, BLE_CENTRAL_BONDMNGR_PAGE_NUM*NRF_FICR->CODEPAGESIZE);
    }
    
    print_address(&bond_info.addr);
    
    return NRF_SUCCESS;
}
Beispiel #18
0
static int format_addr(msp430_amode_t amode, address_t addr)
{
	char name[MAX_SYMBOL_LENGTH];
	const char *prefix = "";

	switch (amode) {
	case MSP430_AMODE_REGISTER:
	case MSP430_AMODE_INDIRECT:
	case MSP430_AMODE_INDIRECT_INC:
		return 0;

	case MSP430_AMODE_IMMEDIATE:
		prefix = "#";
	case MSP430_AMODE_INDEXED:
		break;

	case MSP430_AMODE_ABSOLUTE:
		prefix = "&";
		break;

	case MSP430_AMODE_SYMBOLIC:
		break;
	}

	print_address(addr, name, sizeof(name), PRINT_ADDRESS_EXACT);
	return printc("%s\x1b[1m%s\x1b[0m", prefix, name);
}
/* uses default "hd" style, i.e. 16 bytes followed by ASCII */
static void hexdump_line(FILE *out, uint64_t address, unsigned char *buf) {
	int i;
	static char tbl[16] = "0123456789ABCDEF";

	fprintf(out,"  ");
	print_address(out, address);
	fprintf(out," ");

	/* hex */
	for (i = 0; i < 16; i++) {
		fprintf(out, "%c%c",
			tbl[(unsigned char)buf[i]>> 4],
			tbl[(unsigned char)buf[i] & 0x0f]);
		fprintf(out," ");
		if (i == 7)
			fprintf(out," ");
	}

	fprintf(out," ");

	/* ascii */
	for (i = 0; i < 16; i++) {
		if (isprint(buf[i])) {
			fprintf(out, "%c", buf[i]);
		} else {
			fprintf(out, ".");
		}
	}
	fprintf(out, "\n");
}
Beispiel #20
0
static void
print_ranges_property (struct hw *me,
		       const struct hw_property *property,
		       struct printer *p)
{
  int range_nr;
  range_property_spec range;
  for (range_nr = 0;
       hw_find_range_array_property (me, property->name, range_nr, &range);
       range_nr++)
    {
      print_address (me, &range.child_address, p);
      print_address (hw_parent (me), &range.parent_address, p);
      print_size (me, &range.size, p);
    }
}
	bool dos_blocker::incoming(address const& addr, time_point const now, dht_logger* logger)
	{
		TORRENT_UNUSED(logger);
		node_ban_entry* match = nullptr;
		node_ban_entry* min = m_ban_nodes;
		for (node_ban_entry* i = m_ban_nodes; i < m_ban_nodes + num_ban_nodes; ++i)
		{
			if (i->src == addr)
			{
				match = i;
				break;
			}
			if (i->count < min->count) min = i;
			else if (i->count == min->count
				&& i->limit < min->limit) min = i;
		}

		if (match)
		{
			++match->count;

			if (match->count >= m_message_rate_limit * 10)
			{
				if (now < match->limit)
				{
					if (match->count == m_message_rate_limit * 10)
					{
#ifndef TORRENT_DISABLE_LOGGING
						if (logger != nullptr && logger->should_log(dht_logger::tracker))
						{
							logger->log(dht_logger::tracker, "BANNING PEER [ ip: %s time: %d ms count: %d ]"
								, print_address(addr).c_str()
								, int(total_milliseconds((now - match->limit) + seconds(10)))
								, match->count);
						}
#else
						TORRENT_UNUSED(logger);
#endif // TORRENT_DISABLE_LOGGING
						// we've received too many messages in less than 10 seconds
						// from this node. Ignore it until it's silent for 5 minutes
						match->limit = now + seconds(m_block_timeout);
					}

					return false;
				}

				// the messages we received from this peer took more than 10
				// seconds. Reset the counter and the timer
				match->count = 0;
				match->limit = now + seconds(10);
			}
		}
		else
		{
			min->count = 1;
			min->limit = now + seconds(10);
			min->src = addr;
		}
		return true;
	}
int main() 
{
    int Num = 5;
    printf("%p\n", &Num);
    print_address(Num);
    
    return 0;
}
Beispiel #23
0
static void
gdbscm_disasm_print_address (bfd_vma addr, struct disassemble_info *info)
{
  struct gdbscm_disasm_data *data
    = (struct gdbscm_disasm_data *) info->application_data;
  struct gdbarch *gdbarch = data->gdbarch;

  print_address (gdbarch, addr, (struct ui_file *) info->stream);
}
Beispiel #24
0
static void print_an_address (void)
{
  struct address_s address;

  address.street = "1823 23rd Ave NE";
  address.city = "Seattle";
  address.region = "WA";
  address.postal_code = "98023";
  print_address (&address);
}
Beispiel #25
0
static void
print_simm_not_reg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
		    void * dis_info,
		    long value,
		    unsigned int attrs ATTRIBUTE_UNUSED,
		    bfd_vma pc ATTRIBUTE_UNUSED,
		    int length ATTRIBUTE_UNUSED)
{
  print_address (cd, dis_info, value, attrs, pc, length);
}
void	print_address(int nb, int sz)
{
    if (sz == 0)
        return ;
    else
    {
        print_address(nb / 16, sz - 1);
        ft_puthexa(nb % 16);
    }
}
static void test_wlan_address(int argc, char **argv)
{
	struct wlan_network network;

	if (wlan_get_current_network(&network)) {
		wmprintf("not connected\r\n");
		return;
	}
	print_address(&network.address);
}
Beispiel #28
0
static void	memory_report_invalid_addr(const void* addr)
{
    ADDRESS64   address;

    address.Mode    = AddrModeFlat;
    address.Segment = 0;
    address.Offset  = (unsigned long)addr;
    dbg_printf("*** Invalid address ");
    print_address(&address, FALSE);
    dbg_printf("\n");
}
Beispiel #29
0
    /** This is called by Gap to notify the application we connected */
    virtual void onConnectionComplete(const ble::ConnectionCompleteEvent &event)
    {
        printf("Connected to peer: ");
        print_address(event.getPeerAddress().data());
        printf("Peer random resolvable address: ");
        print_address(event.getPeerResolvablePrivateAddress().data());

        _handle = event.getConnectionHandle();

        if (_bonded) {
            /* disconnect in 2s */
            _event_queue.call_in(
                2000,
                &_ble.gap(),
                disconnect_call,
                _handle,
                ble::local_disconnection_reason_t(ble::local_disconnection_reason_t::USER_TERMINATION)
            );
        }
    };
Beispiel #30
0
print_reg_property(device *me,
		   const device_property *property)
{
  int reg_nr;
  reg_property_spec reg;
  for (reg_nr = 0;
       device_find_reg_array_property(me, property->name, reg_nr, &reg);
       reg_nr++) {
    print_address(device_parent(me), &reg.address);
    print_size(me, &reg.size);
  }
}