#include #include #include #include #include #include #include #include #include #include #include #include #include #include "p4emu_hdr.h" #include "utils.h" #include "p4raw1.h" int getState(int port) { #include "p4raw2.h" } int main(int argc, char **argv) { dataPorts = 0; for (int i = 4; i < argc; i++) { initIface(dataPorts, argv[i]); dataPorts++; } if (dataPorts < 2) err("using: dp [ifcN]"); if (dataPorts > maxPorts) dataPorts = maxPorts; if (initTables() != 0) err("error initializing tables"); int port = atoi(argv[2]); struct sockaddr_in addr; memset(&addr, 0, sizeof (addr)); if (inet_aton(argv[1], &addr.sin_addr) == 0) err("bad addr address"); addr.sin_family = AF_INET; addr.sin_port = htons(port); printf("connecting %s %i.\n", inet_ntoa(addr.sin_addr), port); commandSock = socket(AF_INET, SOCK_STREAM, 0); if (commandSock < 0) err("unable to open socket"); if (connect(commandSock, (struct sockaddr*)&addr, sizeof(addr)) < 0) err("failed to connect socket"); cpuPort = atoi(argv[3]); printf("cpu port is #%i of %i...\n", cpuPort, dataPorts); for (int o = 0; o < dataPorts; o++) { #include "p4raw3.h" } doNegotiate("raw"); #include "p4raw4.h" }