//
//  ipconverter.hpp
//  PSNDSelector
//
//  Created by powersmart on 16/6/5.
//  Copyright © 2016年 PowerInfo. All rights reserved.
//

#ifndef ipconverter_hpp
#define ipconverter_hpp

#define PSL_IPV4_ONLY 1
#define PSL_IPV6_ONLY 2

/**
 @param type 1 for ip point is &(int), it's network byte order
             2 for ip point is char*
 @param ipv4 see type
 @param ipv6 char array, length of array should larger than 128
 @param sizeofipv6 size of char array `ipv6`
 @return error return -1
         success return 0
 */
int converter_ipv4_to_ipv6(int type, void *ipv4, char* ipv6, int sizeofipv6);

/**
 @param type 1 for ip point is &(int), it's network byte order
             2 for ip point is char*
 @param ipv4 see type
 @param ipv6 char array, length of array should not less than 128
 @param sizeofipv4 size of char array `ipv4` if `ipv4` type is 1, length of array should not less than 128
 @return error return -1
 success return 0
 */
int converter_ipv6_to_ipv4(int type, char* ipv6, void *ipv4, int sizeofipv4);

/**
 @return if ipv4-only, return PSL_IPV4_ONLY
         if ipv6-only, return PSL_IPV6_ONLY
         failed, return -1
 */
int checknetwork_ipv4_ipv6();

#endif /* ipconverter_hpp */
