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) {
35 at = attr->first->data;
36 *s = *(char*)at->data;
41 destroyList(attr, (void(*)(void*))freeAttr);
48 int ngadmin_setStormFilterState (struct ngadmin *nga, int s)
53 attr = createEmptyList();
54 pushBackList(attr, newByteAttr(ATTR_STORM_ENABLE, s != 0));
57 return writeRequest(nga, attr);
61 int ngadmin_getStormFilterValues (struct ngadmin *nga, int *ports)
66 int ret = ERR_OK, port;
67 struct attr_bitrate *sb;
71 if (nga == NULL || ports == NULL)
79 attr = createEmptyList();
80 pushBackList(attr, newEmptyAttr(ATTR_STORM_BITRATE));
81 ret = readRequest(nga, attr);
85 filterAttributes(attr, ATTR_STORM_BITRATE, ATTR_END);
87 for (port = 0; port < sa->ports; port++)
88 ports[port] = BITRATE_UNSPEC;
90 for (ln = attr->first; ln != NULL; ln = ln->next) {
93 if (sb->port <= sa->ports)
94 ports[sb->port - 1] = sb->bitrate;
99 destroyList(attr, (void(*)(void*))freeAttr);
106 int ngadmin_setStormFilterValues (struct ngadmin *nga, const int *ports)
110 struct attr_bitrate *sb;
113 if (nga == NULL || ports == NULL)
115 else if (nga->current == NULL)
119 attr = createEmptyList();
121 for (port = 0; port < nga->current->ports; port++) {
122 if (ports[port] != BITRATE_UNSPEC) {
123 sb = malloc(sizeof(struct attr_bitrate));
127 sb->bitrate = ports[port];
128 pushBackList(attr, newAttr(ATTR_STORM_BITRATE, sizeof(struct attr_bitrate), sb));
132 return writeRequest(nga, attr);
136 int ngadmin_getBitrateLimits (struct ngadmin *nga, int *ports)
141 int ret = ERR_OK, port;
142 struct attr_bitrate *pb;
146 if (nga == NULL || ports == NULL)
154 attr = createEmptyList();
155 pushBackList(attr, newEmptyAttr(ATTR_BITRATE_INPUT));
156 pushBackList(attr, newEmptyAttr(ATTR_BITRATE_OUTPUT));
157 ret = readRequest(nga, attr);
161 filterAttributes(attr, ATTR_BITRATE_INPUT, ATTR_BITRATE_OUTPUT, ATTR_END);
163 for (port = 0; port < sa->ports; port++) {
164 ports[2 * port + 0] = BITRATE_UNSPEC;
165 ports[2 * port + 1] = BITRATE_UNSPEC;
168 for (ln = attr->first; ln != NULL; ln = ln->next) {
171 if (pb->port > sa->ports)
173 else if (at->attr == ATTR_BITRATE_INPUT)
174 ports[(pb->port - 1) * 2 + 0] = pb->bitrate;
176 ports[(pb->port - 1) * 2 + 1] = pb->bitrate;
181 destroyList(attr, (void(*)(void*))freeAttr);
187 int ngadmin_setBitrateLimits (struct ngadmin *nga, const int *ports)
191 struct attr_bitrate *pb;
194 if (nga == NULL || ports == NULL)
196 else if (nga->current == NULL)
200 attr = createEmptyList();
202 for (port = 0; port < nga->current->ports; port++) {
203 if (ports[2 * port + 0] >= BITRATE_NOLIMIT && ports[2 * port + 0] <= BITRATE_512M) {
204 pb = malloc(sizeof(struct attr_bitrate));
208 pb->bitrate = ports[2 * port + 0];
209 pushBackList(attr, newAttr(ATTR_BITRATE_INPUT, sizeof(struct attr_bitrate), pb));
211 if (ports[2 * port + 1] >= BITRATE_NOLIMIT && ports[2 * port + 1] <= BITRATE_512M) {
212 pb = malloc(sizeof(struct attr_bitrate));
216 pb->bitrate = ports[2 * port + 1];
217 pushBackList(attr, newAttr(ATTR_BITRATE_OUTPUT, sizeof(struct attr_bitrate), pb));
222 return writeRequest(nga, attr);