5 #include <nsdp/protocol.h>
11 int ngadmin_getStormFilterState (struct ngadmin *nga, int *s)
18 if (nga == NULL || s == NULL)
20 else if (nga->current == NULL)
24 attr = createEmptyList();
25 pushBackList(attr, newEmptyAttr(ATTR_STORM_ENABLE));
26 ret = readRequest(nga, attr);
30 filterAttributes(attr, ATTR_STORM_ENABLE, ATTR_END);
34 if (attr->first == NULL) {
38 at = attr->first->data;
43 *s = *(char*)at->data;
47 destroyList(attr, (void(*)(void*))freeAttr);
54 int ngadmin_setStormFilterState (struct ngadmin *nga, int s)
59 attr = createEmptyList();
60 pushBackList(attr, newByteAttr(ATTR_STORM_ENABLE, s != 0));
63 return writeRequest(nga, attr);
67 int ngadmin_getStormFilterValues (struct ngadmin *nga, int *ports)
72 int ret = ERR_OK, port;
73 struct attr_bitrate *sb;
77 if (nga == NULL || ports == NULL)
85 attr = createEmptyList();
86 pushBackList(attr, newEmptyAttr(ATTR_STORM_BITRATE));
87 ret = readRequest(nga, attr);
91 filterAttributes(attr, ATTR_STORM_BITRATE, ATTR_END);
93 for (port = 0; port < sa->ports; port++)
94 ports[port] = BITRATE_UNSPEC;
96 for (ln = attr->first; ln != NULL; ln = ln->next) {
103 if (sb->port <= sa->ports)
104 ports[sb->port - 1] = sb->bitrate;
109 destroyList(attr, (void(*)(void*))freeAttr);
116 int ngadmin_setStormFilterValues (struct ngadmin *nga, const int *ports)
120 struct attr_bitrate *sb;
123 if (nga == NULL || ports == NULL)
125 else if (nga->current == NULL)
129 attr = createEmptyList();
131 for (port = 0; port < nga->current->ports; port++) {
132 if (ports[port] != BITRATE_UNSPEC) {
133 sb = malloc(sizeof(struct attr_bitrate));
137 sb->bitrate = ports[port];
138 pushBackList(attr, newAttr(ATTR_STORM_BITRATE, sizeof(struct attr_bitrate), sb));
142 return writeRequest(nga, attr);
146 int ngadmin_getBitrateLimits (struct ngadmin *nga, int *ports)
151 int ret = ERR_OK, port;
152 struct attr_bitrate *pb;
156 if (nga == NULL || ports == NULL)
164 attr = createEmptyList();
165 pushBackList(attr, newEmptyAttr(ATTR_BITRATE_INPUT));
166 pushBackList(attr, newEmptyAttr(ATTR_BITRATE_OUTPUT));
167 ret = readRequest(nga, attr);
171 filterAttributes(attr, ATTR_BITRATE_INPUT, ATTR_BITRATE_OUTPUT, ATTR_END);
173 for (port = 0; port < sa->ports; port++) {
174 ports[2 * port + 0] = BITRATE_UNSPEC;
175 ports[2 * port + 1] = BITRATE_UNSPEC;
178 for (ln = attr->first; ln != NULL; ln = ln->next) {
185 if (pb->port > sa->ports)
187 else if (at->attr == ATTR_BITRATE_INPUT)
188 ports[(pb->port - 1) * 2 + 0] = pb->bitrate;
190 ports[(pb->port - 1) * 2 + 1] = pb->bitrate;
195 destroyList(attr, (void(*)(void*))freeAttr);
201 int ngadmin_setBitrateLimits (struct ngadmin *nga, const int *ports)
205 struct attr_bitrate *pb;
208 if (nga == NULL || ports == NULL)
210 else if (nga->current == NULL)
214 attr = createEmptyList();
216 for (port = 0; port < nga->current->ports; port++) {
217 if (ports[2 * port + 0] >= BITRATE_NOLIMIT && ports[2 * port + 0] <= BITRATE_512M) {
218 pb = malloc(sizeof(struct attr_bitrate));
222 pb->bitrate = ports[2 * port + 0];
223 pushBackList(attr, newAttr(ATTR_BITRATE_INPUT, sizeof(struct attr_bitrate), pb));
225 if (ports[2 * port + 1] >= BITRATE_NOLIMIT && ports[2 * port + 1] <= BITRATE_512M) {
226 pb = malloc(sizeof(struct attr_bitrate));
230 pb->bitrate = ports[2 * port + 1];
231 pushBackList(attr, newAttr(ATTR_BITRATE_OUTPUT, sizeof(struct attr_bitrate), pb));
236 return writeRequest(nga, attr);