Statistics
| Branch: | Revision:

pstreamer / src / peer_metadata.c @ 56d5986f

History | View | Annotate | Download (635 Bytes)

1
#include<peer_metadata.h>
2
#include<malloc.h>
3
#include<string.h>
4

    
5
int8_t metadata_update(struct metadata *m, uint16_t cb_size, uint8_t neigh_size)
6
{
7
        if (m)
8
        {
9
                m->cb_size = cb_size;
10
                m->neigh_size = neigh_size;
11
                return 0;
12
        }
13
        return -1;
14
}
15

    
16
int8_t peer_set_metadata(struct  peer *p, const struct metadata *m)
17
{
18
        if (p && m)
19
        {
20
                if (!(p->metadata))
21
                        p->metadata = malloc(sizeof(struct metadata));
22
                memmove(p->metadata, m, sizeof(struct metadata));
23
                return 0;
24
        }
25
        return -1;
26
}
27

    
28
uint16_t peer_cb_size(const struct peer *p)
29
{
30
        if (p && p->metadata)
31
                return ((struct metadata *)p->metadata)->cb_size;
32
        return DEFAULT_PEER_CBSIZE;
33
}