Re: [libvirt] [PATCH] network utilities: Properly convert port numbers to/from network byte order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 04, 2009 at 10:14:56AM +0000, Matthew Booth wrote:
> * src/util/network.c: Add htons and ntohs in virSocket(Get|Set)Port
> ---
>  src/util/network.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/network.c b/src/util/network.c
> index d67340a..56426e7 100644
> --- a/src/util/network.c
> +++ b/src/util/network.c
> @@ -173,6 +173,8 @@ virSocketSetPort(virSocketAddrPtr addr, int port) {
>      if (addr == NULL)
>          return -1;
>  
> +    port = htons(port);
> +
>      if(addr->stor.ss_family == AF_INET) {
>          addr->inet4.sin_port = port;
>      }
> @@ -201,11 +203,11 @@ virSocketGetPort(virSocketAddrPtr addr) {
>          return -1;
>  
>      if(addr->stor.ss_family == AF_INET) {
> -        return addr->inet4.sin_port;
> +        return ntohs(addr->inet4.sin_port);
>      }
>  
>      else if(addr->stor.ss_family == AF_INET6) {
> -        return addr->inet6.sin6_port;
> +        return ntohs(addr->inet6.sin6_port);
>      }
>  
>      return -1;

  Okidoc, pushed, thansk !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]