Created
April 14, 2016 21:22
-
-
Save nl0x/7dd493a810c0254a0053633dd847bb8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void clientmgr_handle_info(clientmgr_ctx *ctx, struct l3ctx *l3ctx, struct client *foreign_client) { | |
| printf("Received client info\n"); | |
| print_client(foreign_client); | |
| struct client *client = clientmgr_get_client(ctx, foreign_client->mac); | |
| if (!client) { | |
| printf("Didn't know about this client yet.\n"); | |
| client = foreign_client; | |
| VECTOR_ADD(ctx->clients, *client); | |
| } else { | |
| printf("Merging clients\n"); | |
| print_client(client); | |
| for (int i = 0; i < VECTOR_LEN(foreign_client->addresses); i++) { | |
| struct client_ip *e = &VECTOR_INDEX(foreign_client->addresses, i); | |
| struct client_ip *ip = clientmgr_get_client_ip(foreign_client, &e->address); | |
| printf("ip %p e %p\n", ip, e); | |
| if (ip == NULL) { | |
| VECTOR_ADD(client->addresses, *e); | |
| } else if (e->lastseen.tv_nsec > ip->lastseen.tv_nsec) { | |
| ip->lastseen = e->lastseen; | |
| } | |
| } | |
| } | |
| printf("Now I know about this client:\n"); | |
| print_client(client); | |
| clientmgr_update_client_routes(l3ctx, ctx->export_table, client); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment