int on_switch(char * v, void *d) { __bool ok = __false; CArgs args; PCRTK_PACKET p = (PCRTK_PACKET)d; parse_arg_ex(v, &args, " "); if(args.argc >= 2){ if(!strcmpi(args.argv[1], "primary")){ ok = switch_to_primary(); }else if(!strcmpi(args.argv[1], "backup")){ ok = switch_to_backup(); } } send_rtk_data_with_guid( vbus_system, &p->src, &p->guid, ok ? PT_System : PT_System | PF_Failed | PF_ACK, 0, 0 ); return 0; }
static void RTK_API sr(PCRTK_PACKET p, HVBUS bus) { #if 0 { char name[128]; p->guid.to_string(name); DEBUG_PRINTF(( "Got packet, ID=%s:%d/%d/%d, Type:0x%08x, " "Src=%s:%d, Size=%d, Offset=%d\n", name, p->grp_id, p->frgmt_id, p->total_frag, p->packet_type, p->src.host.Data, p->src.port, p->data_size, p->offset )); } #endif send_rtk_data_with_guid( bus, &p->src, &p->guid, p->packet_type | PF_ACK, 0, 0 ); }
__bool Query( PCTAG_NAME name, PCTAG_VALUE value, __uint timeout ) { char heap[sizeof(TAG_NAME) + sizeof(TAG_VALUE)]; __uint heapsize; RTK_ADDR addr; heapsize = sizeof(*name) + sizeof(*value); memcpy(heap, name, sizeof(*name)); memcpy(heap + sizeof(*name), value, sizeof(*value)); node_to_host(&name->node, &addr.host); addr.port = PORT_ALL_SERVER; send_rtk_data_with_guid( vbus_operation, &addr, &Guid, PT_Operation, heap, heapsize ); return Wait(timeout); }
CDiscoverPictures(PCNODE_KEY node, __uint timeout) { RTK_ADDR dest; c_items = 0; add_transaction(vbus_config, this); node_to_host(node, &dest.host); dest.port = PORT_ALL_SERVER; send_rtk_data_with_guid( vbus_config, &dest, &Guid, PT_DiscoverPictures ); Wait(timeout); }
CAddDevice( PCNODE_KEY node, PCDEVICE_KEY key, PCVENDOR_KEY v, PCDEVTYPE_KEY t, const char * addr, const char * init_string, __uint timeout ) { RTK_ADDR dest; node_to_host(node, &dest.host); dest.port = PORT_ALL_SERVER; ok = false; __uint size; if(!init_string){ init_string = ""; } size = strlen(addr) + 1 + strlen(init_string) + 1 + sizeof(*v) + sizeof(*t) + sizeof(*key); void *buf; buf = alloc_buffer_v( key, sizeof(*key), v, sizeof(*v), t, sizeof(*t), addr, strlen(addr) + 1, init_string, strlen(init_string)+1, 0 ); if(!buf){ return; } add_transaction(vbus_config, this); send_rtk_data_with_guid( vbus_config, &dest, &Guid, PT_AddDevice, buf, size); free_buffer(buf); Wait(timeout); }
CDiscoverConfigFiles(PCNODE_KEY node, char * b, __uint s, __uint timeout) { RTK_ADDR dest; ok = false; bufsize = s; buf = b; *buf = '\0'; add_transaction(vbus_config, this); node_to_host(node, &dest.host); dest.port = PORT_ALL_SERVER; send_rtk_data_with_guid( vbus_config, &dest, &Guid, PT_DiscoverConfigFiles ); Wait(timeout); }
CBringupBackups(__uint timeout) { RTK_ADDR dest; char * msg = "switch primary"; dest.host = g_ThisNode->key; dest.port = PORT_ALL_SLAVE; m_bOk = false; m_bTimeout = true; add_transaction(vbus_system, this); send_rtk_data_with_guid( vbus_system, &dest, &Guid, PT_System, msg, strlen(msg) + 1 ); Wait(timeout); }
CDelDevice( PCNODE_KEY node, PCDEVICE_KEY key, __uint timeout ) { RTK_ADDR dest; node_to_host(node, &dest.host); dest.port = PORT_ALL_SERVER; ok = false; add_transaction(vbus_config, this); send_rtk_data_with_guid( vbus_config, &dest, &Guid, PT_DelDevice, key, sizeof(*key) ); Wait(timeout); }