// ------------------------------------------------------------ void Qaullib_UserTouchIp(union olsr_ip_addr *ip, float linkcost) { struct qaul_user_LL_item *user; if(QAUL_DEBUG) printf("Qaullib_UserTouchIp \n"); // check if user exists in LL if(Qaullib_User_LL_IpSearch (ip, &user)) { if(QAUL_DEBUG) printf("user exists \n"); // if user exists: update lastseen_at if(user->changed >= QAUL_USERCHANGED_DELETED) { if(user->type == QAUL_USERTYPE_KNOWN) user->changed = QAUL_USERCHANGED_MODIFIED; else user->changed = QAUL_USERCHANGED_UNCHANGED; } // set link cost if(linkcost > 20.0) { // delete this user if(user->changed < QAUL_USERCHANGED_DELETED) user->changed = QAUL_USERCHANGED_DELETED; } else { if( user->changed >= QAUL_USERCHANGED_DELETED && linkcost <= 10.0) { user->changed = QAUL_USERCHANGED_MODIFIED; } else if(Qaullib_UserLinkcost2Img(user->lq) != Qaullib_UserLinkcost2Img(linkcost)) { user->changed = QAUL_USERCHANGED_MODIFIED; } } user->lq = linkcost; // set last seen time stamp user->time = time(NULL); } else { if(QAUL_DEBUG) printf("user does not exist, create it \n"); // if user does not exist: create user user = Qaullib_User_LL_Add (ip); user->lq = linkcost; } }
// ------------------------------------------------------------ void Qaullib_User_LL_IpTouch (union olsr_ip_addr *ip, float linkcost) { struct qaul_user_LL_node mynode; struct qaul_user_LL_item *new_item; Qaullib_User_LL_InitNodeWithIP(&mynode, ip); int ip_exists; ip_exists = 0; while(Qaullib_User_LL_NextItem(&mynode)) { if(memcmp(&mynode.item->ip, ip, qaul_ip_size) == 0) { // check if it is a real user if(mynode.item->type != QAUL_USERTYPE_WEB_KNOWN) { ip_exists = 1; mynode.item->time = time(NULL); // if user exists: update lastseen_at if(mynode.item->changed >= QAUL_USERCHANGED_DELETED) { if(mynode.item->type == QAUL_USERTYPE_KNOWN) mynode.item->changed = QAUL_USERCHANGED_MODIFIED; else mynode.item->changed = QAUL_USERCHANGED_UNCHANGED; } // set link cost if(linkcost > 20.0) { // delete this user if(mynode.item->changed < QAUL_USERCHANGED_DELETED) mynode.item->changed = QAUL_USERCHANGED_DELETED; } else { if( mynode.item->changed >= QAUL_USERCHANGED_DELETED && linkcost <= 10.0) { mynode.item->changed = QAUL_USERCHANGED_MODIFIED; } else if(Qaullib_UserLinkcost2Img(mynode.item->lq) != Qaullib_UserLinkcost2Img(linkcost)) { mynode.item->changed = QAUL_USERCHANGED_MODIFIED; } } } // update link cost mynode.item->lq = linkcost; } } // create new entry if none exists if(ip_exists == 0) { new_item = Qaullib_User_LL_Add (ip, 0); new_item->lq = linkcost; } return; }