static int
register_service (struct HardwareInfos *dev)
{
- // advertise the service
+ /* advertise the service */
CSADDR_INFO addr_info;
WSAQUERYSET wqs;
GUID guid;
wqs.lpServiceClassId = &guid;
wqs.dwNumberOfCsAddrs = 1;
wqs.lpcsaBuffer = &addr_info ;
- wqs.lpBlob = 0; //FIXME it should be 0 for a new entry
+ wqs.lpBlob = 0;
if (SOCKET_ERROR == WSASetService (&wqs , RNRSERVICE_REGISTER, 0))
{
{
case WSAEFAULT:
free (wqs);
- //fprintf (stderr, "WSAFAULT error! (the memory allocated wasn't enought\n");
wqs = (WSAQUERYSET*)malloc (wqs_len);
break;
case WSANO_DATA:
break;
case WSA_E_NO_MORE:
done = 1;
- // fprintf (stderr, "No matching service found\n");
break;
default:
fprintf (stderr, "Failed to look over the services: ");
{
fprintf (stderr, "Failed to connect to the SDP server on interface `%.*s': %s\n",
IFNAMSIZ, dev->iface, strerror (errno));
- //FIXME exit?
return -1;
}
for (it = response_list; it; it = it->next)
{
sdp_record_t *record = (sdp_record_t*) it->data;
- //TODO print some record informations to be sure everything is good
sdp_list_t *proto_list = 0;
if (sdp_get_access_protos (record, &proto_list) == 0)
{
}
#ifdef LINUX
- /* Get the channel used */ //FIXME probably not needed anymore
+ /* Get the channel used */
int len;
struct sockaddr_rc rc_addr = { 0 };
#ifdef MINGW
SOCKADDR_BTH addr;
- /* bind the hci socket to the interface */
+ /* bind the RFCOMM socket to the interface */
addr.addressFamily = AF_BTH;
addr.btAddr = 0;
addr.port = BT_PORT_ANY;
- //FIXME flags parameter
if (GNUNET_NETWORK_socket_bind (dev->handle, (const SOCKADDR*)&addr, sizeof (SOCKADDR_BTH), 0) != GNUNET_OK)
{
fprintf (stderr, "Failed to bind the socket: ");
if (-1 == dev.fd_rfcomm)
{
- fprintf (stderr, "Failed to create a HCI socket: %s\n", strerror (raw_eno));
+ fprintf (stderr, "Failed to create a RFCOMM socket: %s\n", strerror (raw_eno));
return 1;
}
if (dev.fd_rfcomm >= FD_SETSIZE)
stdin_mst = mst_create (&stdin_send_hw, &dev);
stdin_open = 1;
- fprintf (stderr, "\n-----------------------------------------------\n Check if the program exits\n-----------------------------------------------\n");
/**
- * TODO : When a connection fails I should ignore only the CONTROL messages.
- * For DATA messages I should retry to send the message until it doesn't fail
- * Also I should make the time out of a mac endpoint smaller and check if the rate
+ * TODO : I should make the time out of a mac endpoint smaller and check if the rate
* from get_wlan_header (plugin_transport_bluetooth.c) is correct.
*/
while (1)
sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)
{
fprintf (stderr, "LOG : %s has a broadcast message (pos %d, size %d)\n", dev.iface, neighbours.pos, neighbours.size); //FIXME: debugging message
- // broadcast = 1; // IF I HAVE A BROADCAST MESSAGE I skip.
- // memset (&write_pout, 0, sizeof (write_pout));
if (send_broadcast(&dev, &sendsocket) != 0) //if the searching wasn't successful don't get stuck on the select stage
{
broadcast = 1;
memset (&write_pout, 0, sizeof (write_pout)); //remove the message
- fprintf (stderr, "LOG : Skip the broadcast message (pos %d, size %d)\n", neighbours.pos, neighbours.size);
+ fprintf (stderr, "LOG : Skipping the broadcast message (pos %d, size %d)\n", neighbours.pos, neighbours.size);
}
else
{
read (i, readbuf, sizeof (readbuf));
if (0 > ret)
{
- fprintf (stderr, "Read error from STDIN: %s\n", strerror (errno));
- break; break;
+ fprintf (stderr,
+ "Read error from STDIN: %s\n",
+ strerror (errno));
+ break;
}
if (0 == ret)
{
stdin_mst = mst_create (&stdin_send_hw, &dev);
stdin_open = 1;
-
- fprintf (stderr, "\n-----------------------------------------------\n Check if the program exits\n-----------------------------------------------\n");
int pos = 0;
int stdin_pos = -1;
pos = 0;
stdin_pos = -1;
stdout_pos = -1;
- sendsocket = NULL; //FIXME memleaks
- fprintf (stderr, "---------------------------------------------------\n");
+ sendsocket = NULL; //FIXME ???memleaks
GNUNET_NETWORK_fdset_zero (rfds);
if ((0 == write_pout.size) && (1 == stdin_open))
{
stdin_pos = pos;
pos +=1;
- fprintf (stderr, "LOG: set STDIN_FILENO\n");
- GNUNET_NETWORK_fdset_handle_set (rfds, (struct GNUNET_DISK_FileHandle*) &stdin_handle); //FIXME create a GNUNET_STRUCT handle for stdin
+ GNUNET_NETWORK_fdset_handle_set (rfds, (struct GNUNET_DISK_FileHandle*) &stdin_handle);
}
if (0 == write_std.size)
{
pos += 1;
- fprintf (stderr, "LOG: set the listening socket %d\n", GNUNET_NETWORK_get_fd (dev.handle));
GNUNET_NETWORK_fdset_set (rfds, dev.handle);
}
for (i = 0; i < crt_rfds; i++)
{
pos += 1;
- fprintf (stderr, "LOG: adding %d read socket\n", i);
GNUNET_NETWORK_fdset_set (rfds, rfds_list[i]);
}
if (0 < write_std.size)
{
stdout_pos = pos;
- fprintf (stderr, "LOG: set STDOUT_FILENO\n");
GNUNET_NETWORK_fdset_handle_set (wfds, (struct GNUNET_DISK_FileHandle*) &stdout_handle);
- fprintf (stderr, "LOG: after setting STDOUT_FILENO\n");
// printf ("%s\n", write_std.buf);
// memset (write_std.buf, 0, write_std.size);
// write_std.size = 0;
if (0 < write_pout.size)
{
if (strcmp (argv[1], "ff:ff:ff:ff:ff:ff") == 0) {
- fprintf(stderr, "BROADCAST\n");
+ fprintf(stderr, "LOG: BROADCAST! Skipping the message\n");
// skip the message
broadcast = 1;
memset (write_pout.buf, 0, write_pout.size);
print_last_error();
ExitProcess ( 2 ) ;
}
- addr.port = get_channel (argv[1]); //crapa aici
+ addr.port = get_channel (argv[1]);
if (addr.port == -1)
{
fprintf (stderr, "Couldn't find the sdp service for the address: %s\n", argv[1]);
}
else
{
- fprintf (stderr, "got the channel %d\n", addr.port);
-
if (GNUNET_OK != GNUNET_NETWORK_socket_connect (sendsocket, (LPSOCKADDR)&addr, addr_len))
{
fprintf (stderr, "Failed to connect: ");
if (broadcast == 0)
{
- fprintf (stderr, "before select\n");
int retval = GNUNET_NETWORK_socket_select (rfds, wfds, NULL, GNUNET_TIME_relative_get_forever_());
- fprintf (stderr, "after select %d\n", retval);
if (retval < 0)
{
- fprintf (stderr, "select error\n");
+ fprintf (stderr, "Select error\n");
ExitProcess (2);
}
//if (GNUNET_NETWORK_fdset_isset (wfds, (struct GNUNET_NETWORK_Handle*)&stdout_handle))
if (retval == stdout_pos)
{
- fprintf (stderr, "-------------STDOUT------------\n");
fprintf(stderr, "LOG : sends a message to STDOUT\n"); //FIXME: debugging message
//ssize_t ret;
//ret = GNUNET_NETWORK_socket_send ((struct GNUNET_NETWORK_Handle *)&stdout_handle, write_std.buf + write_std.pos, write_std.size - write_std.pos);
print_last_error();
break;
}
- fprintf (stderr, "--->sended: %d\n", ret);
- Sleep(5000);
+
if (ret <= 0)
{
fprintf (stderr, "Failed to write to STDOUT\n");
{
if (GNUNET_NETWORK_fdset_isset (wfds, sendsocket))
{
- fprintf (stderr, "-------------SEND------------\n");
ssize_t ret;
ret = GNUNET_NETWORK_socket_send (sendsocket, write_pout.buf + write_pout.pos,
write_pout.size - write_pout.pos);
print_last_error();
}
ExitProcess (2);
- //break;
}
else
{
}
//if (GNUNET_NETWORK_fdset_isset (rfds, (struct GNUNET_NETWORK_Handle*)&stdin_handle))
- if (retval == stdin_pos) //FALSEEE!!!! NUUUUU EEE VOOIEE!!_----------------------------------------------------------?
+ if (retval == stdin_pos)
{
- fprintf (stderr, "-------------STDIN------------\n");
//ssize_t ret;
//ret = GNUNET_NETWORK_socket_recv ((struct GNUNET_NETWORK_Handle *)&stdin_handle, readbuf, sizeof (write_pout.buf));
//ret = read (STDIN_FILENO, readbuf, sizeof (readbuf));
else
if (GNUNET_NETWORK_fdset_isset (rfds, dev.handle))
{
- fprintf (stderr, "-------------ACCEPT------------\n");
fprintf (stderr, "LOG: accepting connection\n");
struct GNUNET_NETWORK_Handle *readsocket;
readsocket = GNUNET_NETWORK_socket_accept (dev.handle, (LPSOCKADDR)&acc_addr, &addr_len);
- sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)
+ sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame),
rrm);
- fprintf (stderr, "MESSAGE: %s\n", readbuf);
if (0 >= ret)
{
WSACleanup();
#endif
return 1; /* we never exit 'normally' */
-}
\ No newline at end of file
+}