Revision 7186100b net_helper-ml.c

View differences:

net_helper-ml.c
172 172
	p = (msgData_cb *)arg;
173 173
	if (p == NULL) return;
174 174
	send_params params = {0,0,0,0};
175
	send_Data(connectionID,(char *)(sendingBuffer[p->bIdx]),p->mSize,p->msgType,&params);
175
	mlSendData(connectionID,(char *)(sendingBuffer[p->bIdx]),p->mSize,p->msgType,&params);
176 176
	free(sendingBuffer[p->bIdx]);
177 177
	sendingBuffer[p->bIdx] = NULL;
178 178
//	fprintf(stderr,"Net-helper: Message # %d for connection %d sent!\n ", p->bIdx,connectionID);
......
211 211
//	fprintf(stderr, "Net-helper : called back with some news...\n");
212 212
	char str[SOCKETID_STRING_SIZE];
213 213
	if (arg->remote_socketID != NULL)
214
		socketID_To_String(arg->remote_socketID,str,SOCKETID_STRING_SIZE);
214
		mlSocketIDToString(arg->remote_socketID,str,SOCKETID_STRING_SIZE);
215 215
	else
216 216
		sprintf(str,"!Unknown!");
217 217
	if (arg->nrMissingBytes || !arg->firstPacketArrived) {
......
290 290
		receivedBuffer[i][0] = NULL;
291 291
	}
292 292

  
293
	register_Error_connection_cb(&connError_cb);
294
	register_Recv_connection_cb(&receive_conn_cb);
295
	init_messaging_layer(1,tout,port,IPaddr,0,NULL,&init_myNodeID_cb,base);
293
	mlRegisterErrorConnectionCb(&connError_cb);
294
	mlRegisterRecvConnectionCb(&receive_conn_cb);
295
	mlInit(1,tout,port,IPaddr,0,NULL,&init_myNodeID_cb,base);
296 296
	while (me->connID<-1) {
297 297
	//	event_base_once(base,-1, EV_TIMEOUT, &t_out_cb, NULL, &tout);
298 298
		event_base_loop(base,EVLOOP_ONCE);
......
306 306

  
307 307
void bind_msg_type (unsigned char msgtype) {
308 308

  
309
			register_Recv_data_cb(&recv_data_cb,msgtype);
309
			mlRegisterRecvDataCb(&recv_data_cb,msgtype);
310 310
}
311 311

  
312 312

  
......
333 333
	msgData_cb *p = malloc(sizeof(msgData_cb));
334 334
	p->bIdx = index; p->mSize = buffer_size; p->msgType = (unsigned char)buffer_ptr[0];
335 335
	int current = p->bIdx;
336
	to->connID = open_Connection(to->addr,&connReady_cb,p);
336
	to->connID = mlOpenConnection(to->addr,&connReady_cb,p);
337 337
	if (to->connID<0) {
338 338
		free(sendingBuffer[current]);
339 339
		sendingBuffer[current] = NULL;
......
416 416
//	remote->addrSize = SOCKETID_SIZE;
417 417
//	remote->addrStringSize = SOCKETID_STRING_SIZE;
418 418
	remote->addr = getRemoteSocketID(rem_IP, rem_port);
419
	remote->connID = open_Connection(remote->addr,&connReady_cb,NULL);
419
	remote->connID = mlOpenConnection(remote->addr,&connReady_cb,NULL);
420 420
	remote->refcnt = 1;
421 421
	return remote;
422 422
}
......
424 424
// TODO: check why closing the connection is annoying for the ML
425 425
void nodeid_free(struct nodeID *n) {
426 426

  
427
//	close_Connection(n->connID);
428
//	close_Socket(n->addr);
427
//	mlCloseConnection(n->connID);
428
//	mlCloseSocket(n->addr);
429 429
//	free(n);
430 430
	if (n && (--(n->refcnt) == 0)) {
431
	//	close_Connection(n->connID);
432
		close_Socket(n->addr);
431
	//	mlCloseConnection(n->connID);
432
		mlCloseSocket(n->addr);
433 433
		free(n);
434 434
	}
435 435
}
......
438 438
const char *node_addr(const struct nodeID *s)
439 439
{
440 440
  static char addr[256];
441
  // TODO: socketID_To_String always return 0 !!!
442
  int r = socketID_To_String(s->addr,addr,256);
441
  // TODO: mlSocketIDToString always return 0 !!!
442
  int r = mlSocketIDToString(s->addr,addr,256);
443 443
  if (!r)
444 444
	  return addr;
445 445
  else
......
472 472

  
473 473
int nodeid_equal(const struct nodeID *s1, const struct nodeID *s2)
474 474
{
475
	return (compare_socketIDs(s1->addr,s2->addr) == 0);
475
	return (mlCompareSocketIDs(s1->addr,s2->addr) == 0);
476 476
}
477 477

  
478 478
int nodeid_dump(uint8_t *b, const struct nodeID *s)
479 479
{
480
  socketID_To_String(s->addr,(char *)b,SOCKETID_STRING_SIZE);
480
  mlSocketIDToString(s->addr,(char *)b,SOCKETID_STRING_SIZE);
481 481
  //fprintf(stderr,"Dumping nodeID : ho scritto %s (%d bytes)\n",b, strlen((char *)b));
482 482

  
483 483
//	memcpy(b, s->addr,SOCKETID_SIZE);//sizeof(struct sockaddr_in6)*2
......
498 498
		  //memcpy(res->addr, b, SOCKETID_SIZE);
499 499
		  //*len = SOCKETID_SIZE;
500 500
		  *len = strlen((char*)b) + 1;
501
		  string_To_SocketID((char *)b,res->addr);
501
		  mlStringToSocketID((char *)b,res->addr);
502 502
	//	  fprintf(stderr,"Node undumped : %s\n",node_addr(res));
503 503
	//	  res->addrSize = SOCKETID_SIZE;
504 504
	//	  res->addrStringSize = SOCKETID_STRING_SIZE;

Also available in: Unified diff