Inital ...

FossilOrigin-Name: e6352b425bf6574bdaacc571723f7b54394e235d8b64bbaa504c9b7e529b7535
This commit is contained in:
7u83@mail.ru
2015-04-10 15:16:33 +00:00
parent c43f85b2a6
commit 5b51751453
10 changed files with 306 additions and 0 deletions

65
src/capwap/acpriolist.c Normal file
View File

@ -0,0 +1,65 @@
/*
This file is part of libcapwap.
libcapwap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libcapwap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "acpriolist.h"
static int acprio_cmp(const void *x1, const void *x2)
{
cw_acprio_t * p1 = (cw_acprio_t*)x1;
cw_acprio_t * p2 = (cw_acprio_t*)x2;
return strcmp (p1->name,p2->name);
}
static void acprio_del(void *d)
{
cw_acprio_t *p = (cw_acprio_t*)d;
if ( p->name )
free (p->name);
free(d);
}
cw_acpriolist_t cw_acpriolist_create()
{
return avltree_create(acprio_cmp, acprio_del);
}
cw_acprio_t * cw_acpriolist_add(cw_acpriolist_t l, const char *name,int name_len, uint8_t prio)
{
cw_acprio_t * s=malloc(sizeof(cw_acprio_t));
if (!s)
return 0;
s->name=strndup(name,name_len);
s->prio=prio;
cw_acpriolist_del(l,s);
return avltree_add(l,s);
}