FossilOrigin-Name: 43d113474056a9be642476fa1acc8f617a5d20aa7b8bae01e3561ced1747beedbsdmakefiles
parent
32ac896145
commit
5a71866fbd
@ -1,84 +0,0 @@ |
||||
/*
|
||||
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/>.
|
||||
|
||||
*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Implements some aciplist functions |
||||
*/ |
||||
|
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
|
||||
#include <netinet/in.h> |
||||
#include <arpa/inet.h> |
||||
|
||||
#include "aciplist.h" |
||||
#include "mavl.h" |
||||
#include "sock.h" |
||||
|
||||
|
||||
static int acip_cmp(const void *x1, const void *x2) |
||||
{ |
||||
struct cw_acip *ip1 = *((struct cw_acip **) x1); |
||||
struct cw_acip *ip2 = *((struct cw_acip **) x2); |
||||
|
||||
int r = ip1->index - ip2->index; |
||||
if (r!=0) |
||||
return r; |
||||
|
||||
|
||||
if (ip1->ip.ss_family != ip2->ip.ss_family) { |
||||
if (ip1->ip.ss_family == AF_INET) |
||||
return -1; |
||||
else |
||||
return 1; |
||||
} |
||||
|
||||
if (ip1->ip.ss_family == AF_INET) { |
||||
struct sockaddr_in *s2 = (struct sockaddr_in *) &ip2->ip; |
||||
struct sockaddr_in *s1 = (struct sockaddr_in *) &ip1->ip; |
||||
|
||||
return memcmp(&s1->sin_addr, &s2->sin_addr, |
||||
sock_addrlen((struct sockaddr *) s1)); |
||||
} |
||||
|
||||
if (ip1->ip.ss_family == AF_INET6) { |
||||
struct sockaddr_in6 *s2 = (struct sockaddr_in6 *) &ip2->ip; |
||||
struct sockaddr_in6 *s1 = (struct sockaddr_in6 *) &ip1->ip; |
||||
|
||||
return memcmp(&s1->sin6_addr.s6_addr, &s2->sin6_addr.s6_addr, |
||||
sock_addrlen((struct sockaddr *) s1)); |
||||
} |
||||
|
||||
return -1; |
||||
} |
||||
|
||||
static void acip_del(void *d) |
||||
{ |
||||
free(*(void**)d); |
||||
} |
||||
|
||||
/**
|
||||
* Create a cw_aciplist_t object |
||||
* @return The created aciplist or NULL if an error has occured. |
||||
*/ |
||||
cw_aciplist_t cw_aciplist_create() |
||||
{ |
||||
return mavl_create(acip_cmp, acip_del,1312); |
||||
} |
||||
|
@ -1,24 +0,0 @@ |
||||
#ifndef __ACIPLIST_H |
||||
#define __ACIPLIST_H |
||||
|
||||
#include "mavl.h" |
||||
|
||||
struct cw_acip{ |
||||
struct sockaddr_storage ip; |
||||
uint32_t index; |
||||
}; |
||||
|
||||
typedef struct cw_acip cw_acip_t; |
||||
|
||||
typedef struct mavl * cw_aciplist_t; |
||||
|
||||
extern cw_aciplist_t cw_aciplist_create(); |
||||
|
||||
#define cw_aciplist_destroy(l) mavl_destroy(l) |
||||
#define cw_aciplist_add(l,elem) mavl_add(l,elem,NULL) |
||||
#define cw_aciplist_del(l,elem) mavl_del(l,elem) |
||||
#define cw_aciplist_foreach(l,callback,cbpriv) mavl_foreach_asc(l,callback,cbpriv) |
||||
#define cw_aciplist_replace(l,r) mavl_replace(l,r,NULL) |
||||
|
||||
#endif |
||||
|
@ -1,85 +0,0 @@ |
||||
/*
|
||||
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); |
||||
// if ( p->addr )
|
||||
// free(p->addr);
|
||||
free(d); |
||||
} |
||||
|
||||
|
||||
const struct mbag_typedef mbag_type_acprio = { |
||||
"acprio",acprio_del |
||||
}; |
||||
|
||||
|
||||
|
||||
|
||||
cw_acpriolist_t cw_acpriolist_create() |
||||
{ |
||||
return mavl_create(acprio_cmp, acprio_del,4); |
||||
} |
||||
|
||||
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 mavl_add(l,s,NULL); |
||||
|
||||
} |
||||
|
||||
|
||||
int cw_acpriolist_get(cw_acpriolist_t l, char * acname){ |
||||
cw_acprio_t ps,*pf; |
||||
ps.name=acname; |
||||
|
||||
pf=mavl_get(l,&ps); |
||||
if (!pf) |
||||
return 256; |
||||
return pf->prio; |
||||
} |
||||
|
||||
*/ |
@ -1,44 +0,0 @@ |
||||
#ifndef __ACIPRIORITYLIST_H |
||||
#define __ACIPRIORITYLIST_H |
||||
|
||||
#include "mavl.h" |
||||
|
||||
|
||||
/**
|
||||
* Used to store AC Name With Priority elements. |
||||
*/ |
||||
struct cw_acprio{ |
||||
/**
|
||||
* AC Name |
||||
*/ |
||||
char *name; |
||||
/**
|
||||
* IP of AC |
||||
*/ |
||||
struct sockaddr_storage * addr; |
||||
/**
|
||||
* Priority |
||||
*/ |
||||
uint8_t prio; |
||||
}; |
||||
|
||||
extern const struct mbag_typedef mbag_type_acprio; |
||||
|
||||
#define MBAG_ACPRIO (&mbag_type_acprio) |
||||
|
||||
|
||||
|
||||
typedef struct cw_acprio cw_acprio_t; |
||||
typedef struct mavl * cw_acpriolist_t; |
||||
|
||||
extern cw_acpriolist_t cw_acpriolist_create(); |
||||
cw_acprio_t * cw_acpriolist_add(cw_acpriolist_t l, const char *name,int name_len, uint8_t prio); |
||||
|
||||
int cw_acpriolist_get(cw_acpriolist_t l, char * acname); |
||||
|
||||
|
||||
|
||||
#define cw_acpriolist_del(l,s) mavl_del(l,s) |
||||
#define cw_acpriolist_set(l,n,nl,p) cw_acpriolist_add(l,n,nl,p) |
||||
|
||||
#endif |
Loading…
Reference in new issue