44 #define DIMOF(a) (sizeof(a)/sizeof(a[0]))
60 guint8 address[] = {127, 0, 0, 1};
61 gchar fred[] =
"fred";
62 gchar george[] =
"george";
63 char stackprotectionstuff[8];
71 stackprotectionstuff[0] =
'\0';
72 (void)stackprotectionstuff;
74 g_message(
"Performing c-class cast tests");
95 f->
setvalue(f, fred, strlen(fred), NULL);
111 g_message(
"finalizing the FrameSet (and presumably frames)");
114 g_message(
"C-class cast tests complete! - please check the output for errors.");
122 const guint8 addr_ipv4_other[4] = {10, 10, 10, 5};
124 const guint8 addr_ipv46_localhost[16] = {0,0,0,0,0,0,0,0,0,0,0xff,0xff,127,0,0,1};
125 const guint8 addr_macaddr48 [6]= {0x00, 0x1b, 0xfc, 0x1b, 0xa8, 0x73};
126 const guint8 addr_macaddr64 [8]= {0x00, 0x1b, 0xfc, 0x1b, 0xa8, 0x73, 0x42, 0x42};
127 const guint8 addr_ipv6_other[16] = {0xfe, 0x80, 0,0,0,0,0,0, 0x2, 0x1b, 0xfc, 0xff, 0xfe, 0x1b, 0xa8, 0x73};
142 AddrFrame* gframes[] = {ipv4_localhost, ipv6_localhost, ipv46_localhost, macaddr48, macaddr64, ipv6_other, ipv4_other};
143 AddrFrame* bframes[] = {bframeipv4_1, bframeipv4_2, bframeipv6_1, bframeipv6_2, bframemac_1, bframemac_2, bframemac_3};
150 g_message(
"Starting Known Good AddressFrame tests.");
151 for (j=0; j <
DIMOF(gframes); ++j) {
156 g_critical(
"OOPS Good AddressFrame %d is NOT valid!", j);
174 g_message(
"Starting Known Bad AddressFrame tests.");
175 for (j=0; j <
DIMOF(bframes); ++j) {
178 g_critical(
"Bad AddressFrame %d SHOULD NOT BE valid!", j);
185 g_message(
"End of AddressFrame tests.");
191 #define PCAP "../pcap/"
197 char errbuf[PCAP_ERRBUF_SIZE];
198 struct pcap_pkthdr hdr;
199 const guchar* packet;
201 const char * lldpfilenames [] = {
PCAP "lldp.detailed.pcap",
PCAP "procurve.lldp.pcap", PCAP
"lldpmed_civicloc.pcap"};
202 const char * cdpfilenames [] = {
PCAP "cdp.pcap",
PCAP "n0.eth2.cdp.pcap"};
204 (void)argc; (void)argv;
206 g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR|G_LOG_LEVEL_CRITICAL);
211 for (j=0; j <
DIMOF(cdpfilenames); ++j) {
213 const char * filename = cdpfilenames[j];
215 if (NULL == (handle = pcap_open_offline(filename, errbuf))) {
216 g_error(
"open_offline failed.../: %s", errbuf);
219 while (NULL != (packet = pcap_next(handle, &hdr))) {
220 const guchar * pend = packet + hdr.caplen;
222 g_message(
"Found a %d/%d byte CDP packet!", hdr.caplen, hdr.len);
226 g_warning(
"ERROR: %d byte CDP packet %d in [%s] is NOT valid!\n",
227 (
int)(pend-packet), count, filename);
229 dump_mem(packet, packet+hdr.caplen);
236 for (j=0; j <
DIMOF(lldpfilenames); ++j) {
238 const char * filename = lldpfilenames[j];
239 if (NULL == (handle = pcap_open_offline(filename, errbuf))) {
240 g_error(
"open_offline failed.../: %s\n", errbuf);
242 while (NULL != (packet = pcap_next(handle, &hdr))) {
243 const guchar * pend = packet + hdr.caplen;
244 g_message(
"Found a %d/%d byte LLDP packet!\n", hdr.caplen, hdr.len);
246 dump_mem(packet, packet+hdr.caplen);