Iptables w SunRPC

0

Witam,

Mam problem z wykonaniem komunikacji między programami klienta i serwera wykonanymi w SunRPC.
Klient ma wysyłać do serwera żądanie podania reguł zapory (IPTABLES) oraz przekazanie informacji dotyczących środowiska użytkownika (polecenie SET, bez parametrów). W programowaniu w C mam jeszcze duże luki i nie wiem jak zaprogramować odpowiednie procedury po stronie programu klienta jaki serwera.
Czy ktoś z Was mógłby mi trochę pomóc?

Pozdrawiam
A.S.

0

Pokaz kod i powiedz w czym masz konkretnie problem :)

0

Chodzi o wprowadzenie odpowiedniego kodu (realizującego polecenia z pierwszego mojego postu tego wątku) do plików serwera:

/*

  • This is sample code generated by rpcgen.
  • These are only templates and you can use them
  • as a guideline for developing your own functions.
    */

#include "sunrpc_01.h"

sunrpc_01_wy *
sunrpc_01_zapora_1_svc(sunrpc_01_we arg1, struct svc_req *rqstp)
{
static sunrpc_01_wy result;

/*
 * insert server code here
 */

return &result;

}

sunrpc_01_wy *
sunrpc_01_zmienne_1_svc(sunrpc_01_we arg1, struct svc_req *rqstp)
{
static sunrpc_01_wy result;

/*
 * insert server code here
 */

return &result;

}

oraz do pliku klienta:

/*

  • This is sample code generated by rpcgen.
  • These are only templates and you can use them
  • as a guideline for developing your own functions.
    */

#include "sunrpc_01.h"

void
sunrpc_01sunrpc_1(char *host)
{
CLIENT *clnt;
sunrpc_01_wy *result_1;
sunrpc_01_we sunrpc_01_zapora_1_arg1;
sunrpc_01_wy *result_2;
sunrpc_01_we sunrpc_01_zmienne_1_arg1;

#ifndef DEBUG
clnt = clnt_create (host, sunrpc_01SUNRPC, sunrpc_01_V1, "udp");
if (clnt == NULL) {
clnt_pcreateerror (host);
exit (1);
}
#endif /* DEBUG */

result_1 = sunrpc_01_zapora_1(sunrpc_01_zapora_1_arg1, clnt);
if (result_1 == (sunrpc_01_wy *) NULL) {
	clnt_perror (clnt, "call failed");
}
result_2 = sunrpc_01_zmienne_1(sunrpc_01_zmienne_1_arg1, clnt);
if (result_2 == (sunrpc_01_wy *) NULL) {
	clnt_perror (clnt, "call failed");
}

#ifndef DEBUG
clnt_destroy (clnt);
#endif /* DEBUG */
}

int
main (int argc, char *argv[])
{
char *host;

if (argc < 2) {
	printf ("usage: %s server_host\n", argv[0]);
	exit (1);
}
host = argv[1];
sunrpc_01sunrpc_1 (host);

exit (0);
}

Pliki te zostały wygenerowanie rpcgen'em na Linuxie z pliku
sunrpc_01.x:

struct sunrpc_01_we {
int sunrpc_01_nr;
string sunrpc_01_komunikat<1000>;
};

struct sunrpc_01_wy{
int sunrpc_01_wynik;
string sunrpc_01_dane<1000>;
};

struct wyjscie_sunrpc_01 {
resp out;
};

program sunrpc_01SUNRPC{
version sunrpc_01_V1{
sunrpc_01_wy sunrpc_01_zapora(sunrpc_01_we) = 1;
sunrpc_01_wy sunrpc_01_zmienne(sunrpc_01_we) = 2;
} = 1;
} = 0x21000000;

1 użytkowników online, w tym zalogowanych: 0, gości: 1