int mrp_unadvertise_stream(uint8_t * streamid, uint8_t * destaddr, u_int16_t vlan, int pktsz, int interval, int priority, int latency) { char *msgbuf; int rc; msgbuf = malloc(1500); if (NULL == msgbuf) return -1; memset(msgbuf, 0, 1500); sprintf(msgbuf, "S--:S=%02X%02X%02X%02X%02X%02X%02X%02X" ",A=%02X%02X%02X%02X%02X%02X" ",V=%04X" ",Z=%d" ",I=%d" ",P=%d" ",L=%d", streamid[0], streamid[1], streamid[2], streamid[3], streamid[4], streamid[5], streamid[6], streamid[7], destaddr[0], destaddr[1], destaddr[2], destaddr[3], destaddr[4], destaddr[5], vlan, pktsz, interval, priority << 5, latency); mrp_okay = 0; rc = send_mrp_msg(msgbuf, 1500); free(msgbuf); if (rc != 1500) return -1; else return 0; }
int mrp_get_domain(int *class_a_id, int *a_priority, u_int16_t * a_vid, int *class_b_id, int *b_priority, u_int16_t * b_vid) { char *msgbuf; /* we may not get a notification if we are joining late, * so query for what is already there ... */ msgbuf = malloc(64); if (NULL == msgbuf) return -1; memset(msgbuf, 0, 64); sprintf(msgbuf, "S??"); send_mrp_msg(msgbuf, 64); free(msgbuf); while (!halt_tx && (domain_a_valid == 0) && (domain_b_valid == 0)) usleep(20000); *class_a_id = 0; *a_priority = 0; *a_vid = 0; *class_b_id = 0; *b_priority = 0; *b_vid = 0; if (domain_a_valid) { *class_a_id = domain_class_a_id; *a_priority = domain_class_a_priority; *a_vid = domain_class_a_vid; } if (domain_b_valid) { *class_b_id = domain_class_b_id; *b_priority = domain_class_b_priority; *b_vid = domain_class_b_vid; } return (0); }
int mrp_register_domain(int *class_id, int *priority, u_int16_t * vid) { char *msgbuf; int rc; msgbuf = malloc(64); if (NULL == msgbuf) return -1; memset(msgbuf, 0, 64); sprintf(msgbuf, "S+D:C=%d,P=%d,V=%04x", *class_id, *priority, *vid); mrp_okay = 0; rc = send_mrp_msg(msgbuf, 1500); /* rc = recv_mrp_okay(); */ free(msgbuf); return rc; }
int mrp_disconnect() { char *msgbuf; int rc; msgbuf = malloc(64); if (NULL == msgbuf) return -1; memset(msgbuf, 0, 64); sprintf(msgbuf, "BYE"); mrp_okay = 0; rc = send_mrp_msg(msgbuf, 1500); /* rc = recv_mrp_okay(); */ free(msgbuf); return rc; }
int mrp_await_listener(unsigned char *streamid) { char *msgbuf; memcpy(monitor_stream_id, streamid, sizeof(monitor_stream_id)); msgbuf = malloc(64); if (NULL == msgbuf) return -1; memset(msgbuf, 0, 64); sprintf(msgbuf, "S??"); send_mrp_msg(msgbuf, 64); free(msgbuf); /* either already there ... or need to wait ... */ while (!halt_tx && (listeners == 0)) usleep(20000); return (0); }
int mrp_join_vlan() { char *msgbuf; int rc; msgbuf = malloc(1500); if (NULL == msgbuf) return -1; memset(msgbuf, 0, 1500); sprintf(msgbuf, "V++:I=0002"); rc = send_mrp_msg(msgbuf, 1500); free(msgbuf); if (rc != 1500) return -1; else return 0; }
int mrp_join_listener(uint8_t * streamid) { char *msgbuf; int rc; msgbuf = malloc(1500); if (NULL == msgbuf) return -1; memset(msgbuf, 0, 1500); sprintf(msgbuf, "S+L:S=%02X%02X%02X%02X%02X%02X%02X%02X" ",D=2", streamid[0], streamid[1], streamid[2], streamid[3], streamid[4], streamid[5], streamid[6], streamid[7]); mrp_okay = 0; rc = send_mrp_msg(msgbuf, 1500); /* rc = recv_mrp_okay(); */ free(msgbuf); return rc; }
int mrp_disconnect(void) { char *msgbuf; int rc; msgbuf = malloc(1500); if (NULL == msgbuf) return -1; memset(msgbuf, 0, 64); sprintf(msgbuf, "BYE"); mrp_okay = 0; rc = send_mrp_msg(msgbuf, 1500); free(msgbuf); if (rc != 1500) return -1; else return 0; }
int mrp_register_domain(int *class_id, int *priority, u_int16_t * vid) { char *msgbuf; int rc; msgbuf = malloc(1500); if (NULL == msgbuf) return -1; memset(msgbuf, 0, 1500); sprintf(msgbuf, "S+D:C=%d,P=%d,V=%04x", *class_id, *priority, *vid); mrp_okay = 0; rc = send_mrp_msg(msgbuf, 1500); free(msgbuf); if (rc != 1500) return -1; else return 0; }