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;
70 if (nga == NULL || ports == NULL)
72 else if (nga->current == NULL)
76 attr = createEmptyList();
77 pushBackList(attr, newEmptyAttr(ATTR_STORM_BITRATE));
78 ret = readRequest(nga, attr);
82 filterAttributes(attr, ATTR_STORM_BITRATE, ATTR_END);
84 for (port = 0; port < nga->current->ports; port++)
85 ports[port] = BITRATE_UNSPEC;
87 for (ln = attr->first; ln != NULL; ln = ln->next) {
90 ports[sb->port - 1] = sb->bitrate;
95 destroyList(attr, (void(*)(void*))freeAttr);
102 int ngadmin_setStormFilterValues (struct ngadmin *nga, const int *ports)
106 struct attr_bitrate *sb;
109 if (nga == NULL || ports == NULL)
111 else if (nga->current == NULL)
115 attr = createEmptyList();
117 for (port = 0; port < nga->current->ports; port++) {
118 if (ports[port] != BITRATE_UNSPEC) {
119 sb = malloc(sizeof(struct attr_bitrate));
123 sb->bitrate = ports[port];
124 pushBackList(attr, newAttr(ATTR_STORM_BITRATE, sizeof(struct attr_bitrate), sb));
128 return writeRequest(nga, attr);
132 int ngadmin_getBitrateLimits (struct ngadmin *nga, int *ports)
137 int ret = ERR_OK, port;
138 struct attr_bitrate *pb;
141 if (nga == NULL || ports == NULL)
143 else if (nga->current == NULL)
147 attr = createEmptyList();
148 pushBackList(attr, newEmptyAttr(ATTR_BITRATE_INPUT));
149 pushBackList(attr, newEmptyAttr(ATTR_BITRATE_OUTPUT));
150 ret = readRequest(nga, attr);
155 for (port = 0; port < nga->current->ports; port++) {
156 ports[2 * port + 0] = BITRATE_UNSPEC;
157 ports[2 * port + 1] = BITRATE_UNSPEC;
160 for (ln = attr->first; ln != NULL; ln = ln->next) {
163 if (at->attr == ATTR_BITRATE_INPUT)
164 ports[(pb->port - 1) * 2 + 0] = pb->bitrate;
165 else if (at->attr == ATTR_BITRATE_OUTPUT)
166 ports[(pb->port - 1) * 2 + 1] = pb->bitrate;
171 destroyList(attr, (void(*)(void*))freeAttr);
177 int ngadmin_setBitrateLimits (struct ngadmin *nga, const int *ports)
181 struct attr_bitrate *pb;
184 if (nga == NULL || ports == NULL)
186 else if (nga->current == NULL)
190 attr = createEmptyList();
192 for (port = 0; port < nga->current->ports; port++) {
193 if (ports[2 * port + 0] >= BITRATE_NOLIMIT && ports[2 * port + 0] <= BITRATE_512M) {
194 pb = malloc(sizeof(struct attr_bitrate));
198 pb->bitrate = ports[2 * port + 0];
199 pushBackList(attr, newAttr(ATTR_BITRATE_INPUT, sizeof(struct attr_bitrate), pb));
201 if (ports[2 * port + 1] >= BITRATE_NOLIMIT && ports[2 * port + 1] <= BITRATE_512M) {
202 pb = malloc(sizeof(struct attr_bitrate));
206 pb->bitrate = ports[2 * port + 1];
207 pushBackList(attr, newAttr(ATTR_BITRATE_OUTPUT, sizeof(struct attr_bitrate), pb));
212 return writeRequest(nga, attr);