34 const struct pcap_pkthdr*,
const char *, gpointer selfptr);
47 g_source_unref(self->source);
48 g_source_destroy(self->source);
52 g_free(self->switchid);
53 self->switchid = NULL;
61 self->finalize(&self->baseclass.baseclass);
84 const struct pcap_pkthdr* pkthdr,
85 const char * capturedev,
95 (void)gsource; (void)capstruct;
98 ++
self->baseclass.discovercount;
102 ++
self->baseclass.reportcount;
117 , GMainContext* mcontext
125 g_return_val_if_fail(dret != NULL, NULL);
146 static struct _SwitchDiscoveryType {
147 const char * discoverytype;
148 gboolean (*isthistype)(gconstpointer tlv_vp, gconstpointer pktend);
149 gconstpointer (*get_switch_id)(gconstpointer tlv_vp, gssize* idlength, gconstpointer pktend);
150 gconstpointer (*get_port_id)(gconstpointer tlv_vp, gssize* idlength, gconstpointer pktend);
151 } discovery_types[] = {
161 gconstpointer pktend)
166 for (j=0; j <
DIMOF(discovery_types); ++j) {
167 gconstpointer curswitchid;
168 gssize curswitchidlen = -1;
169 gconstpointer curportid;
170 gssize curportidlen = -1;
172 if (!discovery_types[j].isthistype(pkt, pktend)) {
176 curswitchid = discovery_types[j].get_switch_id(pkt, &curswitchidlen, pktend);
177 curportid = discovery_types[j].get_port_id(pkt, &curportidlen, pktend);
178 g_return_val_if_fail(curswitchid != NULL, FALSE);
179 g_return_val_if_fail(curportid != NULL, FALSE);
181 if (self->switchid == NULL || self->portid == NULL
182 || curportidlen != self->portidlen || curswitchidlen != self->switchidlen
183 || memcmp(curswitchid, self->switchid, curswitchidlen) != 0
184 || memcmp(curportid, self->portid, curportidlen) != 0) {
186 if (self->switchid != NULL) {
187 FREE(self->switchid);
self->switchid = NULL;
189 if (self->portid != NULL) {
190 FREE(self->portid);
self->portid = NULL;
192 self->switchid = g_memdup(curswitchid, curswitchidlen);
193 self->portid = g_memdup(curportid, curportidlen);
194 self->switchidlen = curswitchidlen;
195 self->portidlen = curportidlen;