make all C callback function unexported

master
fangdingjun 6 years ago
parent 387719e6f0
commit 4e5708fbe4

@ -14,9 +14,9 @@ struct session
void *data; void *data;
}; };
extern int OnDataReadCallback(void *, char *, int); extern int onDataReadCallback(void *, char *, int);
extern int OnDataWriteCallback(void *, char *, int); extern int onDataWriteCallback(void *, char *, int);
extern int OnDataTimeoutRead(void *, int); extern int onDataTimeoutRead(void *, int);
struct session *init_gnutls_client_session(); struct session *init_gnutls_client_session();
struct session *init_gnutls_server_session(); struct session *init_gnutls_server_session();
@ -31,7 +31,7 @@ int set_callback(struct session *sess);
void session_destroy(struct session *); void session_destroy(struct session *);
int OnCertSelectCallback(void *ptr, char *hostname, int namelen, int onCertSelectCallback(void *ptr, char *hostname, int namelen,
int *pcert_length, gnutls_pcert_st **cert, gnutls_privkey_t *privke); int *pcert_length, gnutls_pcert_st **cert, gnutls_privkey_t *privke);
gnutls_cipher_hd_t new_cipher(int cipher_type, char *key, int keylen, char *iv, int ivlen); gnutls_cipher_hd_t new_cipher(int cipher_type, char *key, int keylen, char *iv, int ivlen);

@ -85,24 +85,24 @@ int cert_select_callback(gnutls_session_t sess, const gnutls_datum_t *req_ca_dn,
//return -1; //return -1;
} }
//printf("call go callback\n"); //printf("call go callback\n");
ret = OnCertSelectCallback(ptr, hostname, namelen, pcert_length, pcert, pkey); ret = onCertSelectCallback(ptr, hostname, namelen, pcert_length, pcert, pkey);
//printf("after callback pcert_length %d, pcert 0x%x, pkey 0x%x\n", *pcert_length, pcert, pkey); //printf("after callback pcert_length %d, pcert 0x%x, pkey 0x%x\n", *pcert_length, pcert, pkey);
return ret; return ret;
} }
ssize_t pull_function(gnutls_transport_ptr_t ptr, void *data, size_t len) ssize_t pull_function(gnutls_transport_ptr_t ptr, void *data, size_t len)
{ {
return OnDataReadCallback(ptr, data, len); return onDataReadCallback(ptr, data, len);
} }
int pull_timeout_function(gnutls_transport_ptr_t ptr, unsigned int ms) int pull_timeout_function(gnutls_transport_ptr_t ptr, unsigned int ms)
{ {
return OnDataTimeoutRead(ptr, ms); return onDataTimeoutRead(ptr, ms);
} }
ssize_t push_function(gnutls_transport_ptr_t ptr, const void *data, size_t len) ssize_t push_function(gnutls_transport_ptr_t ptr, const void *data, size_t len)
{ {
return OnDataWriteCallback(ptr, (char *)data, len); return onDataWriteCallback(ptr, (char *)data, len);
} }
void set_data(struct session *sess, size_t data) void set_data(struct session *sess, size_t data)

@ -341,10 +341,10 @@ func (c *Conn) getServerName() string {
return name return name
} }
// OnDataReadCallback callback function for gnutls library want to read data from network // onDataReadCallback callback function for gnutls library want to read data from network
// //
//export OnDataReadCallback //export onDataReadCallback
func OnDataReadCallback(d unsafe.Pointer, cbuf *C.char, bufLen C.int) C.int { func onDataReadCallback(d unsafe.Pointer, cbuf *C.char, bufLen C.int) C.int {
//log.Println("read addr ", uintptr(d)) //log.Println("read addr ", uintptr(d))
conn := (*Conn)(unsafe.Pointer((uintptr(d)))) conn := (*Conn)(unsafe.Pointer((uintptr(d))))
buf := make([]byte, int(bufLen)) buf := make([]byte, int(bufLen))
@ -360,10 +360,10 @@ func OnDataReadCallback(d unsafe.Pointer, cbuf *C.char, bufLen C.int) C.int {
return C.int(n) return C.int(n)
} }
// OnDataWriteCallback callback function for gnutls library want to send data to network // onDataWriteCallback callback function for gnutls library want to send data to network
// //
//export OnDataWriteCallback //export onDataWriteCallback
func OnDataWriteCallback(d unsafe.Pointer, cbuf *C.char, bufLen C.int) C.int { func onDataWriteCallback(d unsafe.Pointer, cbuf *C.char, bufLen C.int) C.int {
//log.Println("write addr ", uintptr(d), int(_l)) //log.Println("write addr ", uintptr(d), int(_l))
conn := (*Conn)(unsafe.Pointer((uintptr(d)))) conn := (*Conn)(unsafe.Pointer((uintptr(d))))
gobuf := C.GoBytes(unsafe.Pointer(cbuf), bufLen) gobuf := C.GoBytes(unsafe.Pointer(cbuf), bufLen)
@ -375,22 +375,22 @@ func OnDataWriteCallback(d unsafe.Pointer, cbuf *C.char, bufLen C.int) C.int {
return C.int(n) return C.int(n)
} }
// OnDataTimeoutRead callback function for timeout read // onDataTimeoutRead callback function for timeout read
// //
//export OnDataTimeoutRead //export onDataTimeoutRead
func OnDataTimeoutRead(d unsafe.Pointer, delay C.int) C.int { func onDataTimeoutRead(d unsafe.Pointer, delay C.int) C.int {
log.Println("timeout pull function") log.Println("timeout pull function")
return 0 return 0
} }
// OnCertSelectCallback callback function for ceritificate select, // onCertSelectCallback callback function for ceritificate select,
// this function select certificate from Config.Certificates field, // this function select certificate from Config.Certificates field,
// //
// on server side, this function select the certificate depend on SNI what client send, // on server side, this function select the certificate depend on SNI what client send,
// if client not send SNI, select the Config.Certificates[0] // if client not send SNI, select the Config.Certificates[0]
// //
//export OnCertSelectCallback //export onCertSelectCallback
func OnCertSelectCallback(ptr unsafe.Pointer, hostname *C.char, func onCertSelectCallback(ptr unsafe.Pointer, hostname *C.char,
namelen C.int, pcertLength *C.int, cert **C.gnutls_pcert_st, privkey *C.gnutls_privkey_t) C.int { namelen C.int, pcertLength *C.int, cert **C.gnutls_pcert_st, privkey *C.gnutls_privkey_t) C.int {
servername := C.GoStringN(hostname, namelen) servername := C.GoStringN(hostname, namelen)

Loading…
Cancel
Save