-wlan_plugin_address_pretty_printer (void *cls,
- const char *type,
- const void *addr,
- size_t addrlen,
- int numeric,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_TRANSPORT_AddressStringCallback
- asc, void *asc_cls)
-{
- char ret[92];
- const unsigned char * input;
-
- GNUNET_assert(cls !=NULL);
- if (addrlen != 6)
- {
- /* invalid address (MAC addresses have 6 bytes) */
- GNUNET_break (0);
- asc (asc_cls, NULL);
- return;
- }
- input = (const unsigned char*) addr;
- GNUNET_snprintf (ret,
- sizeof (ret),
- "%s Mac-Adress %X:%X:%X:%X:%X:%X",
- PROTOCOL_PREFIX,
- input[0], input[1], input[2], input[3], input[4], input[5]);
- asc (asc_cls, ret);
-}
-
-
-
-/**
- * Another peer has suggested an address for this
- * peer and transport plugin. Check that this could be a valid
- * address. If so, consider adding it to the list
- * of addresses.
- *
- * @param cls closure
- * @param addr pointer to the address
- * @param addrlen length of addr
- * @return GNUNET_OK if this is a plausible address for this peer
- * and transport
- */
-
-
-static int
-wlan_plugin_address_suggested (void *cls,
- const void *addr,
- size_t addrlen)
-{
- //struct Plugin *plugin = cls;
-
- /* check if the address is plausible; if so,
- add it to our list! */
-
- GNUNET_assert(cls !=NULL);
- //FIXME mitm is not checked
- //Mac Adress has 6 bytes
- if (addrlen == 6){
- /* TODO check for bad addresses like milticast, broadcast, etc */
- return GNUNET_OK;
- } else {
- return GNUNET_SYSERR;
- }
-
- return GNUNET_SYSERR;
-}
-
-
-/**
- * Function called for a quick conversion of the binary address to
- * a numeric address. Note that the caller must not free the
- * address and that the next call to this function is allowed
- * to override the address again.
- *
- * @param cls closure
- * @param addr binary address
- * @param addrlen length of the address
- * @return string representing the same address
- */
-static const char*
-wlan_plugin_address_to_string (void *cls,
- const void *addr,
- size_t addrlen)
-{
- char ret[92];
- const unsigned char * input;
-
- GNUNET_assert(cls !=NULL);
- if (addrlen != 6)
- {
- /* invalid address (MAC addresses have 6 bytes) */
- GNUNET_break (0);
- return NULL;
- }
- input = (const unsigned char*) addr;
- GNUNET_snprintf (ret,
- sizeof (ret),
- "%s Mac-Adress %X:%X:%X:%X:%X:%X",
- PROTOCOL_PREFIX,
- input[0], input[1], input[2], input[3], input[4], input[5]);
- return GNUNET_strdup (ret);
-}
-
-/**
- * Function to test if fragment number already exists in the fragments received
- *
- * @param session session the fragment belongs to
- * @param fh Fragmentheader of the fragment
- * @return GNUNET_YES if fragment exists already, GNUNET_NO if it does not exists in the queue of the session
- */
-
-static const int
-is_double_msg(struct Session * session, struct FragmentationHeader * fh)
-{
- struct RecQueue * rec_queue = session->frag_head;
- while (rec_queue != NULL)
- {
- if (rec_queue->num == fh->fragment_off_or_num)
- {
- return GNUNET_YES;
- }
- rec_queue = rec_queue->next;
-
- }
- return GNUNET_NO;
-}
-
-/**
- * Function to insert a fragment in a queue of a session
- * @param session session the fragment belongs to
- * @param rec_queue fragment to add
- */
-
-static void
-insert_fragment_in_queue(struct Session * session, struct RecQueue * rec_queue)
-{
- struct RecQueue * rec_queue2 = session->frag_head;
- struct WlanHeader * wlanheader = NULL;
- //first received fragment of message
- if (session->rec_size == NO_MESSAGE_OR_MESSAGE_FINISHED)
- {
- session->rec_size = MESSAGE_LENGHT_UNKNOWN;
- }
- //this is the first fragment of the message (fragment id 0)
- if (rec_queue->num == 0)
- {
- wlanheader = (struct WlanHeader *) rec_queue->msg;
- session->rec_size = wlanheader->header.size;
- }
-
- //sort into list
- while (rec_queue2 != NULL)
- {
- if (rec_queue2->num > rec_queue->num)
- {
- //next element number is grater than the current num
- GNUNET_CONTAINER_DLL_insert_before(session->frag_head, session->frag_tail, rec_queue2, rec_queue);
- return;
- }
- rec_queue = rec_queue->next;
- }
- //no element has a grater number
- GNUNET_CONTAINER_DLL_insert_tail(session->frag_head, session->frag_tail, rec_queue);
-}
-
-/**
- * Function to dispose the fragments received for a message
- * @param session session to free the fragments from
- */
-
-static void
-free_rec_frag_queue(struct Session * session)