Ejemplo n.º 1
0
static int send_JOIN_PLACE(struct mwPlace *place) {
  struct mwOpaque o = {0, 0};
  struct mwPutBuffer *b;
  int ret;

  b = mwPutBuffer_new();
  gboolean_put(b, FALSE);
  guint16_put(b, 0x01);
  guint16_put(b, 0x02); /* 0x01 */
  guint16_put(b, 0x01); /* 0x00 */

  mwPutBuffer_finalize(&o, b);

  ret = mwChannel_send(place->channel, msg_out_JOIN_PLACE, &o);

  mwOpaque_clear(&o);

  if(ret) {
    place_state(place, mwPlace_ERROR);
  } else {
    place_state(place, mwPlace_JOINING);
  }

  return ret;
}
Ejemplo n.º 2
0
static void enc_offer_put(struct mwPutBuffer *b, struct mwEncryptOffer *enc) {
  guint16_put(b, enc->mode);

  if(enc->items) {
    guint32 count;
    struct mwPutBuffer *p;
    struct mwOpaque o;
    GList *list;

    /* write the count, items, extra, and flag into a tmp buffer,
       render that buffer into an opaque, and write it into b */

    count = g_list_length(enc->items);
    p = mwPutBuffer_new();

    guint32_put(p, count);
    for(list = enc->items; list; list = list->next) {
      mwEncryptItem_put(p, list->data);
    }

    guint16_put(p, enc->extra);
    gboolean_put(p, enc->flag);

    mwPutBuffer_finalize(&o, p);
    mwOpaque_put(b, &o);
    mwOpaque_clear(&o);
  }
}
Ejemplo n.º 3
0
static void mwMessageHead_put(struct mwPutBuffer *b, struct mwMessage *msg) {
  guint16_put(b, msg->type);
  guint16_put(b, msg->options);
  guint32_put(b, msg->channel);
  
  if(msg->options & mwMessageOption_HAS_ATTRIBS)
    mwOpaque_put(b, &msg->attribs);
}
Ejemplo n.º 4
0
static void LOGIN_put(struct mwPutBuffer *b, struct mwMsgLogin *msg) {
  guint16_put(b, msg->login_type);
  mwString_put(b, msg->name);

  /* ordering reversed from houri draft?? */
  mwOpaque_put(b, &msg->auth_data);
  guint16_put(b, msg->auth_type);

  guint16_put(b, 0x0000); /* unknown */
}
Ejemplo n.º 5
0
static void HANDSHAKE_ACK_put(struct mwPutBuffer *b,
			      struct mwMsgHandshakeAck *msg) {

  guint16_put(b, msg->major);
  guint16_put(b, msg->minor);
  guint32_put(b, msg->srvrcalc_addr);

  if(msg->major >= 0x1e && msg->minor > 0x18) {
    guint32_put(b, msg->magic);
    mwOpaque_put(b, &msg->data);
  }
}
Ejemplo n.º 6
0
static void HANDSHAKE_put(struct mwPutBuffer *b, struct mwMsgHandshake *msg) {
  guint16_put(b, msg->major);
  guint16_put(b, msg->minor);
  guint32_put(b, msg->head.channel);
  guint32_put(b, msg->srvrcalc_addr);
  guint16_put(b, msg->login_type);
  guint32_put(b, msg->loclcalc_addr);
  
  if(msg->major >= 0x001e && msg->minor >= 0x001d) {
    guint16_put(b, msg->unknown_a);
    guint32_put(b, msg->unknown_b);
    mwString_put(b, msg->local_host);
  }
}
Ejemplo n.º 7
0
int mwDirectory_search(struct mwDirectory *dir, const char *query) {
  struct mwServiceDirectory *srvc;
  struct mwChannel *chan;
  struct mwPutBuffer *b;
  struct mwOpaque o;
  int ret;

  g_return_val_if_fail(dir != NULL, -1);
  g_return_val_if_fail(MW_DIRECTORY_IS_OPEN(dir), -1);
  g_return_val_if_fail(query != NULL, -1);
  g_return_val_if_fail(*query != '\0', -1);

  srvc = dir->service;
  g_return_val_if_fail(srvc != NULL, -1);

  chan = srvc->channel;
  g_return_val_if_fail(chan != NULL, -1);

  b = mwPutBuffer_new();
  guint32_put(b, map_request(dir));
  guint32_put(b, dir->id);
  guint16_put(b, 0x0061);      /* some magic? */
  guint32_put(b, 0x00000008);  /* seek results */
  mwString_put(b, query);

  mwPutBuffer_finalize(&o, b);
  ret = mwChannel_send(chan, action_search, &o);
  mwOpaque_clear(&o);

  return ret;
}
Ejemplo n.º 8
0
static int dir_open(struct mwDirectory *dir) {
  struct mwServiceDirectory *srvc;
  struct mwChannel *chan;
  struct mwPutBuffer *b;
  struct mwOpaque o;
  int ret;

  g_return_val_if_fail(dir != NULL, -1);

  srvc = dir->service;
  g_return_val_if_fail(srvc != NULL, -1);

  chan = srvc->channel;
  g_return_val_if_fail(chan != NULL, -1);

  b = mwPutBuffer_new();
  guint32_put(b, map_request(dir));

  /* unsure about these three bytes */
  gboolean_put(b, FALSE);
  guint16_put(b, 0x0000);

  guint32_put(b, dir->book->id);
  mwString_put(b, dir->book->name);

  mwPutBuffer_finalize(&o, b);
  ret = mwChannel_send(chan, action_open, &o);
  mwOpaque_clear(&o);

  return ret;
}
Ejemplo n.º 9
0
int mwConference_invite(struct mwConference *conf,
			struct mwIdBlock *who,
			const char *text) {

  struct mwPutBuffer *b;
  struct mwOpaque o;
  int ret;

  g_return_val_if_fail(conf != NULL, -1);
  g_return_val_if_fail(conf->channel != NULL, -1);
  g_return_val_if_fail(who != NULL, -1);

  b = mwPutBuffer_new();

  mwIdBlock_put(b, who);
  guint16_put(b, 0x00);
  guint32_put(b, 0x00);
  mwString_put(b, text);
  mwString_put(b, who->user);

  mwPutBuffer_finalize(&o, b);
  ret = mwChannel_sendEncrypted(conf->channel, msg_INVITE, &o, FALSE);
  mwOpaque_clear(&o);

  return ret;
}
Ejemplo n.º 10
0
static int send_SECTION_LIST(struct mwPlace *place, guint32 section) {
  int ret = 0;
  struct mwOpaque o = {0, 0};
  struct mwPutBuffer *b;

  b = mwPutBuffer_new();
  guint16_put(b, msg_out_SECTION_LIST);
  guint32_put(b, section);
  gboolean_put(b, FALSE);
  guint32_put(b, ++place->requests);
  mwPutBuffer_finalize(&o, b);

  ret = mwChannel_send(place->channel, msg_out_SECTION, &o);
  mwOpaque_clear(&o);

  return ret;
}
Ejemplo n.º 11
0
static void ft_create_chan(struct mwFileTransfer *ft) {
  struct mwSession *s;
  struct mwChannelSet *cs;
  struct mwChannel *chan;
  struct mwLoginInfo *login;
  struct mwPutBuffer *b;
  
  /* we only should be calling this if there isn't a channel already
     associated with the conversation */
  g_return_if_fail(ft != NULL);
  g_return_if_fail(mwFileTransfer_isNew(ft));
  g_return_if_fail(ft->channel == NULL);
		   
  s = mwService_getSession(MW_SERVICE(ft->service));
  cs = mwSession_getChannels(s);

  chan = mwChannel_newOutgoing(cs);
  mwChannel_setService(chan, MW_SERVICE(ft->service));
  mwChannel_setProtoType(chan, PROTOCOL_TYPE);
  mwChannel_setProtoVer(chan, PROTOCOL_VER);

  /* offer all known ciphers */
  mwChannel_populateSupportedCipherInstances(chan);

  /* set the target */
  login = mwChannel_getUser(chan);
  login->user_id = g_strdup(ft->who.user);
  login->community = g_strdup(ft->who.community);

  /* compose the addtl create */
  b = mwPutBuffer_new();
  guint32_put(b, 0x00);
  mwString_put(b, ft->filename);
  mwString_put(b, ft->message);
  guint32_put(b, ft->size);
  guint32_put(b, 0x00);
  guint16_put(b, 0x00);

  mwPutBuffer_finalize(mwChannel_getAddtlCreate(chan), b);

  ft->channel = mwChannel_create(chan)? NULL: chan;
  if(ft->channel) {
    mwChannel_setServiceData(ft->channel, ft, NULL);
  }
}
Ejemplo n.º 12
0
static void CHANNEL_CREATE_put(struct mwPutBuffer *b,
			       struct mwMsgChannelCreate *msg) {

  guint32_put(b, msg->reserved);
  guint32_put(b, msg->channel);
  mwIdBlock_put(b, &msg->target);
  guint32_put(b, msg->service);
  guint32_put(b, msg->proto_type);
  guint32_put(b, msg->proto_ver);
  guint32_put(b, msg->options);
  mwOpaque_put(b, &msg->addtl);
  gboolean_put(b, msg->creator_flag);

  if(msg->creator_flag)
    mwLoginInfo_put(b, &msg->creator);

  enc_offer_put(b, &msg->encrypt);

  guint32_put(b, 0x00);
  guint32_put(b, 0x00);
  guint16_put(b, 0x07);
}