TfwHttpResp * test_resp_alloc(size_t data_len) { TfwHttpResp *resp; TfwMsgIter it; resp = (TfwHttpResp *)tfw_http_msg_create(&it, Conn_HttpSrv, data_len); BUG_ON(!resp); return resp; }
static void tfw_bmb_msg_send(int tn, int cn) { TfwBmbTask *task = &bmb_task[tn]; int fz_tries = 0, r; TfwStr msg; TfwHttpMsg req; TfwMsgIter it; BUG_ON(!task->conn[cn].sk); do { if (++fz_tries > 10) { TFW_ERR("Too many fuzzer tries to generate request\n"); return; } r = fuzz_gen(&task->ctx, task->buf, task->buf + BUF_SIZE, 0, 1, FUZZ_REQ); if (r < 0) { TFW_ERR("Cannot generate HTTP request, r=%d\n", r); return; } if (r == FUZZ_END) fuzz_init(&task->ctx, true); } while (r != FUZZ_VALID); msg.ptr = task->buf; msg.skb = NULL; msg.len = strlen(msg.ptr); msg.flags = 0; if (!tfw_http_msg_create(&req, &it, Conn_Clnt, msg.len)) { TFW_WARN("Cannot create HTTP request.\n"); return; } if (verbose) TFW_LOG("Send request:\n" "------------------------------\n" "%s\n" "------------------------------\n", task->buf); tfw_http_msg_write(&it, &req, &msg); ss_send(task->conn[cn].sk, &req.msg.skb_list, true); atomic_inc(&bmb_request_send); }
TfwHttpReq * test_req_alloc(size_t data_len) { TfwHttpReq *req; TfwMsgIter it; /* Actually there were more code here, mostly it was copy-paste from * tfw_http_msg_alloc(). It is removed because we need to test how it * initializes the message and we would not like to test the copy-paste. */ req = (TfwHttpReq *)tfw_http_msg_create(&it, Conn_HttpClnt, data_len); BUG_ON(!req); return req; }