]> source.dussan.org Git - rspamd.git/commitdiff
Add function rspamd_inet_address_set_port.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 21 Aug 2014 15:20:40 +0000 (16:20 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 21 Aug 2014 15:20:40 +0000 (16:20 +0100)
src/libutil/util.c
src/libutil/util.h

index 3c696c57911fd0da9d639b2661637e5bcc43566a..4562a90fe7ac27e9dd46028214c6c3c8595a1a73 100644 (file)
@@ -2371,6 +2371,19 @@ rspamd_inet_address_get_port (rspamd_inet_addr_t *addr)
        return 0;
 }
 
+void
+rspamd_inet_address_set_port (rspamd_inet_addr_t *addr, uint16_t port)
+{
+       switch (addr->af) {
+       case AF_INET:
+               addr->addr.s4.sin_port = htons (port);
+               break;
+       case AF_INET6:
+               addr->addr.s6.sin6_port = htons (port);
+               break;
+       }
+}
+
 int
 rspamd_inet_address_connect (rspamd_inet_addr_t *addr, gint type,
                gboolean async)
index 7cc73f53a6508fdca974f862b32a9f5057c043d3..9bef49a7e828af7cf1822c5e29bf29acb23e562a 100644 (file)
@@ -510,6 +510,11 @@ const char * rspamd_inet_address_to_string (rspamd_inet_addr_t *addr);
  */
 uint16_t rspamd_inet_address_get_port (rspamd_inet_addr_t *addr);
 
+/**
+ * Set port for inet address
+ */
+void rspamd_inet_address_set_port (rspamd_inet_addr_t *addr, uint16_t port);
+
 /**
  * Connect to inet_addr address
  * @param addr