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; }