void avb_init(chanend media_ctl[], chanend listener_ctl[], chanend talker_ctl[], chanend media_clock_ctl, chanend c_mac_rx0, chanend c_mac_tx0, chanend c_ptp0) { #if AVB_OSC OSC_SET_RANGE(avb_source, 0, AVB_NUM_SOURCES-1); OSC_SET_RANGE(device_media_clock, 0, AVB_NUM_MEDIA_CLOCKS-1); OSC_SET_RANGE(avb_sink, 0, AVB_NUM_SINKS-1); OSC_SET_RANGE(media_in, 0, AVB_NUM_MEDIA_INPUTS-1); OSC_SET_RANGE(media_out, 0, AVB_NUM_MEDIA_OUTPUTS-1); #endif mac_get_macaddr(c_mac_tx0, mac_addr); mrp_init((char *)mac_addr); register_talkers(talker_ctl); register_listeners(listener_ctl); register_media(media_ctl); init_media_clock_server(media_clock_ctl); avb_1722_maap_init(mac_addr); #ifdef AVB_ENABLE_1722_1 { unsigned char serial_number[2] = { 0,1 }; avb_1722_1_init(mac_addr, serial_number); } #endif c_mac_rx = c_mac_rx0; c_mac_tx = c_mac_tx0; c_ptp = c_ptp0; domain_attr = mrp_get_attr(); mrp_attribute_init(domain_attr, MSRP_DOMAIN_VECTOR, NULL); #ifdef AVB_INCLUDE_MMRP avb_mmrp_init(); #endif #ifndef AVB_EXCLUDE_MVRP avb_mvrp_init(); #endif xc_abi_outuint(c_mac_tx, ETHERNET_TX_INIT_AVB_ROUTER); mac_set_custom_filter(c_mac_rx, MAC_FILTER_AVB_CONTROL); }
int mrpw_init_protocols(void) { uint16_t ether_types[4]; WSADATA wsa_data; int rc; mrpd_port = MRPD_PORT_DEFAULT; mmrp_enable = 1; mvrp_enable = 1; msrp_enable = 1; periodic_enable = 1; logging_enable = 1; WSAStartup(MAKEWORD(1, 1), &wsa_data); /* open our network interface and set the capture ethertype to MRP types */ net_if = netif_open(TIME_PERIOD_25_MILLISECONDS); // time out is 25ms if (!net_if) { fprintf(stderr, "ERROR - opening network interface\n"); return -1; } ether_types[0] = MVRP_ETYPE; ether_types[1] = MMRP_ETYPE; ether_types[2] = MSRP_ETYPE; if (netif_set_capture_ethertype(net_if, ether_types, 3)) { fprintf(stderr, "ERROR - setting netif capture ethertype\n"); return -1; } rc = mrp_init(); if (rc) goto out; rc = init_local_ctl(); if (rc) goto out; if (mmrp_enable) { rc = mmrp_init(mmrp_enable); if (rc) goto out; } if (mvrp_enable) { rc = mvrp_init(mvrp_enable); if (rc) goto out; } if (msrp_enable) { rc = msrp_init(msrp_enable); if (rc) goto out; } rc = init_timers(); if (rc) goto out; return 0; out: return -1; }
int main(int argc, char *argv[]) { uint16_t ether_types[4]; WSADATA wsa_data; int rc; mrpd_port = MRPD_PORT_DEFAULT; mmrp_enable = 1; mvrp_enable = 1; msrp_enable = 1; periodic_enable = 1; logging_enable = 1; WSAStartup(MAKEWORD(1, 1), &wsa_data); /* open our network interface and set the capture ethertype to MRP types */ net_if = netif_open(TIME_PERIOD_25_MILLISECONDS); // time out is 25ms if (!net_if) { fprintf(stderr, "ERROR - opening network interface\n"); exit(-1); } ether_types[0] = MVRP_ETYPE; ether_types[1] = MMRP_ETYPE; ether_types[2] = MSRP_ETYPE; if (netif_set_capture_ethertype(net_if, ether_types, 3)) { fprintf(stderr, "ERROR - setting netif capture ethertype\n"); exit(-1); } rc = mrp_init(); if (rc) goto out; rc = init_local_ctl(); if (rc) goto out; if (mmrp_enable) { rc = mmrp_init(mmrp_enable); if (rc) goto out; } if (mvrp_enable) { rc = mvrp_init(mvrp_enable); if (rc) goto out; } if (msrp_enable) { rc = msrp_init(msrp_enable); if (rc) goto out; } rc = init_timers(); if (rc) goto out; process_events(); out: if (rc) printf("Error starting. Run as sudo?\n"); WSACleanup(); return rc; }