//----------------------------------------------------------------------------- // read an incoming message from datalink to network layer void read_network(int link, size_t length, char * datagram) { DATAGRAM dtg; memcpy(&dtg, datagram, length); // dispatch the datagram if (is_kind(dtg.kind,__DISCOVER__)) do_discovery(link, dtg); if (is_kind(dtg.kind,__ROUTING__)) do_routing(link, dtg); if (is_kind(dtg.kind,__TRANSPORT__)) { PACKET pkt; size_t len_to_cpy = dtg.length; memcpy((char*)&pkt, dtg.payload, len_to_cpy); if ((CnetAddr)(dtg.dest) != nodeinfo.address) { route(dtg); packets_forwarded_total++; } else read_transport(dtg.kind, dtg.length, dtg.src, (char*)dtg.payload); } }
static int source_set_port_cb(pa_source *s, pa_device_port *p) { struct userdata *u = s->userdata; pa_droid_port_data *data; pa_assert(u); pa_assert(p); data = PA_DEVICE_PORT_DATA(p); if (!data->device) { /* If there is no device defined, just return 0 to say everything is ok. * Then next port change can be whatever source port, even the one enabled * before parking. */ pa_log_debug("Source set port to parking"); return 0; } pa_log_debug("Source set port %u", data->device); do_routing(u, data->device); return 0; }