diff options
Diffstat (limited to 'sesman/libscp/libscp_session.c')
-rw-r--r-- | sesman/libscp/libscp_session.c | 54 |
1 files changed, 10 insertions, 44 deletions
diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c index a1859aa5..e6c77058 100644 --- a/sesman/libscp/libscp_session.c +++ b/sesman/libscp/libscp_session.c @@ -164,7 +164,7 @@ scp_session_set_rsr(struct SCP_SESSION *s, tui8 rsr) /*******************************************************************/ int -scp_session_set_locale(struct SCP_SESSION *s, char *str) +scp_session_set_locale(struct SCP_SESSION *s, const char *str) { if (0 == str) { @@ -180,7 +180,7 @@ scp_session_set_locale(struct SCP_SESSION *s, char *str) /*******************************************************************/ int -scp_session_set_username(struct SCP_SESSION *s, char *str) +scp_session_set_username(struct SCP_SESSION *s, const char *str) { if (0 == str) { @@ -206,7 +206,7 @@ scp_session_set_username(struct SCP_SESSION *s, char *str) /*******************************************************************/ int -scp_session_set_password(struct SCP_SESSION *s, char *str) +scp_session_set_password(struct SCP_SESSION *s, const char *str) { if (0 == str) { @@ -232,7 +232,7 @@ scp_session_set_password(struct SCP_SESSION *s, char *str) /*******************************************************************/ int -scp_session_set_domain(struct SCP_SESSION *s, char *str) +scp_session_set_domain(struct SCP_SESSION *s, const char *str) { if (0 == str) { @@ -258,7 +258,7 @@ scp_session_set_domain(struct SCP_SESSION *s, char *str) /*******************************************************************/ int -scp_session_set_program(struct SCP_SESSION *s, char *str) +scp_session_set_program(struct SCP_SESSION *s, const char *str) { if (0 == str) { @@ -284,7 +284,7 @@ scp_session_set_program(struct SCP_SESSION *s, char *str) /*******************************************************************/ int -scp_session_set_directory(struct SCP_SESSION *s, char *str) +scp_session_set_directory(struct SCP_SESSION *s, const char *str) { if (0 == str) { @@ -310,7 +310,7 @@ scp_session_set_directory(struct SCP_SESSION *s, char *str) /*******************************************************************/ int -scp_session_set_client_ip(struct SCP_SESSION *s, char *str) +scp_session_set_client_ip(struct SCP_SESSION *s, const char *str) { if (0 == str) { @@ -336,7 +336,7 @@ scp_session_set_client_ip(struct SCP_SESSION *s, char *str) /*******************************************************************/ int -scp_session_set_hostname(struct SCP_SESSION *s, char *str) +scp_session_set_hostname(struct SCP_SESSION *s, const char *str) { if (0 == str) { @@ -362,7 +362,7 @@ scp_session_set_hostname(struct SCP_SESSION *s, char *str) /*******************************************************************/ int -scp_session_set_errstr(struct SCP_SESSION *s, char *str) +scp_session_set_errstr(struct SCP_SESSION *s, const char *str) { if (0 == str) { @@ -396,49 +396,15 @@ scp_session_set_display(struct SCP_SESSION *s, SCP_DISPLAY display) /*******************************************************************/ int -scp_session_set_addr(struct SCP_SESSION *s, int type, void *addr) +scp_session_set_addr(struct SCP_SESSION *s, int type, const void *addr) { - struct in_addr ip4; -#ifdef IN6ADDR_ANY_INIT - struct in6_addr ip6; -#endif - int ret; - switch (type) { case SCP_ADDRESS_TYPE_IPV4: - /* convert from char to 32bit*/ - ret = inet_pton(AF_INET, addr, &ip4); - - if (ret == 0) - { - log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__); - inet_pton(AF_INET, "127.0.0.1", &ip4); - g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4); - return 1; - } - - g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4); - break; - case SCP_ADDRESS_TYPE_IPV4_BIN: g_memcpy(&(s->ipv4addr), addr, 4); break; #ifdef IN6ADDR_ANY_INIT case SCP_ADDRESS_TYPE_IPV6: - /* convert from char to 128bit*/ - ret = inet_pton(AF_INET6, addr, &ip6); - - if (ret == 0) - { - log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__); - inet_pton(AF_INET, "::1", &ip6); - g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16); - return 1; - } - - g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16); - break; - case SCP_ADDRESS_TYPE_IPV6_BIN: g_memcpy(s->ipv6addr, addr, 16); break; #endif |