#include "asterisk/lock.h"
#include "asterisk/srv.h"
-struct ast_ha {
- /* Host access rule */
- struct in_addr netaddr;
- struct in_addr netmask;
- int sense;
- struct ast_ha *next;
-};
-
struct my_ifreq {
char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "eth0", "ppp0", etc. */
struct sockaddr_in ifru_addr;
while (ha) {
hal = ha;
ha = ha->next;
- free(hal);
+ ast_free(hal);
}
}
ast_log(LOG_WARNING, "%s is not a valid netmask\n", nm);
if (error)
*error = 1;
- free(ha);
+ ast_free(ha);
return ret;
}
if (!inet_aton(tmp, &ha->netaddr)) {
ast_log(LOG_WARNING, "%s is not a valid IP\n", tmp);
if (error)
*error = 1;
- free(ha);
+ ast_free(ha);
return ret;
}
ha->netaddr.s_addr &= ha->netmask.s_addr;
ret = ha;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "%s/%s appended to acl for peer\n", stuff, nm);
+ ast_debug(1, "%s/%s appended to acl for peer\n", stuff, nm);
return ret;
}
/* Start optimistic */
int res = AST_SENSE_ALLOW;
while (ha) {
+#if 0 /* debugging code */
char iabuf[INET_ADDRSTRLEN];
char iabuf2[INET_ADDRSTRLEN];
/* DEBUG */
ast_copy_string(iabuf, ast_inet_ntoa(sin->sin_addr), sizeof(iabuf));
ast_copy_string(iabuf2, ast_inet_ntoa(ha->netaddr), sizeof(iabuf2));
- if (option_debug)
- ast_log(LOG_DEBUG, "##### Testing %s with %s\n", iabuf, iabuf2);
+ ast_debug(1, "##### Testing %s with %s\n", iabuf, iabuf2);
+#endif
/* For each rule, if this address and the netmask = the net address
apply the current rule */
if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == ha->netaddr.s_addr)
char srv[256];
char host[256];
int tportno = ntohs(sin->sin_port);
- if (inet_aton(value, &sin->sin_addr))
- return 0;
if (service) {
snprintf(srv, sizeof(srv), "%s.%s", service, value);
if (ast_get_srv(NULL, host, sizeof(host), &tportno, srv) > 0) {
{ "EF", 0x2E },
};
+int ast_str2cos(const char *value, unsigned int *cos)
+{
+ int fval;
+
+ if (sscanf(value, "%d", &fval) == 1) {
+ if (fval < 8) {
+ *cos = fval;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
int ast_str2tos(const char *value, unsigned int *tos)
{
int fval;
int s;
struct sockaddr_in sin;
socklen_t slen;
-
s = socket(PF_INET, SOCK_DGRAM, 0);
if (s < 0) {
ast_log(LOG_WARNING, "Cannot create socket\n");