Browse code

unixsock_reply_sendto added.

Jan Janak authored on 03/03/2004 20:41:52
Showing 2 changed files
... ...
@@ -655,6 +655,30 @@ ssize_t unixsock_reply_send(void)
655 655
 }
656 656
 
657 657
 
658
+/*
659
+ * Send a reply
660
+ */
661
+ssize_t unixsock_reply_sendto(struct sockaddr_un* to)
662
+{
663
+	int ret;
664
+
665
+	if (!to) {
666
+		LOG(L_ERR, "unixsock_reply_sendto: Invalid parameter value\n");
667
+		return -1;
668
+	}
669
+
670
+	ret = sendto(sock, reply_buf, reply_pos.s - reply_buf, MSG_DONTWAIT, 
671
+		     (struct sockaddr*)to, SUN_LEN(to));
672
+
673
+	if (ret == -1) {
674
+		LOG(L_ERR, "unixsock_reply_sendto: sendto: %s\n", 
675
+		    strerror(errno));
676
+	}
677
+
678
+	return ret;
679
+}
680
+
681
+
658 682
 /*
659 683
  * Read a line, the result will be stored in line
660 684
  * parameter, the data is not copied, it's just
... ...
@@ -922,3 +946,12 @@ int unixsock_reply_printf(char* fmt, ...)
922 946
 	reply_pos.len -= ret;
923 947
 	return 0;
924 948
 }
949
+
950
+
951
+/*
952
+ * Return the address of the sender
953
+ */
954
+struct sockaddr_un* unix_sender_address(void)
955
+{
956
+	return &reply_addr;
957
+}
... ...
@@ -95,6 +95,12 @@ int unixsock_reply_printf(char* fmt, ...);
95 95
 ssize_t unixsock_reply_send(void);
96 96
 
97 97
 
98
+/*
99
+ * Send the reply to the given destination
100
+ */
101
+ssize_t unixsock_reply_sendto(struct sockaddr_un* to);
102
+
103
+
98 104
 /*
99 105
  * Read a line, the result will be stored in line
100 106
  * parameter, the data is not copied, it's just
... ...
@@ -120,4 +126,10 @@ int unixsock_read_body(str* body, str* source);
120 126
 int unixsock_read_lineset(str* lineset, str* source);
121 127
 
122 128
 
129
+/*
130
+ * Return the address of the sender
131
+ */
132
+struct sockaddr_un* unixsock_sender_address(void);
133
+
134
+
123 135
 #endif /* _UNIXSOCK_SERVER_H */