make all C callback function unexported

master
fangdingjun 6 years ago
parent 387719e6f0
commit 4e5708fbe4

@ -14,9 +14,9 @@ struct session
void *data;
};
extern int OnDataReadCallback(void *, char *, int);
extern int OnDataWriteCallback(void *, char *, int);
extern int OnDataTimeoutRead(void *, int);
extern int onDataReadCallback(void *, char *, int);
extern int onDataWriteCallback(void *, char *, int);
extern int onDataTimeoutRead(void *, int);
struct session *init_gnutls_client_session();
struct session *init_gnutls_server_session();
@ -31,7 +31,7 @@ int set_callback(struct session *sess);
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);
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;
}
//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);
return ret;
}
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)
{
return OnDataTimeoutRead(ptr, ms);
return onDataTimeoutRead(ptr, ms);
}
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)

@ -341,10 +341,10 @@ func (c *Conn) getServerName() string {
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
func OnDataReadCallback(d unsafe.Pointer, cbuf *C.char, bufLen C.int) C.int {
//export onDataReadCallback
func onDataReadCallback(d unsafe.Pointer, cbuf *C.char, bufLen C.int) C.int {
//log.Println("read addr ", uintptr(d))
conn := (*Conn)(unsafe.Pointer((uintptr(d))))
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)
}
// 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
func OnDataWriteCallback(d unsafe.Pointer, cbuf *C.char, bufLen C.int) C.int {
//export onDataWriteCallback
func onDataWriteCallback(d unsafe.Pointer, cbuf *C.char, bufLen C.int) C.int {
//log.Println("write addr ", uintptr(d), int(_l))
conn := (*Conn)(unsafe.Pointer((uintptr(d))))
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)
}
// OnDataTimeoutRead callback function for timeout read
// onDataTimeoutRead callback function for timeout read
//
//export OnDataTimeoutRead
func OnDataTimeoutRead(d unsafe.Pointer, delay C.int) C.int {
//export onDataTimeoutRead
func onDataTimeoutRead(d unsafe.Pointer, delay C.int) C.int {
log.Println("timeout pull function")
return 0
}
// OnCertSelectCallback callback function for ceritificate select,
// onCertSelectCallback callback function for ceritificate select,
// this function select certificate from Config.Certificates field,
//
// on server side, this function select the certificate depend on SNI what client send,
// if client not send SNI, select the Config.Certificates[0]
//
//export OnCertSelectCallback
func OnCertSelectCallback(ptr unsafe.Pointer, hostname *C.char,
//export onCertSelectCallback
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 {
servername := C.GoStringN(hostname, namelen)

Loading…
Cancel
Save