613dddc385
patches originally created for pkgsrc, and adds broadcast/receive real-time FCP commands (experimental Entropy extensions). Add patch making all FCP protocol commands use \r\n as EOL, now required by Freenet (\n wasn't enough).
254 lines
8.3 KiB
Text
254 lines
8.3 KiB
Text
$NetBSD: patch-aa,v 1.3 2006/05/16 18:02:04 tv Exp $
|
|
|
|
--- ftfcp.c.orig 2005-06-24 08:57:55.000000000 -0400
|
|
+++ ftfcp.c
|
|
@@ -235,7 +235,7 @@ int fcp_send_cmds(pid_t pid, fcp_t *f, c
|
|
for (i = 0, cmd = cmds; i < count; i++, cmd++) {
|
|
switch (cmd->type) {
|
|
case ARG_NONE:
|
|
- rc = sk_printf(&f->conn, "%s\n", cmd->name);
|
|
+ rc = sk_printf(&f->conn, "%s\r\n", cmd->name);
|
|
if (0 != rc) {
|
|
LOG(L_ERROR,("{%d} sending command '%s' failed (%s)\n",
|
|
pid, cmd->name, strerror(errno)));
|
|
@@ -252,7 +252,7 @@ int fcp_send_cmds(pid_t pid, fcp_t *f, c
|
|
LOG(L_DEBUG,("{%d} skip %s=%s\n", pid, cmd->name, arg));
|
|
break;
|
|
}
|
|
- rc = sk_printf(&f->conn, "%s=%s\n", cmd->name, arg);
|
|
+ rc = sk_printf(&f->conn, "%s=%s\r\n", cmd->name, arg);
|
|
if (0 != rc) {
|
|
LOG(L_ERROR,("{%d} sending command '%s=%s' failed (%s)\n",
|
|
pid, cmd->name, arg, strerror(errno)));
|
|
@@ -268,7 +268,7 @@ int fcp_send_cmds(pid_t pid, fcp_t *f, c
|
|
LOG(L_DEBUG,("{%d} skip %s=%s\n", pid, cmd->name, arg));
|
|
break;
|
|
}
|
|
- rc = sk_printf(&f->conn, "%s=%s\n", cmd->name, arg);
|
|
+ rc = sk_printf(&f->conn, "%s=%s\r\n", cmd->name, arg);
|
|
if (0 != rc) {
|
|
LOG(L_ERROR,("{%d} sending command '%s=%s' failed (%s)\n",
|
|
pid, cmd->name, arg, strerror(errno)));
|
|
@@ -277,7 +277,7 @@ int fcp_send_cmds(pid_t pid, fcp_t *f, c
|
|
LOG(L_DEBUG,("{%d} sent %s=%s\n", pid, cmd->name, arg));
|
|
break;
|
|
case ARG_STRING:
|
|
- rc = sk_printf(&f->conn, "%s=%s\n", cmd->name, cmd->arg);
|
|
+ rc = sk_printf(&f->conn, "%s=%s\r\n", cmd->name, cmd->arg);
|
|
if (0 != rc) {
|
|
LOG(L_ERROR,("{%d} sending command '%s=%s' failed (%s)\n",
|
|
pid, cmd->name, cmd->arg, strerror(errno)));
|
|
@@ -1309,52 +1309,52 @@ int fcp_put(fcp_t *f, const char *uri, i
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent 00 00 00 02\n", pid));
|
|
|
|
- if (0 != sk_printf(&f->conn, "ClientPut\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "ClientPut\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent ClientPut\n", pid));
|
|
|
|
if (htl > 0) {
|
|
- if (0 != sk_printf(&f->conn, "HopsToLive=%x\n", htl)) {
|
|
+ if (0 != sk_printf(&f->conn, "HopsToLive=%x\r\n", htl)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent HopsToLive=%x\n", pid, htl));
|
|
}
|
|
|
|
- if (0 != sk_printf(&f->conn, "URI=%s\n", uri)) {
|
|
+ if (0 != sk_printf(&f->conn, "URI=%s\r\n", uri)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent URI=%s\n", pid, uri));
|
|
|
|
size = f->datasize + f->metasize;
|
|
- if (0 != sk_printf(&f->conn, "DataLength=%x\n", size)) {
|
|
+ if (0 != sk_printf(&f->conn, "DataLength=%x\r\n", size)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent DataLength=%x\n", pid, size));
|
|
|
|
if (f->metasize > 0) {
|
|
size = f->metasize;
|
|
- if (0 != sk_printf(&f->conn, "MetadataLength=%x\n", size)) {
|
|
+ if (0 != sk_printf(&f->conn, "MetadataLength=%x\r\n", size)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent MetadataLength=%x\n", pid, size));
|
|
}
|
|
|
|
if (0 != delete) {
|
|
- if (0 != sk_printf(&f->conn, "RemoveLocalKey=%s\n", "yes")) {
|
|
+ if (0 != sk_printf(&f->conn, "RemoveLocalKey=%s\r\n", "yes")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent RemoveLocalKey=%s\n", pid, "yes"));
|
|
}
|
|
|
|
if (0 != meta_only) {
|
|
- if (0 != sk_printf(&f->conn, "MetadataOnly=%s\n", "yes")) {
|
|
+ if (0 != sk_printf(&f->conn, "MetadataOnly=%s\r\n", "yes")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent MetadataOnly=%s\n", pid, "yes"));
|
|
}
|
|
|
|
- if (0 != sk_printf(&f->conn, "Data\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "Data\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent Data\n", pid));
|
|
@@ -1465,13 +1465,13 @@ int fcp_chk(fcp_t *f)
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent 00 00 00 02\n", pid));
|
|
|
|
- if (0 != sk_printf(&f->conn, "GenerateCHK\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "GenerateCHK\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent GenerateCHK\n", pid));
|
|
|
|
size = f->datasize + f->metasize;
|
|
- if (0 != sk_printf(&f->conn, "DataLength=%x\n", size)) {
|
|
+ if (0 != sk_printf(&f->conn, "DataLength=%x\r\n", size)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent DataLength=%x\n",
|
|
@@ -1479,12 +1479,12 @@ int fcp_chk(fcp_t *f)
|
|
|
|
if (f->metasize > 0) {
|
|
size = f->metasize;
|
|
- if (0 != sk_printf(&f->conn, "MetadataLength=%x\n", size)) {
|
|
+ if (0 != sk_printf(&f->conn, "MetadataLength=%x\r\n", size)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent MetadataLength=%x\n", pid, size));
|
|
}
|
|
- if (0 != sk_printf(&f->conn, "Data\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "Data\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent Data\n", pid));
|
|
@@ -1745,29 +1745,29 @@ int fcp_encode_segment(fcp_t *f, size_t
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent 00 00 00 02\n", pid));
|
|
|
|
- if (0 != sk_printf(&f->conn, "FECEncodeSegment\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "FECEncodeSegment\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent FECEncodeSegment\n", pid));
|
|
|
|
#if 0
|
|
- if (0 != sk_printf(&f->conn, "RequestedLists=\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "RequestedLists=\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent RequestedList=\n", pid));
|
|
#endif
|
|
- if (0 != sk_printf(&f->conn, "DataLength=%x\n", f->metasize + datalen)) {
|
|
+ if (0 != sk_printf(&f->conn, "DataLength=%x\r\n", f->metasize + datalen)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent DataLength=%x\n", pid, f->metasize + datalen));
|
|
|
|
#if 0 /* This is stupid, but the metadata size is not specified */
|
|
- if (0 != sk_printf(&f->conn, "MetadataLength=%x\n", f->metasize)) {
|
|
+ if (0 != sk_printf(&f->conn, "MetadataLength=%x\r\n", f->metasize)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent MetadataLength=%x\n", pid, f->metasize));
|
|
#endif
|
|
- if (0 != sk_printf(&f->conn, "Data\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "Data\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent Data\n", pid));
|
|
@@ -1907,22 +1907,22 @@ int fcp_segment_file(fcp_t **pf, const c
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent 00 00 00 02\n", pid));
|
|
|
|
- if (0 != sk_printf(&f->conn, "FECSegmentFile\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "FECSegmentFile\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent FECSegmentFile\n", pid));
|
|
|
|
- if (0 != sk_printf(&f->conn, "AlgoName=%s\n", algo_name)) {
|
|
+ if (0 != sk_printf(&f->conn, "AlgoName=%s\r\n", algo_name)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent AlgoName=%s\n", pid, algo_name));
|
|
|
|
- if (0 != sk_printf(&f->conn, "FileLength=%x\n", file_length)) {
|
|
+ if (0 != sk_printf(&f->conn, "FileLength=%x\r\n", file_length)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent FileLength=%x\n", pid, file_length));
|
|
|
|
- if (0 != sk_printf(&f->conn, "EndMessage\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "EndMessage\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent EndMessage\n", pid));
|
|
@@ -2013,32 +2013,32 @@ int fcp_broadcast(fcp_t *f, int htl,
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent 00 00 00 02\n", pid));
|
|
|
|
- if (0 != sk_printf(&f->conn, "ClientBroadcast\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "ClientBroadcast\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent ClientBroadcast\n", pid));
|
|
|
|
- if (0 != sk_printf(&f->conn, "HopsToLive=%x\n", htl)) {
|
|
+ if (0 != sk_printf(&f->conn, "HopsToLive=%x\r\n", htl)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent HopsToLive=%x\n", pid, htl));
|
|
|
|
- if (0 != sk_printf(&f->conn, "Channel=%s\n", channel)) {
|
|
+ if (0 != sk_printf(&f->conn, "Channel=%s\r\n", channel)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent Channel=%s\n", pid, channel));
|
|
|
|
- if (0 != sk_printf(&f->conn, "Sender=%s\n", sender)) {
|
|
+ if (0 != sk_printf(&f->conn, "Sender=%s\r\n", sender)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent Sender=%s\n", pid, sender));
|
|
|
|
- if (0 != sk_printf(&f->conn, "Payload=%s\n", payload)) {
|
|
+ if (0 != sk_printf(&f->conn, "Payload=%s\r\n", payload)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent Payload=%s\n", pid, payload));
|
|
|
|
- if (0 != sk_printf(&f->conn, "EndMessage\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "EndMessage\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent EndMessage\n", pid));
|
|
@@ -2101,17 +2101,17 @@ int fcp_receive(fcp_t *f, int id)
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent 00 00 00 02\n", pid));
|
|
|
|
- if (0 != sk_printf(&f->conn, "ClientReceive\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "ClientReceive\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent ClientReceive\n", pid));
|
|
|
|
- if (0 != sk_printf(&f->conn, "ID=%x\n", id)) {
|
|
+ if (0 != sk_printf(&f->conn, "ID=%x\r\n", id)) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent ID=%x\n", pid, id));
|
|
|
|
- if (0 != sk_printf(&f->conn, "EndMessage\n")) {
|
|
+ if (0 != sk_printf(&f->conn, "EndMessage\r\n")) {
|
|
goto bailout;
|
|
}
|
|
LOG(L_DEBUG,("{%d} sent EndMessage\n", pid));
|