lldp-tlv.c revision a7f7d1bde43fc825c49afea3f946f5b4b3d563e0
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 Tom Gundersen
Copyright (C) 2014 Susant Sahani
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <net/ethernet.h>
#include "macro.h"
#include "lldp-tlv.h"
tlv_section *s;
if (!s)
return -ENOMEM;
*ret = s;
return 0;
}
void tlv_section_free(tlv_section *m) {
if (!m)
return;
free(m);
}
tlv_packet *m;
if (!m)
return -ENOMEM;
LIST_HEAD_INIT(m->sections);
*ret = m;
return 0;
}
void tlv_packet_free(tlv_packet *m) {
tlv_section *s, *n;
if (!m)
return;
tlv_section_free(s);
free(m);
}
uint8_t *p;
assert_return(m, -EINVAL);
return -ENOMEM;
m->length += data_length;
return 0;
}
assert_return(m, -EINVAL);
}
assert_return(m, -EINVAL);
}
assert_return(m, -EINVAL);
}
assert_return(m, -EINVAL);
}
assert_return(m, -EINVAL);
}
int lldp_tlv_packet_close_container(tlv_packet *m) {
assert_return(m, -EINVAL);
return 0;
}
return 0;
}
int r;
assert_return(m, -EINVAL);
if (r < 0)
return r;
return 0;
}
uint16_t t;
int r;
assert_return(m, -EINVAL);
if (r < 0)
return r;
return 0;
}
uint32_t t;
void *val;
int r;
assert_return(m, -EINVAL);
if (r < 0)
return r;
return r;
}
int r;
assert_return(m, -EINVAL);
if (r < 0)
return r;
return 0;
}
int r;
assert_return(m, -EINVAL);
if (r < 0)
return r;
return 0;
}
/* parse raw TLV packet */
uint16_t t, l;
uint8_t *p;
int r;
assert_return(m, -EINVAL);
p = m->pdu;
/* extract ethernet herader */
p += sizeof(struct ether_header);
for (l = 0; l <= size; ) {
r = tlv_section_new(§ion);
if (r < 0)
return r;
break;
}
p += 2;
}
return 0;
}
tlv_section *s;
assert_return(m, -EINVAL);
break;
if (!s)
return -1;
m->container = s;
m->container = 0;
return -1;
}
return 0;
}
int lldp_tlv_packet_exit_container(tlv_packet *m) {
assert_return(m, -EINVAL);
m->container = 0;
return 0;
}