Commit a6ab05b9 authored by Omar Kallel's avatar Omar Kallel

Use specific Connection Request path designated in icwmp config

parent 196ae20a
Pipeline #12506 passed with stage
in 8 seconds
......@@ -307,6 +307,25 @@ int get_global_config(struct config *conf)
} else {
return error;
}
if ((error = uci_get_value(UCI_CPE_CRPATH_PATH, &value)) == CWMP_OK) {
if (conf->connection_request_path != NULL) {
free(conf->connection_request_path);
}
if (value == NULL)
conf->connection_request_path = strdup("/");
else {
if (value[0] == '/')
conf->connection_request_path = strdup(value);
else {
char *cr_path = NULL;
asprintf(&cr_path, "/%s", value);
conf->connection_request_path = strdup(cr_path);
free(cr_path);
}
}
} else {
return error;
}
if ((error = uci_get_value(UCI_CPE_NOTIFY_PERIODIC_ENABLE, &value)) == CWMP_OK) {
bool a = true;
if (value != NULL) {
......
......@@ -287,6 +287,7 @@ static void http_cr_new_client(int client, bool service_available)
int8_t auth_status = 0;
bool auth_digest_checked = false;
bool method_is_get = false;
char *cr_http_get_head = NULL;
pthread_mutex_lock(&mutex_config_load);
fp = fdopen(client, "r+");
......@@ -298,8 +299,10 @@ static void http_cr_new_client(int client, bool service_available)
service_available = false;
goto http_end;
}
asprintf(&cr_http_get_head, "GET %s", cwmp_main.conf.connection_request_path);
while (fgets(buffer, sizeof(buffer), fp)) {
if (!strncasecmp(buffer, "GET ", strlen("GET ")))
if (!strncasecmp(buffer, cr_http_get_head, strlen(cr_http_get_head)))
method_is_get = true;
if (!strncasecmp(buffer, "Authorization: Digest ", strlen("Authorization: Digest "))) {
auth_digest_checked = true;
......@@ -318,8 +321,8 @@ static void http_cr_new_client(int client, bool service_available)
auth_status = 1;
else
auth_status = 0;
http_end:
FREE(cr_http_get_head);
if (!service_available || !method_is_get) {
CWMP_LOG(INFO, "Receive Connection Request: Return 503 Service Unavailable");
fputs("HTTP/1.1 503 Service Unavailable\r\n", fp);
......
......@@ -69,6 +69,7 @@ typedef struct config {
char *ipv6;
char *interface;
char *ubus_socket;
char *connection_request_path;
int connection_request_port;
int period;
int periodic_notify_interval;
......
......@@ -38,6 +38,7 @@
#define UCI_CPE_INTERFACE_PATH "cwmp.cpe.interface"
#define UCI_CPE_UBUS_SOCKET_PATH "cwmp.cpe.ubus_socket"
#define UCI_CPE_PORT_PATH "cwmp.cpe.port"
#define UCI_CPE_CRPATH_PATH "cwmp.cpe.path"
#define UCI_CPE_LOG_FILE_NAME "cwmp.cpe.log_file_name"
#define UCI_CPE_LOG_MAX_SIZE "cwmp.cpe.log_max_size"
#define UCI_CPE_ENABLE_STDOUT_LOG "cwmp.cpe.log_to_console"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment