Exemplo n.º 1
0
/**
 * Forces closure of all open channels
 */
static void disconnect_all_channels()
{
	channel_object *chan;

	while (channels()->first) {
		chan = channels()->first->element;
		disconnect_channel(chan->handle, 0);
	}

	llist_destroy(channels(), NULL);
	_channels = NULL; 
}
Exemplo n.º 2
0
/**
 * Disconnect HealthDevice signals
 */
static gboolean disconnect_device_signals(const char *device_path)
{
	channel_object *c;
	DBusGProxy *proxy = get_device(device_path);
	gboolean dirty;

	if (!device_path)
		return FALSE;

	dbus_g_proxy_disconnect_signal(proxy, "ChannelConnected",
				       G_CALLBACK(channel_connected),
				       NULL);

	dbus_g_proxy_disconnect_signal(proxy, "ChannelDeleted",
				       G_CALLBACK(channel_deleted),
				       NULL);

	DEBUG("Disconnected device %s", device_path);

	// Disconnect channels related to this device
	do {
		dirty = FALSE;
		LinkedNode *i = channels()->first;

		while (i) {
			c = i->element;
		
			if (strcmp(c->device, device_path) == 0) {
				disconnect_channel(c->handle, 0);
				dirty = TRUE;
				break;
			}
			i = i->next;
		}
        
	} while (dirty);

	remove_device(device_path);

	return TRUE;
}
Exemplo n.º 3
0
/**
 * Takes care of channel closure, when initiative is remote
 */
static void channel_closed(const char *path)
{
	channel_object *c = get_channel(path);
	device_object *d;

	if (!c)
		return;

	d = get_device_object(c->device);

	if (c->first) {
		// notifies higher layers
		if (d) {
			device_disconnected(c->handle, d->addr);
		} else {
			ERROR("Unknown device: %s", c->device);
			device_disconnected(c->handle, c->device);
		}
	}

	disconnect_channel(c->handle, 1);
}
Exemplo n.º 4
0
/**
 * Forces closure of a channel -- called by higher layer
 */
static int force_disconnect_channel(Context *c)
{
	return disconnect_channel(c->id.connid, 0);
}
Exemplo n.º 5
0
//,b8 ,2a ,00 ,00 ,00 ,c3
int main()
{
   u64 magic_number;
   octen_message message;

   program_channel = create_channel(program_channel_name, 0x4000, 0x4000, 30000);
   if(!read_channel(program_channel, &magic_number, sizeof(u64)))
      error("Client disconnected!\n");
   if(magic_number != 0x3e3e6b6f3c3c2000)
      error("Program didn't give the magic number!\n");
   if(!write_channel(program_channel, &magic_number, sizeof(u64)))
      error("Client disconnected!\n");

   compile_buffer = allocate(0, 0x1000, PAGE_RWX);

   void *program_function;
   message = create_message(0x1000, CMD_ALOC);
   if(!write_channel(program_channel, &message, sizeof(octen_message)))
      error("Client disconnected!\n");
   if(!read_channel(program_channel, &program_function, sizeof(void*)))
      error("Client disconnected!\n");

   while(true)
   {
      char input_buffer[256];
      printf("* ");
#ifdef OS_WINDOWS
      fflush(stdin);
#else
      __fpurge(stdin);
#endif
      scanf("%255[^\n]", input_buffer);

      if(strcmp("quit", input_buffer)==0)
         break;

      if(strcmp("call", input_buffer)==0 && program_function)
      {
         message = create_message(0, CMD_CALL);
         if(!write_channel(program_channel, &message, sizeof(octen_message)))
            error("Client disconnected!\n");
         if(!write_channel(program_channel, &program_function, sizeof(void*)))
            error("Client disconnected!\n");
         u64 result;
         if(!read_channel(program_channel, &result, sizeof(u64)))
            error("Client disconnected!\n");
         printf("%u\n", (u32)result);
         continue;
      }

      eval_string(input_buffer, compile_buffer);
      message = create_message(0x1000, CMD_SET_EXEC);
      if(!write_channel(program_channel, &message, sizeof(octen_message)))
         error("Client disconnected!\n");
      if(!write_channel(program_channel, &program_function, sizeof(void*)))
         error("Client disconnected!\n");
      if(!write_channel(program_channel, compile_buffer, 0x1000))
         error("Client disconnected!\n");
      if(!read_channel(program_channel, &message, sizeof(octen_message)))
         error("Client disconnected!\n");
   }

   disconnect_channel(program_channel);
   return 0;
}